{
  "openapi": "3.1.0",
  "info": {
    "title": "Riddles API",
    "version": "1.0.0",
    "description": "176 curated riddles with answers in 8 categories and three difficulties, built for quiz and game UIs.\n\n176 curated riddles with answers across 8 categories — classic, logic, wordplay, math, animals, nature, objects and food — each tagged easy, medium or hard. Pull random riddles (up to 20 at once), full-text search, filter by category or difficulty, page through everything, or fetch one by id. Built for quiz and game UIs: pass include_answer=false to serve questions without spoiling the solution, then reveal it via the by-id endpoint. Every riddle is family-friendly and every answer has been checked for correctness.",
    "contact": {
      "name": "Data and APIs",
      "url": "https://dataandapis.com/contact"
    },
    "termsOfService": "https://dataandapis.com/terms-of-service",
    "license": {
      "name": "Data and APIs Terms of Service",
      "url": "https://dataandapis.com/terms-of-service"
    },
    "x-logo": {
      "url": "https://dataandapis.com/images/riddles.webp"
    }
  },
  "externalDocs": {
    "description": "Documentation, live tester and pricing",
    "url": "https://dataandapis.com/apis/riddles"
  },
  "servers": [
    {
      "url": "https://api-riddles.dataandapis.com"
    }
  ],
  "tags": [
    {
      "name": "Entertainment",
      "description": "Riddles API belongs to the Entertainment category of the Data and APIs catalog."
    }
  ],
  "paths": {
    "/v1/riddles/{id}": {
      "get": {
        "operationId": "getRiddle",
        "summary": "Get Riddle",
        "description": "Get Riddle endpoint of the Riddles API. Costs 1 token per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/riddles/get-riddle"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "1"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true,
                  "id": 154,
                  "category": "objects",
                  "difficulty": "medium",
                  "question": "What has cities but no houses, forests but no trees, and rivers without water?",
                  "answer": "A map."
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/riddles/categories": {
      "get": {
        "operationId": "listCategories",
        "summary": "List Categories",
        "description": "List Categories endpoint of the Riddles API. Costs 1 token per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/riddles/list-categories"
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true,
                  "count": 8,
                  "total_riddles": 176,
                  "difficulties": {
                    "easy": 70,
                    "medium": 76,
                    "hard": 30
                  },
                  "categories": [
                    {
                      "name": "animals",
                      "riddles": 19
                    },
                    {
                      "name": "classic",
                      "riddles": 36
                    },
                    {
                      "name": "food",
                      "riddles": 14
                    },
                    {
                      "name": "logic",
                      "riddles": 30
                    },
                    {
                      "name": "math",
                      "riddles": 20
                    },
                    {
                      "name": "nature",
                      "riddles": 16
                    },
                    {
                      "name": "objects",
                      "riddles": 15
                    },
                    {
                      "name": "wordplay",
                      "riddles": 26
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/riddles": {
      "get": {
        "operationId": "listRiddles",
        "summary": "List Riddles",
        "description": "List Riddles endpoint of the Riddles API. Costs 1 token per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/riddles/list-riddles"
        },
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "logic"
          },
          {
            "name": "difficulty",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "hard"
          },
          {
            "name": "include_answer",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "false"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "20"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "map"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true,
                  "total": 3,
                  "page": 1,
                  "limit": 20,
                  "count": 3,
                  "results": [
                    {
                      "id": 16,
                      "category": "logic",
                      "difficulty": "hard",
                      "question": "A girl has as many brothers as sisters, but each brother has only half as many brothers as sisters. How many brothers and sisters are in the family?"
                    },
                    {
                      "id": 17,
                      "category": "logic",
                      "difficulty": "hard",
                      "question": "Two fathers and two sons go fishing and each catches one fish, yet they bring home only three fish. How?"
                    },
                    {
                      "id": 20,
                      "category": "logic",
                      "difficulty": "hard",
                      "question": "Forward I am heavy, but backward I am not. What am I?"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/riddles/random": {
      "get": {
        "operationId": "randomRiddle",
        "summary": "Random Riddle",
        "description": "Random Riddle endpoint of the Riddles API. Costs 1 token per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/riddles/random-riddle"
        },
        "parameters": [
          {
            "name": "amount",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "logic"
          },
          {
            "name": "difficulty",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "easy"
          },
          {
            "name": "include_answer",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "false"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "ok": true,
                  "count": 1,
                  "results": [
                    {
                      "id": 165,
                      "category": "food",
                      "difficulty": "easy",
                      "question": "What kind of cup can't hold water?",
                      "answer": "A cupcake."
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Create a free key at https://dataandapis.com/sign-up. 500 tokens a month on the Free plan; this API costs 1 token per call."
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}