Skip to main content

Developer API ยท v1

QuizByt API documentation

4,489 self-marking quizzes for Class 1 to 10, IGCSE and O Level, in Mathematics, Science, English, Computer Science, Physics, Chemistry and Biology. Read them as JSON, or drop in the ready-made player. One key, one header, plain GET requests.

Get a key, three steps Embed a quiz instead

Authentication

Every request carries your key in a header. Keys start with qb_live_ and are made on registration; you reveal them on the dashboard with a code sent to your email.

curl -H "Authorization: Bearer qb_live_YOUR_KEY" \
  -H "Referer: https://yoursite.example/" \
  https://app.quizbyt.com/api/v1/me

X-Api-Key: qb_live_โ€ฆ works too. The key goes in a header only, never in the address: addresses end up in logs, histories and referers.

Your key works only for your site

Every key is bound to the site address given at registration, and all of its subdomains. A request is accepted when any of these is true:

  • It carries an Origin or Referer header naming that host or a subdomain of it. A browser sets these by itself; from your server, add one line: Referer: https://yoursite.example/.
  • It comes from the server your site resolves to: the client address is one of the host's A or AAAA records, or its reverse name ends in the host.

Anything else is a 403 wrong_domain naming the bound domain. The binding cannot be changed on the dashboard; if your site moves, write to info@quizbyt.com. /me shows the bound domain and how the current request was seen.

{"app":{"name":"MathsBuddy","site_url":"https://mathsbuddy.example","platform":"app","use_kind":"both"},"tier":"beta","level":"beta","domain":{"bound_to":"mathsbuddy.example","subdomains":true,"seen_as":"mathsbuddy.example"},"base_url":"https://app.quizbyt.com/api/v1/beta","limits":{"per_minute":60,"per_day":2000},"usage":{"today":3,"month":41},"library":{"quizzes":4489},"quota":{"per_class_subject":3,"period":"ever","resets_on":null,"embeds_per_subject":5,"used":[{"class":"Class 5","subject":"Mathematics","used":2,"limit":3,"left":1}]}}

Beta, prod and prestige

Every plan sees the same library and the same JSON. What differs is how many new quizzes you may take per class and subject: a quiz you have fetched is free to fetch again, so cache by id and the counter only moves when you ask for something new.

Beta ยท free

Build and show it

  • 3 quizzes per class and subject, ever. /quizzes/next always hands you one you have not had.
  • 5 per subject on the embed picker.
  • Base address /api/v1/beta/. A beta key sent to /api/v1/ gets a 307 to the beta address, so a wrong base URL still works and tells you.
  • At the limit: 429 quota_beta, and one email for that class and subject.

Prod ยท USD 99 a year, yearly only

The full library

  • Every quiz: 4,489 and counting, at /api/v1/.
  • 20 new quizzes per class and subject a month. Resets on the 1st.
  • 30 per subject on the embed picker.
  • At the limit: 429 quota_month with the class, the subject, the counts and the reset date; one email per class and subject a month. Lists, classes and subjects never count.
  • Free for a school once it has 100+ registered students: no payment, checked live against the count.

Prestige ยท USD 199 a year

More room every month

  • Everything in prod.
  • 50 new quizzes per class and subject a month.
  • 40 per subject on the embed picker.
  • We help you implement it: a person from QuizByt works with you on the embed or the API, from the first day.
  • Priority answers from support.
  • Free for a school once it has 500+ registered students.

Both paid plans are yearly only; there is no monthly developer plan. Prices are shown in your currency from your location; the plan page has the payment buttons.

Choose a plan on your dashboard

List quizzes

GET /api/v1/quizzes with any of these filters: class (class-5, o-level), subject (mathematics, english, โ€ฆ), topic (a slug such as decimals), level (easy, medium, hard, skilled), q (a word in the title or topic), page and per_page (up to 50).

curl -H "Authorization: Bearer qb_live_YOUR_KEY" \
  -H "Referer: https://yoursite.example/" \
  "https://app.quizbyt.com/api/v1/quizzes?class=class-5&subject=mathematics&per_page=2"
{
  "quizzes": [
    {
      "id": "c5_math_decimals_e1",
      "title": "Decimals: Easy 1",
      "topic": "Decimals",
      "class": {"id": "class-5", "name": "Class 5"},
      "subject": {"id": "mathematics", "name": "Mathematics"},
      "level": "easy",
      "questions": 5,
      "url": "https://app.quizbyt.com/api/v1/quizzes/c5_math_decimals_e1",
      "embed_url": "https://app.quizbyt.com/embed/quiz/c5_math_decimals_e1",
      "page_url": "https://app.quizbyt.com/class-5/mathematics/decimals"
    }
  ],
  "page": 1, "per_page": 2, "total": 48, "pages": 24
}

One quiz, with its questions

GET /api/v1/quizzes/{id} returns the questions, the options, the right answer and the explanation where the quiz has one. Multiple-choice questions only; a quiz's other question types, if any, are left out and questions counts what you get.

