api-ninjas-com Trivia API

The Trivia API provides random trivia questions and answers from a large database. Topics include science, literature, philosophy, and more.

Operations 2

GET /v1/trivia Get Trivia Questions #
GET /v1/triviaoftheday Get Trivia of the Day #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/api-ninjas-com:api-ninjas-com-trivia-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

api-ninjas-com-trivia-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Ninjas Trivia API
  description: 'Combined OpenAPI specification for every API Ninjas endpoint. Requests go to https://api.api-ninjas.com with an `X-Api-Key` header; get a free key at https://api-ninjas.com/register. Human-readable docs: https://api-ninjas.com/api. Index for LLMs: https://api-ninjas.com/llms.txt.'
  version: 1.0.0
  contact:
    name: API Ninjas
    url: https://api-ninjas.com
  license:
    name: Proprietary
servers:
- url: https://api.api-ninjas.com
  description: API Ninjas Production
security:
- ApiKeyAuth: []
tags:
- name: Trivia
  description: The Trivia API provides random trivia questions and answers from a large database. Topics include science, literature, philosophy, and more.
paths:
  /v1/trivia:
    get:
      summary: Get Trivia Questions
      description: Returns a random trivia question and answer.
      operationId: getTrivia
      parameters:
      - $ref: '#/components/parameters/TriviaOpenapi_category'
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/TriviaOpenapi_safe'
      responses:
        '200':
          description: A list of trivia questions and answers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaOpenapi_Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaOpenapi_Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaOpenapi_Error'
      security:
      - ApiKeyAuth: []
      tags:
      - Trivia
  /v1/triviaoftheday:
    get:
      summary: Get Trivia of the Day
      description: Returns a single trivia question and answer for the current day. The same question is returned for all requests on the same day, and changes each day. No filtering parameters are available for this endpoint to ensure everyone sees the same trivia of the day. Questions flagged as explicit are always excluded here.
      operationId: getTriviaOfTheDay
      responses:
        '200':
          description: A single trivia question and answer for the current day.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaOpenapi_Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaOpenapi_Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriviaOpenapi_Error'
      security:
      - ApiKeyAuth: []
      tags:
      - Trivia
components:
  parameters:
    TriviaOpenapi_safe:
      name: safe
      in: query
      description: Premium subscribers only. Set safe=true to exclude questions flagged as sexually explicit, crude, or containing profanity or slurs. Defaults to false, so results are unfiltered unless you opt in. Filtering is best-effort and not a guarantee. Any value other than true/false returns an error, as does using this parameter on a free account.
      required: false
      schema:
        type: boolean
        default: false
    TriviaOpenapi_category:
      name: category
      in: query
      description: 'Category of trivia. The possible values are: artliterature, language, sciencenature, general, fooddrink, peopleplaces, geography, historyholidays, entertainment, toysgames, music, mathematics, religionmythology, sportsleisure.'
      required: false
      schema:
        type: string
        enum:
        - artliterature
        - language
        - sciencenature
        - general
        - fooddrink
        - peopleplaces
        - geography
        - historyholidays
        - entertainment
        - toysgames
        - music
        - mathematics
        - religionmythology
        - sportsleisure
    limit:
      name: limit
      in: query
      description: How many results to return. Must be between 1 and 30. Default is 1.
      required: false
      schema:
        type: integer
        default: 1
        minimum: 1
        maximum: 30
  schemas:
    TriviaOpenapi_Error:
      type: object
      properties:
        message:
          type: string
        status:
          type: integer
    TriviaResponse:
      type: array
      items:
        type: object
        properties:
          category:
            type: string
            example: music
          question:
            type: string
            example: Who Was The Midnight Rider
          answer:
            type: string
            example: Paul Davidson
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
externalDocs:
  description: API Ninjas documentation
  url: https://api-ninjas.com/api