Recipe API Documentation

Endpoints

Get Recipes

Retrieve a list of recipes with optional filtering, pagination, and sorting.

Query Parameters

Parameter Description Default
page Page number for pagination 1
limit Number of recipes per page 10
category Filter recipes by category ID -
search Search term to filter recipes -
sortBy Field and order to sort results (format: field:order) -

Example Requests

  1. Get the second page with 20 recipes per page:
    GET /api/recipes?page=2&limit=20
  2. Filter recipes by category:
    GET /api/recipes?category=1
  3. Search for recipes containing "pasta":
    GET /api/recipes?search=pasta
  4. Sort recipes by creation date (newest first):
    GET /api/recipes?sortBy=created_at:desc
  5. Combine filtering, pagination, and sorting:
    GET /api/recipes?page=1&limit=10&category=2&search=salad&sortBy=judul:asc

Success Response

{
  "status": "success",
  "recipes": [
    {
      "id": 1,
      "judul": "Es Doger",
      "imageUrl": "https://images.pexels.com/photos/444444/pexels-photo-444444.jpeg",
      "deskripsi": "Minuman segar khas Bandung dengan campuran es serut dan aneka isian"
    },
    // ... more Recipes
  ],
  "currentPage": 1,
  "totalPages": 5,
  "totalRecipes": 50
}

Other Endpoints

The API also includes endpoints for user management and authentication:

Authentication

Most endpoints require authentication. Use the /api/auth endpoints to obtain a token, then include it in the Authorization header of your requests:

Authorization: Bearer YOUR_TOKEN_HERE