A simple REST API that provides random animal pictures and GIFs, similar to cataas.com but supporting multiple animal types.
- Dogs
- Cats
- Turtles
- Ducks
- Gophers
- Rhinos
The architecture supports up to 1000+ different animal types.
npm installDevelopment mode (with auto-reload):
npm run devProduction mode:
npm startThe server will start on port 3000 by default (configurable via PORT environment variable).
Returns API information and available endpoints.
Lists all available animal types with their image and GIF counts.
Example Response:
{
"count": 6,
"animals": [
{
"type": "dog",
"name": "Dog",
"imageCount": 5,
"gifCount": 3
}
]
}Returns a random image or GIF for the specified animal (serves the file directly).
Example:
GET /dog- Random dog image or GIFGET /cat- Random cat image or GIF
Returns a random image for the specified animal (serves the file directly).
Example:
GET /dog/image- Random dog imageGET /turtle/image- Random turtle image
Returns a random GIF for the specified animal (serves the file directly).
Example:
GET /dog/gif- Random dog GIFGET /rhino/gif- Random rhino GIF
Returns all available images and GIFs for the specified animal.
Example Response:
{
"animal": "dog",
"name": "Dog",
"images": ["url1", "url2"],
"gifs": ["url1", "url2"],
"totalCount": 8
}To add a new animal type:
- Create image files in
public/images/{animal}/directory - Create GIF files in
public/gifs/{animal}/directory (use SVG with animations or actual GIF files) - Edit
data/animals.jsonand add a new entry with the animal type as the key:
{
"newanimal": {
"name": "New Animal",
"images": [
"images/newanimal/1.svg",
"images/newanimal/2.svg"
],
"gifs": [
"gifs/newanimal/1.svg"
]
}
}- Restart the server
No code changes required - the API automatically picks up new animal types from the JSON file.
npm testanimal-api/
├── data/
│ └── animals.json # Animal data (file paths to images and GIFs)
├── public/
│ ├── images/
│ │ ├── dog/ # Dog images (SVG files)
│ │ ├── cat/ # Cat images
│ │ ├── turtle/ # Turtle images
│ │ ├── duck/ # Duck images
│ │ ├── gopher/ # Gopher images
│ │ └── rhino/ # Rhino images
│ └── gifs/
│ ├── dog/ # Dog GIFs (animated SVG files)
│ ├── cat/ # Cat GIFs
│ ├── turtle/ # Turtle GIFs
│ ├── duck/ # Duck GIFs
│ ├── gopher/ # Gopher GIFs
│ └── rhino/ # Rhino GIFs
├── src/
│ └── index.js # Main API server
├── package.json
└── README.md
Note: The current implementation uses SVG files for images and animated SVGs for GIFs. You can replace these with actual JPG, PNG, or GIF files as needed.
MIT