Make tests and assessments automatically with Quizgecko Quiz API

Quizgecko is an online quiz and assessment maker that uses AI to generate questions and assessments automatically from any text or document. It has a developer API that allows you to integrate quiz generation into your own applications.

In this tutorial, we'll walk through how to use Quizgecko's API to programmatically create quizzes in Python using the requests library.

Getting Started

First, you'll need to sign up for a free Quizgecko account at quizgecko.com. Once signed up, go to the API page and generate an API key.

Next, install the requests library:

pip install requests

Import requests:

import requests

Define your API key as a variable:

api_key = 'YOUR_API_KEY'

Generating Quizzes

To generate a quiz, make a POST request to the /questions endpoint, passing your API key in the headers and the text in the request body:

url = 'https://quizgecko.com/api/v1/questions'

text = "Isaac Newton was an English mathematician, physicist, astronomer, theologian, and author who is widely recognised as one of the greatest mathematicians and most influential scientists of all time."

headers = {
  'Authorization': f'Bearer {api_key}' 
}

data = {
  'text': text
}

response = requests.post(url, headers=headers, json=data)

This will asynchronously generate a quiz with multiple choice questions based on the provided text.

To poll until the quiz is ready, make GET requests to the /quiz/{id} endpoint, passing the id returned in the response:

quiz_id = response.json()['quiz']['id']

url = f'https://quizgecko.com/api/v1/quiz/{quiz_id}'

while True:
  response = requests.get(url, headers=headers)
  if response.json()['status'] == 'completed':
    break
  time.sleep(5)

print(response.json()['questions'])

Additional Features

The Quizgecko API allows you to:

  • Generate quizzes from URLs and files by passing the link or file

  • Get quiz results and analytics

  • Create quizzes in multiple languages

  • Much more

See the full docs for more details on using the API.

Conclusion

With the Quizgecko API, you can easily integrate AI quiz and assessment generation into your Python applications and tools. Sign up for a free account, grab an API key, and start automating your quiz building today!