curl -H "Authorization: Bearer qb_live_YOUR_KEY" \
  -H "Referer: https://yoursite.example/" \
  https://app.quizbyt.com/api/v1/quizzes/c5_math_decimals_e1
{
  "id": "c5_math_decimals_e1",
  "title": "Decimals: Easy 1",
  "questions": [
    {
      "number": 1,
      "text": "What is 0.5 as a fraction?",
      "options": [
        {"id": "a", "text": "1/2"}, {"id": "b", "text": "1/4"},
        {"id": "c", "text": "1/5"}, {"id": "d", "text": "1/10"}
      ],
      "answer": "a",
      "explanation": "0.5 means five tenths, and five tenths simplifies to one half."
    }
  ],
  "attribution": {"text": "Quiz by QuizByt", "url": "https://app.quizbyt.com/class-5/mathematics/decimals"}
}

When you render questions yourself, show attribution.text linked to attribution.url near the quiz. That is rule one.

Every fetched quiz carries a quota block: the class, the subject, used, limit, left, and counted (false when you had it already).

The next quiz you have not had

GET /api/v1/quizzes/next?class=class-5&subject=mathematics returns one quiz from that class and subject that this key has never fetched, with the same shape as above. Call it again and you get the next one; it never repeats. When the counter for that class and subject is full it answers 429; when you have walked the whole class and subject it answers 404 library_done, and everything you had stays free to fetch by id.

curl -H "Authorization: Bearer qb_live_YOUR_KEY" \
  -H "Referer: https://yoursite.example/" \
  "https://app.quizbyt.com/api/v1/quizzes/next?class=class-5&subject=mathematics"

The ready-made player

Every quiz has an embed_url: a page that plays the quiz with no account and no cookie, marks on the spot, explains each answer, and ends with the score. Put it in an iframe. The address carries its own key where one is needed, so it is safe in a page; your API key never goes in a browser.

<iframe src="https://app.quizbyt.com/embed/quiz/c5_math_decimals_e1" width="100%" height="640" style="border:0;max-width:720px;border-radius:16px" loading="lazy" title="QuizByt quiz"></iframe>

The player tells the parent page its height. Add this once and the frame fits its content:

<script>addEventListener("message",function(e){if(e.data&&e.data.quizbytHeight){document.querySelectorAll('iframe[src*="/embed/"]').forEach(function(f){if(f.contentWindow===e.source)f.style.height=e.data.quizbytHeight+"px"})}})</script>

In a native app, open the same address in a web view. On the paid plan, 30 quizzes per subject are also open on the embed picker, where you get the two lines of HTML without writing any code.

Code samples

The same two calls, list then fetch, in the language you use. The key comes from the environment, never the code; on the beta plan the base address is /api/v1/beta. The Referer line names the site the key is bound to; from a page in a browser it is sent for you.

<?php
// Composer: no library needed, plain curl.
$key = getenv('QUIZBYT_KEY');          // never in the code
$base = 'https://app.quizbyt.com/api/v1';                 // or /api/v1/beta on the beta plan

function quizbyt(string $path, string $key, string $base): array {
  $ch = curl_init($base . $path);
  curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key, 'Accept: application/json', 'Referer: https://yoursite.example/'],  // the site your key is bound to
  ]);
  $body = curl_exec($ch);
  $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
  curl_close($ch);
  $data = json_decode($body, true);
  if ($status !== 200) {
    throw new RuntimeException($data['error'] . ': ' . $data['message']);
  }
  return $data;
}

$list = quizbyt('/quizzes?class=class-5&subject=mathematics&per_page=5', $key, $base);
foreach ($list['quizzes'] as $q) {
  echo $q['title'], ' (', $q['questions'], " questions)\n";
}
$quiz = quizbyt('/quizzes/' . $list['quizzes'][0]['id'], $key, $base);
foreach ($quiz['questions'] as $qq) {
  echo $qq['number'], '. ', $qq['text'], ' -> ', $qq['answer'], "\n";
}
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

type Quiz struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Questions int    `json:"questions"`
}

func get(path string, out any) error {
	req, _ := http.NewRequest("GET", "https://app.quizbyt.com/api/v1"+path, nil)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("QUIZBYT_KEY"))
	req.Header.Set("Referer", "https://yoursite.example/") // the site your key is bound to
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		return err
	}
	defer res.Body.Close()
	if res.StatusCode != 200 {
		var e struct{ Error, Message string }
		json.NewDecoder(res.Body).Decode(&e)
		return fmt.Errorf("%s: %s", e.Error, e.Message)
	}
	return json.NewDecoder(res.Body).Decode(out)
}

