The Trivia API Questions API

The Questions API from The Trivia API — 6 operation(s) for questions.

GitHub OpenAPI

Operations 6

GET /question/{id} Get a question by id #
POST /question/{id}/report Report a question #
POST /question/{id}/validate Validate an answer for a text_input question #
GET /questions Get a random set of questions #
GET /questions/count Count the questions available for a set of filters #
POST /questions/search Search for questions #

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/the-trivia-api-com:the-trivia-api-com-questions-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

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. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

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

OpenAPI Specification

the-trivia-api-com-questions-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Trivia Questions API
  version: 1.0.0
  description: '# Introduction #


    The Trivia API is a REST API used to request multiple choice trivia questions. No API key is required to request questions, but an API key can be used to gain access to further functionality, such as searching, quizzes, and sessions.


    An API key is also required if you would like to use data from the API commercially.'
servers:
- url: https://the-trivia-api.com/v2
tags:
- name: Questions
paths:
  /question/{id}:
    get:
      operationId: getQuestionById
      summary: Get a question by id
      description: Get a question by its id
      security:
      - ApiKeyAuth: []
      - {}
      tags:
      - Questions
      parameters:
      - in: path
        name: id
        schema:
          type: string
        description: The id of the question to return
        example: 5f9f1b9b0e1b9c0017a5f1a5
      - $ref: '#/components/parameters/languageQueryParam'
      - in: query
        name: showAnswer
        schema:
          type: boolean
          default: true
        description: 'For text_input questions, whether to include the correct answer and accepted answers in the response. Defaults to true.

          '
      responses:
        '200':
          description: A question
          content:
            application/json:
              schema:
                anyOf:
                - $ref: '#/components/schemas/TextChoiceQuestion'
                - $ref: '#/components/schemas/ImageChoiceQuestion'
                - $ref: '#/components/schemas/TextInputQuestion'
        '401':
          description: No valid API key was sent, but the request needs one because it uses `language`. Send your key in the `X-API-Key` header.
        '404':
          description: No question found with the given id
  /question/{id}/report:
    post:
      operationId: reportQuestion
      summary: Report a question
      description: Report a question as being incorrect or inappropriate
      tags:
      - Questions
      parameters:
      - in: path
        name: id
        schema:
          type: string
        description: The id of the question to report
        example: 5f9f1b9b0e1b9c0017a5f1a5
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportQuestionBody'
  /question/{id}/validate:
    post:
      operationId: validateQuestionAnswer
      summary: Validate an answer for a text_input question
      description: (Require a complete subscription) Validates a user's free-form text answer against a text_input question. First checks against cached accepted answers, then uses LLM validation if no cached match is found.
      security:
      - ApiKeyAuth: []
      tags:
      - Questions
      parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
        description: The id of the text_input question
        example: 5f9f1b9b0e1b9c0017a5f1a5
      - in: query
        name: language
        schema:
          type: string
          default: en
        description: The language code for the question/answer (ISO 639-1)
        example: en
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - answer
              properties:
                answer:
                  type: string
                  description: The user's answer to validate
                  example: Paris
      responses:
        '200':
          description: Validation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  isCorrect:
                    type: boolean
                    description: Whether the answer is correct
                  correctAnswer:
                    type: string
                    description: The correct answer
                  reason:
                    type: string
                    description: The reason for the validation result (from cache or LLM)
                  source:
                    type: string
                    enum:
                    - cache
                    - llm
                    description: 'Where the validation result came from: a cached answer, or the LLM'
        '400':
          description: Invalid request (missing answer, invalid language, or question is not text_input type)
        '401':
          description: No valid API key was sent. Send your key in the `X-API-Key` header.
        '404':
          description: No question found with the given id
  /questions:
    get:
      operationId: getRandomQuestions
      summary: Get a random set of questions
      description: 'Get a random set of questions. Any combination of query parameters can be used, or you can omit all of them.


        Pass an API Key in order to gain access to features that are behind a subscription, e.g.

        - More than 50 questions per request

        - High resolution images

        - Bypass the rate limiter'
      security:
      - ApiKeyAuth: []
      - {}
      tags:
      - Questions
      parameters:
      - $ref: '#/components/parameters/limitQueryParam'
      - $ref: '#/components/parameters/categoriesQueryParam'
      - $ref: '#/components/parameters/difficultiesQueryParam'
      - $ref: '#/components/parameters/regionQueryParam'
      - $ref: '#/components/parameters/tagsQueryParam'
      - $ref: '#/components/parameters/typesQueryParam'
      - $ref: '#/components/parameters/sessionQueryParam'
      - $ref: '#/components/parameters/previewQueryParam'
      - $ref: '#/components/parameters/languageQueryParam'
      - $ref: '#/components/parameters/queryQueryParam'
      - $ref: '#/components/parameters/contentFilterQueryParam'
      responses:
        '200':
          description: A list of questions
          content:
            application/json:
              schema:
                type: array
                items:
                  anyOf:
                  - $ref: '#/components/schemas/TextChoiceQuestion'
                  - $ref: '#/components/schemas/ImageChoiceQuestion'
                  - $ref: '#/components/schemas/TextInputQuestion'
        '400':
          description: Invalid query parameter, e.g. a `limit` that is not a whole number of at least 1, or an unrecognised category, difficulty or type
        '401':
          description: No valid API key was sent, but the request needs one because it asks for `image_choice` or `text_input` types, a `language`, or a semantic `query`. Send your key in the `X-API-Key` header.
  /questions/count:
    get:
      operationId: getQuestionCount
      summary: Count the questions available for a set of filters
      description: 'Returns the number of approved questions that `GET /questions` draws from when given the same query parameters. The same defaults apply: if `types` is not provided only `text_choice` questions are counted, if `tags` is not provided niche questions are excluded, and if `region` is not provided only questions suitable for every region are counted. `appliedFilters` shows the filters that were actually used.


        No API key or subscription is needed for any parameter: every question type and language can be counted. When an API key is sent, the request counts against the key''s monthly credits like every other API request.


        `limit` is accepted and ignored.


        `session`, `preview=true` and a non-empty `query` are not supported and return a 400. Counting a semantic `query` would need an embedding call, and its matches come from a capped candidate pool (up to 1000), so there is no exact total. To search questions, use `POST /questions/search`.


        Responses can be cached by browsers and CDNs for 60 seconds.'
      security:
      - ApiKeyAuth: []
      - {}
      tags:
      - Questions
      parameters:
      - $ref: '#/components/parameters/categoriesQueryParam'
      - $ref: '#/components/parameters/difficultiesQueryParam'
      - $ref: '#/components/parameters/regionQueryParam'
      - $ref: '#/components/parameters/tagsQueryParam'
      - in: query
        name: types
        schema:
          type: string
          default: text_choice
        description: Comma separated list of the types of questions to count. If not provided, only `text_choice` questions are counted, for parity with `GET /questions`; pass `types` explicitly to count other types (e.g. `text_choice,image_choice,text_input` for every type). No subscription is needed for any type.
        example: image_choice,text_input
      - $ref: '#/components/parameters/languageQueryParam'
      - $ref: '#/components/parameters/contentFilterQueryParam'
      responses:
        '200':
          description: The number of questions available for the given filters
          headers:
            Cache-Control:
              description: Publicly cacheable for 60 seconds
              schema:
                type: string
                example: public, max-age=60, s-maxage=60
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuestionCountResponse'
        '400':
          description: Invalid query parameter, or one of the unsupported `session`, `preview=true` or `query` parameters was used
        '429':
          description: An API key was sent and this request would take it over its monthly credit limit
  /questions/search:
    post:
      operationId: searchQuestions
      summary: Search for questions
      description: (Requires subscription)
      security:
      - ApiKeyAuth: []
      tags:
      - Questions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchQuestionsBody'
      responses:
        '200':
          description: Search results, including a set of questions and information used to get more results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchQuestionsResponse'
        '400':
          description: Invalid request body, e.g. a `perPage` or `pageNumber` that is not a whole number of at least 1
