Question Generator API

Integrate our question generator API into your application. Only successful generations are counted. Create an account and get started now.

Documentation

Credits

$10

Roughly 100 API requests.

Each API request generates 5-10 questions. Only successful generations are counted.

Number of questions


1,000


Documentation

Integrate our question generator API into your application. Each API request generates 5-10 questions. Only successful generations are counted.

Getting a key

Subscribe to the Question Generator API and you will see your api key in this page.

API Endpoint

https://server.opexams.com

Authentication

To use the Question Generator API, you need to authenticate your requests. You can do this by sending your API key in the api-key header.

"api-key": "YOUR-API-KEY"

POST /questions-generator

Generate questions by providing a body as JSON with the following parameters:

Name

Value

Required

Description

type

string

true

The type of the question to generate. Can be `contextBased` or `topicBased`

context

string

if type is `contextBased`

The text to generate questions from

topic

string

if type is `topicBased`

The topic of the question to generate

questionType

string

true

The type of the question to generate. Can be `MCQ`, `TF` or `open`

difficulty

string

false

The difficulty of the question to generate. Can be `easy`, `medium` or `hard`

requestId

string

true

The id of the request. can by used to track the request

Test request

You can test the API by setting a `request-type` header to `test` and the request will not be counted in your usage.

Response

Response example for a successful request:

{ "data": [ { "id": "pDgnjdMzOt9", "question": "Who founded University College London?", "answer": "Jeremy Bentham", "options": ["Charles Darwin", "Jeremy Bentham", "Isaac Newton", "William Shakespeare", "Albert Einstein"] }, { "id": "GZG49mXC3Jy", "question": "In what year was UCL established?", "answer": "1826", "options": ["1826", "1939", "1865", "1790", "1901"] }, { "id": "r0SclR9bOYf", "question": "What is the motto of UCL?", "answer": "Scientia et Labore", "options": ["Lux et Veritas", "In Hoc Signo Vinces", "Sapere Aude", "Scientia et Labore", "Deo Juvante"] }, { "id": "Tjadx7EYWKL", "question": "Which famous philosopher taught at UCL?", "answer": "Karl Marx", "options": ["Socrates", "Aristotle", "Plato", "Friedrich Nietzsche", "Karl Marx"] }, { "id": "Z9TxfwpFzvN", "question": "Who is the current Provost of UCL?", "answer": "David Price", "options": ["Richard Horton", "David Price", "Jeremy Farrar", "Patrick Vallance", "Mark Walport"] }, { "id": "q-DdK8od76m", "question": "Which UCL constituent college specializes in medical sciences?", "answer": "UCL Faculty of Medical Sciences", "options": ["UCL School of Slavonic and East European Studies", "UCL Institute of Education", "UCL Faculty of Laws", "UCL Faculty of Engineering Science", "UCL Faculty of Medical Sciences"] }, { "id": "0eUI1bSZpaE", "question": "What is the name of UCL's student union?", "answer": "UCLSU", "options": ["UCL Union", "UCLU", "UCLSU", "UCL Student Life", "UCL Campus Life"] }, { "id": "IXZvKXJMZoW", "question": "What is the name of UCL's main library?", "answer": "The UCL Main Library", "options": ["Senate House Library", "British Library", "UCL Library Services", "The Maughan Library", "The UCL Main Library"] }, { "id": "5qLp-pHWWnn", "question": "Which famous writer studied at UCL?", "answer": "Virginia Woolf", "options": ["Virginia Woolf", "Charles Dickens", "William Shakespeare", "Jane Austen", "Oscar Wilde"] }, { "id": "Hj2nDaEw2rW", "question": "Which famous museum is located on UCL's campus?", "answer": "The Petrie Museum of Egyptian Archaeology", "options": ["British Museum", "Science Museum", "Natural History Museum", "Victoria and Albert Museum", "The Petrie Museum of Egyptian Archaeology"] } ] }

GET /questions-generator/usage

Get your usage by sending a GET request to this endpoint.

Response

Response example for a successful request:

{ "usedCredits": 150, "totalCredits": 1000, "creditsLeft": 850 }

Error codes

The Question Generator API uses the following error codes:

Code

Description

400

Bad Request — Your request is invalid.

401

Unauthorized — Your API key is invalid.