API for fetching random chinchilla images from Wikimedia Commons and Pixabay. Built with Next.js 15 and TypeScript, hosted on Vercel, images stored in Cloudinary.
- 🎲 Random domestic chinchilla images
- 📝 Metadata with author information and source links
- ⚡ Serverless API on Next.js
- 🖼️ Optimized WebP images via Cloudinary
- 📚 Interactive API documentation
- 🌐 Deployed on Vercel
- Install dependencies:
npm install- Create
.env.localfile:
cp .env.local.example .env.local- Fill in environment variables in
.env.local:
Register at cloudinary.com and get your credentials:
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret- Start dev server:
npm run devOpen http://localhost:3000 in your browser.
After setting up Cloudinary credentials:
npm run uploadThis script will:
- Upload all WebP images from
images-webp/to Cloudinary - Update
public/metadata.jsonwith Cloudinary URLs - Create checkpoints every 5 uploads
Returns a random chinchilla image with metadata.
Response:
{
"image": "https://res.cloudinary.com/.../chinchilla.webp",
"author": "Wikipedia User",
"mediawikiUrl": "https://commons.wikimedia.org/wiki/File:...",
"pixabayUrl": "https://pixabay.com/photos/...",
"basename": "Chinchilla_1",
"source": "wikimedia"
}Returns metadata only (without the image data).
Response:
{
"basename": "Chinchilla_1",
"author": "Wikipedia User",
"mediawikiUrl": "https://commons.wikimedia.org/wiki/File:...",
"pixabayUrl": "https://pixabay.com/photos/...",
"webpFile": "File_Chinchilla_1_by_User.webp",
"cloudinaryUrl": "https://res.cloudinary.com/...",
"source": "wikimedia"
}- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Image Storage: Cloudinary
- Hosting: Vercel
- Image Sources: Wikimedia Commons, Pixabay
random-chinchilla-api/
├── app/
│ ├── api/
│ │ └── random/ # API endpoints
│ ├── layout.tsx # Root layout
│ ├── page.tsx # Main page
│ └── globals.css # Global styles
├── lib/
│ ├── cloudinary.ts # Cloudinary utilities
│ └── metadata.ts # Metadata loader
├── types/
│ └── chinchilla.ts # TypeScript types
├── scripts/
│ ├── index.js # Wiki parser (original)
│ ├── convert-to-webp.js # WebP converter (original)
│ ├── upload-to-cloudinary.ts # Cloudinary uploader
│ ├── parse-pixabay.js # Pixabay parser
│ └── process-pixabay.ts # Pixabay processor
├── public/
│ └── metadata.json # Image metadata
└── images-webp/ # Local WebP images
- Create Git repository:
git init
git add .
git commit -m "Initial commit"-
Push to GitHub:
git remote add origin https://github.com/yourusername/random-chinchilla-api.git git push -u origin main
-
Connect to Vercel:
- Go to vercel.com
- Import your GitHub repository
- Vercel will automatically detect Next.js project
- Configure Environment Variables in Vercel:
In project settings, add:
CLOUDINARY_CLOUD_NAMECLOUDINARY_API_KEYCLOUDINARY_API_SECRET
- Deploy:
Vercel will automatically deploy your project!
npm run dev- Start dev servernpm run build- Build for productionnpm start- Start production servernpm run upload- Upload images to Cloudinarynpm run parse-pixabay- Parse images from Pixabaynpm run process-pixabay- Convert and upload Pixabay images
The scripts/ directory contains original scripts:
index.js- Wikimedia Commons parser for downloading imagesconvert-to-webp.js- Image converter to WebP formatparse-pixabay.js- Pixabay API parser
Use them to expand the image collection.
Current collection: ~100+ images of domestic chinchillas from Wikimedia Commons and Pixabay.
Images from Wikimedia Commons are distributed under various free licenses. Each image contains a link to the original with license and author information.
Images from Pixabay are available under the Pixabay License.
Contributions are welcome! Feel free to open issues or submit pull requests.
- Add changelog
- Set up pre-commit hooks
- Add development guidelines and instructions
Made with ❤️ by Pavel Kuzyakin using Next.js and Cloudinary
