The Open Trivia Database provides a completely free JSON API for use in programming projects. Use of this API does not require a API Key, just generate the URL below use it in your own application to retrieve trivia questions.
All data provided by the API is available under the Creative Commons Attribution-ShareAlike 4.0 International License.
To get started using the Open Trivia DB API, use this URL: For more settings or help using the API, read along below. Alternatively, you can use the helper form to craft your specific query.
Session Tokens are unique keys that will help keep track of the questions the API has already retrieved. By appending a Session Token to a API Call, the API will never give you the same
question twice. Over the lifespan of a Session Token, there will eventually reach a point where you have exhausted all the possible questions in the database. At this point, the API will
respond with the approperate "Response Code". From here, you can either "Reset" the Token, which will wipe all past memory, or you can ask for a new one.
Session Tokens will be deleted after 6 hours of inactivity.
Using a Session Token:
Retrieve a Session Token:
Reset a Session Token:
The API appends a "Response Code" to each API Call to help tell developers what the API is doing.
The Open Trivia DB may contain questions which contain Unicode or Special Characters. For this reason, the API returns results in a encoded format. You can specify the desired encoding format using the examples below. If the encode type is not present in the URL, it will follow the default encoding.
API Call with Encode Type (urlLegacy, url3986, base64):
Example Sentence (Non Encoded): "Don't forget that π = 3.14 & doesn't equal 3."There are some functions in the API which can be useful to developers.
Category Lookup: Returns the entire list of categories and ids in the database.
Category Question Count Lookup: Returns the number of questions in the database, in a specific category.
Global Question Count Lookup: Returns the number of ALL questions in the database. Total, Pending, Verified, and Rejected.