Recipe API

A read-only REST API for products and categories.

Endpoints

Products

List all products

GET /products

Query Parameters:

Examples:

# All products
curl https://next-recipe-api.vercel.dev/products

# Products in the "tops" category
curl https://next-recipe-api.vercel.dev/products?category=tops

# Products in the "shoes" category
curl https://next-recipe-api.vercel.dev/products?category=shoes

# Sort by name (ascending)
curl https://next-recipe-api.vercel.dev/products?sort=name

# Sort by name (descending)
curl https://next-recipe-api.vercel.dev/products?sort=-name

# Pagination: get 5 products, skip first 2
curl https://next-recipe-api.vercel.dev/products?limit=5&skip=2

# Combined filters
curl "https://next-recipe-api.vercel.dev/products?category=tops&sort=name&limit=3"

Get single product

GET /products/:slug

Returns the product with its full category object.

Example:

curl https://next-recipe-api.vercel.dev/products/tee

Response:

{
  "id": "1",
  "name": "Tee",
  "slug": "tee",
  "description": "Lightweight cotton crew neck for everyday wear.",
  "price": 35,
  "image": "...",
  "category": { "id": "1", "name": "Tops", "slug": "tops" },
  "updatedAt": "2024-01-15T12:00:00.000Z"
}

Response (404):

{ "error": "Product not found" }

Categories

List all categories

GET /categories

Example:

curl https://next-recipe-api.vercel.dev/categories

Get single category

GET /categories/:slug

Returns the category with all products in that category.

Example:

curl https://next-recipe-api.vercel.dev/categories/tops
curl https://next-recipe-api.vercel.dev/categories/shorts
curl https://next-recipe-api.vercel.dev/categories/shoes

Response:

{
  "id": "1",
  "name": "Tops",
  "slug": "tops",
  "products": [
    { "id": "1", "name": "Tee", "slug": "tee", "description": "...", "price": 35, "image": "...", "category": "tops" }
  ]
}

Response (404):

{ "error": "Category not found" }

Get product activity

GET /products/:slug/activity

Returns simulated activity metrics for a single product. Numbers are deterministic based on the current time — stable on refresh but reset every hour with different products becoming "hot".

Example:

curl https://next-recipe-api.vercel.dev/products/tee/activity

Response:

{ "id": "1", "inDemand": true, "sold": 14, "wishlisted": 28, "viewed": 142 }

Get all product activity

GET /products/activity

Returns activity metrics for all products. Useful for showing demand indicators on a product listing page.

Example:

curl https://next-recipe-api.vercel.dev/products/activity

Promotion

Get promotion message

GET /promotion

Example:

curl https://next-recipe-api.vercel.dev/promotion

Response:

{ "message": "Check out our latest deals and discounts!" }

Data Structure

Product

{
  "id": "1",
  "name": "Tee",
  "slug": "tee",
  "description": "Lightweight cotton crew neck for everyday wear.",
  "price": 35,
  "image": "tee.png",
  "category": "tops",
  "updatedAt": "2024-01-15T12:00:00.000Z"
}

Category

{
  "id": "1",
  "name": "Tops",
  "slug": "tops"
}

Product Activity

{
  "id": "1",
  "inDemand": true,
  "sold": 14,
  "wishlisted": 28,
  "viewed": 142
}