Blog

Got a source for that? Now we do

Will Fry3 min read

Every so often a player is sure the answer to a question is wrong. Sometimes they're right, and sometimes they're not, but until now there was no easy way for them (or you) to check.

Text questions from The Trivia API now come with sources: links to pages that back up the correct answer.

What's new

Text questions (text_choice and text_input) have a new optional sources field:

  • urls is a list of links that support the answer. Usually there's one.
  • checkedAt is when we last checked the sources, as an ISO 8601 date and time.

Each source has been checked to contain a quote that states the fact. Here's a question with one (trimmed to the fields that matter here):

{
  "id": "622a1c3a7cc59eab6f95104d",
  "question": { "text": "What is dry ice made of?" },
  "correctAnswer": "Carbon dioxide",
  "sources": {
    "urls": ["https://www.britannica.com/science/dry-ice"],
    "checkedAt": "2026-11-18T22:28:34.726Z"
  }
}

Sources are returned on every question response, on every plan, so there's no parameter to add. Image questions (image_choice) don't have them.

Questions without a source

Around 80% of text questions have at least one source. The rest come back with an empty urls: we didn't find a source we'd stand behind. That includes facts that are contested.

{
  "id": "63b0586b4799123c67712f23",
  "question": { "text": "Which is the longest river within India's borders?" },
  "correctAnswer": "Ganges",
  "sources": {
    "urls": [],
    "checkedAt": "2026-11-19T16:24:38.182Z"
  }
}

sources is always there on text questions, so there are only two cases to handle: an empty urls and a urls with links in it. Only the second has anything to show.

Getting only questions with sources

If you want every question in your quiz to have a source, add hasSources=true:

curl "https://the-trivia-api.com/v2/questions?limit=10&hasSources=true"

It works on /v2/questions, /v2/questions/count and /v2/session/{id}/preview-questions, and as a hasSources field in the body of POST /v2/questions/search. Leaving it out, or setting it to false, applies no filter. Any other value gets a 400.

With the SDK (version 1.3.0 or later), hasSources is an option on getRandomQuestions, and the question types include sources:

import { getRandomQuestions } from "@trivia-api/sdk";
 
const [question] = await getRandomQuestions({ limit: 1, hasSources: true });
 
// Once the player has answered
const url = "sources" in question ? question.sources?.urls[0] : undefined;
 
if (url) {
  const link = document.createElement("a");
  link.href = url;
  link.textContent = "Learn more";
  link.target = "_blank";
  link.rel = "noopener";
  document.querySelector("#result")?.append(link);
}

Some links end in a text fragment, the part after #:~:text=:

https://en.wikipedia.org/w/index.php?title=Avengers%3A_Endgame&oldid=1386446912#:~:text=Chris%20Evans%20as%20Steve%20Rogers%20%2F%20Captain%20America

In browsers that support text fragments, the page opens scrolled to that passage, with it highlighted. In other browsers the page just opens as normal. Use the URL as it is: don't strip the fragment or re-encode it, or the highlight stops working.

Wikipedia links are permanent links (that's the oldid), so they point at the exact revision we checked, even if the article has changed since.

Using them

A few ideas:

  • A "Learn more" link after the player answers. This goes well with the explanation field from the hints and explanations post: show the explanation, then the link for anyone who wants to read further.
  • A source next to a disputed answer. If you let players flag questions, a link to the source gives them something to check before they do.
  • Only serving questions you can back up. With hasSources=true, every question you show has an answer someone can check.

Whichever you do, keep sources hidden until the player has answered. A text fragment can contain the answer, and sources is still returned when you request a text_input question with showAnswer=false, so it's up to you to leave it out of the UI until the answer is revealed.

The API reference has the full details on sources and hasSources.

Build with The Trivia API

The docs cover every endpoint, parameter and response. No API key is needed to get started.

License

Information about the Creative Commons license for The Trivia API.

The API and all data returned from it are licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Creative Commons License

This means that the API and the questions it returns are free for noncommercial use. If you have somewhere suitable in your app, then please credit the API somewhere discreet — we love having our hard work shared!

If you would like to use the API commercially, or would like enhanced functionality, this service is offered through a paid subscription.

Sign in

Sign in to access your API key and manage your account.

or continue with email