func main() {
	var list struct{ Quizzes []Quiz }
	if err := get("/quizzes?class=class-5&subject=mathematics&per_page=5", &list); err != nil {
		panic(err)
	}
	for _, q := range list.Quizzes {
		fmt.Printf("%s (%d questions)\n", q.Title, q.Questions)
	}
}
// Node 18+ (fetch is built in). Keep the key on the server.
const BASE = 'https://app.quizbyt.com/api/v1';   // or /api/v1/beta on the beta plan
const KEY = process.env.QUIZBYT_KEY;

async function quizbyt(path) {
  const res = await fetch(BASE + path, { headers: { Authorization: `Bearer ${KEY}`, Referer: 'https://yoursite.example/' } /* the site your key is bound to */ });
  const data = await res.json();
  if (!res.ok) throw new Error(`${data.error}: ${data.message}`);
  return data;
}

const list = await quizbyt('/quizzes?class=class-5&subject=mathematics&per_page=5');
for (const q of list.quizzes) console.log(q.title, `(${q.questions} questions)`);

const quiz = await quizbyt(`/quizzes/${list.quizzes[0].id}`);
for (const q of quiz.questions) console.log(q.number, q.text, '->', q.answer);
// In the browser, show quiz.embed_url in an <iframe> instead of calling the API.
type Quiz = { id: string; title: string; topic: string; questions: number; embed_url: string };
type Question = { number: number; text: string; options: { id: string; text: string }[]; answer: string; explanation: string | null };
type QuizDetail = Quiz & { questions: Question[]; attribution: { text: string; url: string } };

const BASE = 'https://app.quizbyt.com/api/v1';
const KEY = process.env.QUIZBYT_KEY!;

async function quizbyt<T>(path: string): Promise<T> {
  const res = await fetch(BASE + path, { headers: { Authorization: `Bearer ${KEY}`, Referer: 'https://yoursite.example/' } /* the site your key is bound to */ });
  const data = await res.json();
  if (!res.ok) throw new Error(`${data.error}: ${data.message}`);
  return data as T;
}

const list = await quizbyt<{ quizzes: Quiz[]; total: number }>('/quizzes?subject=science&level=easy');
const quiz = await quizbyt<QuizDetail>(`/quizzes/${list.quizzes[0].id}`);
console.log(quiz.title, quiz.questions.length, 'questions');
import java.net.URI;
import java.net.http.*;

public class QuizByt {
  static final String BASE = "https://app.quizbyt.com/api/v1";   // or /api/v1/beta
  static final String KEY = System.getenv("QUIZBYT_KEY");

  static String get(String path) throws Exception {
    HttpClient client = HttpClient.newHttpClient();
    HttpRequest req = HttpRequest.newBuilder(URI.create(BASE + path))
        .header("Authorization", "Bearer " + KEY)
        .header("Accept", "application/json")
        .header("Referer", "https://yoursite.example/")   // the site your key is bound to
        .GET().build();
    HttpResponse<String> res = client.send(req, HttpResponse.BodyHandlers.ofString());
    if (res.statusCode() != 200) {
      throw new RuntimeException("QuizByt " + res.statusCode() + ": " + res.body());
    }
    return res.body();   // parse with Jackson or Gson
  }

  public static void main(String[] args) throws Exception {
    System.out.println(get("/quizzes?class=class-5&subject=mathematics&per_page=5"));
    System.out.println(get("/quizzes/c5_math_decimals_e1"));
  }
}

Classes and subjects

GET /api/v1/classes lists every class with its subjects and quiz counts; GET /api/v1/subjects lists the subjects. Use their id values as filters above.

{"classes":[{"id":"class-1","name":"Class 1","quizzes":124,"subjects":[{"id":"english","name":"English"},{"id":"mathematics","name":"Mathematics"},{"id":"science","name":"Science"}]}, โ€ฆ]}

Limits and errors

  • 60 requests a minute, 2,000 a day per key. Over the limit you get 429. Cache what you fetch; the library changes slowly and quizzes keep their ids.
  • Errors are JSON with error and message: 401 unauthorized, 403 wrong_domain (the key is bound to another site; see your key works only for your site), 400 bad_request, 404 not_found, 404 library_done, 429 rate_limited, 429 quota_month (prod and prestige: that class and subject is used up until resets_on), 429 quota_beta (beta: that class and subject is used up; a plan opens more). The quota errors also carry used, limit, plans_url and contact.
  • CORS is open, but the key belongs on your server: call the API from your backend, send the questions or the embed_url to your pages.
  • Need more than your plan gives for a class and subject? Prestige has 50 a month, or write to info@quizbyt.com with your app name.

The two rules

  1. Credit stays. "Quiz by QuizByt", linked, wherever a quiz is shown.
  2. Keys stay on your server. Never in a page, an app binary or a public repository.

And a key is tied to the site it was registered for, with its subdomains; it does not work from anywhere else.

No scraping the library into another product. A key that breaks the rules is revoked. Everything else, build away.

Get a key

Developer supportWrite to info@quizbyt.com with your app name and the request that misbehaved (address, time, response). A person answers within one working day; outages faster.