components:
  parameters:
    tagsQueryParam:
      in: query
      name: tags
      schema:
        type: string
      description: Comma separated list of tags to return questions from. If not provided, all tags will be used.
      example: science,film_and_tv
    difficultiesQueryParam:
      in: query
      name: difficulties
      description: Comma separated list of difficulties of questions to return. If not provided, all difficulties will be used.
      schema:
        type: string
        default: easy,medium,hard
      example: medium,hard
    contentFilterQueryParam:
      in: query
      name: contentFilter
      schema:
        type: string
        enum:
        - all
        - family
        default: all
      description: Content filter to apply. When set to \"family\", excludes questions marked as adult content.
    regionQueryParam:
      in: query
      name: region
      schema:
        type: string
      description: 'Some questions are regional, i.e. only reasonable to ask people from a particular set of countries.


        If not provided, all questions will be suitable to ask to people from anywhere in the world. If provided, you could also receive questions that are only suitable to ask to ask to people from the specified region, but not to people from all regions.


        The region should be provided as an ISO 3166-1 alpha-2 country code.'
      example: GB
    queryQueryParam:
      in: query
      name: query
      schema:
        type: string
      description: Available with a Complete subscription, this will return questions that are semantically similar to the query. e.g. "Ancient civilizations" will match questions containing the text "Pyramids", "The Romans", "The bronze age", etc.
      example: ancient%20civilizations
    languageQueryParam:
      in: query
      name: language
      schema:
        type: string
      description: (Requires a Complete subscription) ISO 639-1 code of the language to return questions in. If not provided, questions will be returned in English.
      example: es
    previewQueryParam:
      in: query
      name: preview
      schema:
        type: string
        enum:
        - 'true'
        - 'false'
      description: When used with a session, this will not mark the generated questions as "used", so the same questions could be returned again in a future request. Questions generated in this way need to be manually marked as "used".
      example: true
    sessionQueryParam:
      in: query
      name: session
      schema:
        type: string
      description: The session id to return questions from. If not provided, questions will not come from a session, so could be duplicates of questions received on previous requests.
      example: '1234567890'
    typesQueryParam:
      in: query
      name: types
      schema:
        type: string
        default: text_choice
      description: 'Comma separated list of the types of questions to return. If not provided, only text choice questions will be used.

        A Complete subscription is required to receive image questions.'
      example: text_choice,image_choice
    limitQueryParam:
      in: query
      name: limit
      description: 'The number of questions to return. Must be a whole number of at least 1, otherwise the request returns a 400. A value above the maximum is capped to it: the maximum is 50 without an API key, or the number of questions per request that your subscription allows.'
      schema:
        type: integer
        minimum: 1
        default: 10
      example: 5
    categoriesQueryParam:
      in: query
      name: categories
      description: Comma separated list of categories to return questions from. If not provided, all categories will be used. An unrecognised category returns a 400.
      schema:
        type: string
      example: science,film_and_tv
  schemas:
    SearchQuestionsResponse:
      type: object
      properties:
        questions:
          type: array
          description: The questions that match the search criteria
          items:
            $ref: '#/components/schemas/V2Question'
        totalHits:
          type: number
          description: The total number of questions that match the search criteria
        perPage:
          type: number
          description: The number of questions returned per page
        pageNumber:
          type: number
          description: The page number returned
        totalPages:
          type: number
          description: The total number of pages when the current search criteria is applied. Sending a request with a page number greater than this will return an empty array of questions.
      required:
      - questions
      - totalHits
      - perPage
      - pageNumber
      - totalPages
    V2Question:
      oneOf:
      - $ref: '#/components/schemas/TextChoiceQuestion'
      - $ref: '#/components/schemas/ImageChoiceQuestion'
      - $ref: '#/components/schemas/TextInputQuestion'
    Category:
      type: string
      enum:
      - music
      - sport_and_leisure
      - film_and_tv
      - arts_and_literature
      - history
      - society_and_culture
      - science
      - geography
      - food_and_drink
      - general_knowledge
    ImageChoiceQuestion:
      allOf:
      - $ref: '#/components/schemas/BaseQuestion'
      - type: object
        properties:
          question:
            type: object
            properties:
              text:
                type: string
                description: String formulation of the questions
                example: Which of these photos shows The Eiffel Tower?
            required:
            - text
          correctAnswer:
            type: array
            items:
              $ref: '#/components/schemas/ImageOption'
          incorrectAnswers:
            type: array
            items:
              type: array
              items:
                $ref: '#/components/schemas/ImageOption'
          type:
            type: string
            enum:
            - image_choice
            example: image_choice
        required:
        - question
        - correctAnswer
        - incorrectAnswers
        - type
    ImageOption:
      type: object
      properties:
        url:
          type: string
          description: Full URL of the image
          example: https://example.com/images/12345/an-interesting-image.jpg
        height:
          type: number
          description: Height of the image in pixels
          example: 400
        width:
          type: number
          description: Width of the image in pixels
          example: 300
        size:
          type: number
          description: Size of the image in bytes
          example: 256612
        author:
          type: object
          properties:
            name:
              type: string
              description: The author's name
              example: John Smith
            url:
              type:
              - string
              - 'null'
              description: URL to the author's website or social media profile
              example: https://john-smith.example.com
        source:
          type: object
          properties:
            url:
              type:
              - string
              - 'null'
              description: Where the image is originally credited
              example: https://example.com/some-source-gallery
        description:
          type: string
          description: Description of what the image is showing, can be used as alt text.
          example: A picture of a cat
        license:
          type: object
          properties:
            url:
              type:
              - string
              - 'null'
              description: URL to the license of the image
              example: https://creativecommons.org/licenses/by/4.0/
            name:
              type: string
              description: Name of the license
              example: Creative Commons Attribution 4.0 International
      required:
      - url
      - height
      - width
      - size
      - author
      - source
      - description
      - license
    BaseQuestion:
      type: object
      properties:
        category:
          type: string
          $ref: '#/components/schemas/Category'
        id:
          type: string
          description: Unique identifier for the question
          example: 5f9f1b9b0e1b9c0017a5f1a5
        tags:
          type: array
          description: Secondary categories for the question. More freeform than category (can take any value), and can have multiple tags per question.
          items:
            type: string
          example:
          - france
          - geography
          - capital_cities
          - cities
        difficulty:
          type: string
          enum:
          - easy
          - medium
          - hard
          description: How difficult the question is perceived to be by the moderators of the API.
        regions:
          type: array
          items:
            type: string
          description: 'If the question is regional (i.e. only reasonable to ask people from a particular set of countries), then the ISO 3166-1 alpha-2 country codes for those countries are specified here.


            For most questions, this will be an empty array, meaning that the question is suitable to ask to people from anywhere in the world.'
        isNiche:
          type: boolean
          description: Will be true if the question is a niche question, i.e. if it is considered too difficult to return unless the tag is specifically requested.
      required:
      - category
      - id
      - tags
      - isNiche
      - difficulty
    TextInputQuestion:
      allOf:
      - $ref: '#/components/schemas/BaseQuestion'
      - type: object
        properties:
          question:
            type: object
            properties:
              text:
                type: string
                description: String formulation of the question
                example: What is the chemical symbol for gold?
            required:
            - text
          correctAnswer:
            type: string
            description: The "gold standard" correct answer
            example: Au
          acceptedAnswers:
            type: array
            description: Cached list of accepted answer variations (only returned if showAnswer=true)
            example:
            - Au
            - AU
            - au
            items:
              type: string
          correctAnswerRatio:
            type: object
            description: How often this question has been answered correctly vs incorrectly
            properties:
              correct:
                type: number
                description: Number of correct answers recorded
              incorrect:
                type: number
                description: Number of incorrect answers recorded
            required:
            - correct
            - incorrect
          hint:
            type: string
            description: 'A one-sentence clue to show before the player answers, if they ask for one. It points towards the answer without giving it away. Optional: not every question has one yet, and it is currently only returned for English requests.'
            example: The symbol comes from the metal's Latin name, not its English one.
          explanation:
            type: string
            description: 'One or two sentences to show after the player answers, saying why the correct answer is right or adding a related fact. It names the correct answer, so it is not returned when showAnswer=false. Optional: not every question has one yet, and it is currently only returned for English requests.'
            example: Gold's symbol Au comes from its Latin name, aurum, meaning 'shining dawn'.
          type:
            type: string
            enum:
            - text_input
            example: text_input
        required:
        - question
        - correctAnswer
        - correctAnswerRatio
        - type
    ReportQuestionBody:
      type: object
      properties:
        reason:
          description: The reason that this question is bad
          type: string
          example: The correct answer is listed as 'France' but it should be 'Spain'
    QuestionCountResponse:
      type: object
      properties:
        count:
          type: integer
          description: The number of approved questions that `GET /questions` draws from for the applied filters
          example: 1234
        appliedFilters:
          type: object
          description: The filters used to calculate `count`. `categories`, `difficulties` and `types` are always present and include any defaults that were applied (`types` defaults to `text_choice`). The other filters are only present if they were provided in the request.
          properties:
            categories:
              type: array
              items:
                $ref: '#/components/schemas/Category'
            difficulties:
              type: array
              items:
                type: string
                enum:
                - easy
                - medium
                - hard
            types:
              type: array
              items:
                type: string
                enum:
                - text_choice
                - image_choice
                - text_input
              example:
              - text_choice
            tags:
              type: array
              items:
                type: string
              example:
              - rome
            region:
              type: string
              example: GB
            language:
              type: string
              example: en
            contentFilter:
              type: string
              enum:
              - all
              - family
          required:
          - categories
          - difficulties
          - types
      required:
      - count
      - appliedFilters
    TextChoiceQuestion:
      allOf:
      - $ref: '#/components/schemas/BaseQuestion'
      - type: object
        properties:
          question:
            type: object
            properties:
              text:
                type: string
                description: String formulation of the questions
                example: What is the capital of France?
            required:
            - text
          correctAnswer:
            type: string
            description: The correct answer
            example: Paris
          incorrectAnswers:
            type: array
            description: Array of incorrect answers
            example:
            - London
            - Berlin
            - Brussels
            items:
              type: string
              description: An incorrect answer
          hint:
            type: string
            description: 'A one-sentence clue to show before the player answers, if they ask for one. It points towards the answer without giving it away. Optional: not every question has one yet, and it is currently only returned for English requests.'
            example: Think of a city famous for a tower built for the 1889 World's Fair.
          explanation:
            type: string
            description: 'One or two sentences to show after the player answers, saying why the correct answer is right or adding a related fact. It names the correct answer, so do not show it before the player has answered. Optional: not every question has one yet, and it is currently only returned for English requests.'
            example: Paris is France's capital and largest city; London, Berlin and Brussels are the capitals of the UK, Germany and Belgium.
          type:
            type: string
            enum:
            - text_choice
            example: text_choice
        required:
        - question
        - correctAnswer
        - incorrectAnswers
        - type
    SearchQuestionsBody:
      type: object
      properties:
        categories:
          description: The categories to search for
          type: array
          items:
            $ref: '#/components/schemas/Category'
        order:
          description: The order to sort the questions by, new questions are those that have been submitted most recently.
          type: string
          enum:
          - new
          - old
        pageNumber:
          description: The page number to return. Must be a whole number of at least 1. Defaults to 1.
          type: integer
          minimum: 1
        perPage:
          description: The number of questions to return per page. Must be a whole number of at least 1. A value above the number of questions per request that your subscription allows is capped to it, and the response's `perPage` shows the value used. Defaults to 10.
          type: integer
          minimum: 1
        freetext:
          description: Freetext value to search for withing question text
          type: string
        ids:
          description: The ids of the questions to search for
          type: array
          items:
            type: string
        tags:
          description: The tags to search for
          type: array
          items:
            type: string
        difficulties:
          description: The difficulty to search for
          type: array
          items:
            type: string
            enum:
            - easy
            - medium
            - hard
        types:
          description: The types to search for
          type: array
          items:
            type: string
        region:
          description: The region to search for
          type: string
        contentFilter:
          description: Content filter to apply. When set to "family", excludes questions marked as adult content.
          type: string
          enum:
          - all
          - family
        mode:
          description: Search mode. 'text' will use keyword search, and will match questions that contain the exact search query in the question text. 'semantic' is only available with a Complete subscription, and will use semantic search to match questions that are semantically similar to the search query, e.g. "Ancient civilizations" will match questions containing the text "Pyramids", "The Romans", "The bronze age", etc. Defaults to text.
          type: string
          enum:
          - text
          - semantic
        query:
          description: Query used by the selected search mode.
          type: string
        language:
          description: (Requires a Complete subscription) ISO 639-1 code of the language to return questions in. If not provided, questions will be returned in English.
          type: string
          example: es
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key