Guide 2.8: Developer Guide

Fetching Questions

Now that you know how to retrieve subjects, exam types, and years, it is time to fetch the actual questions. The /q endpoint is the core of SdashAPI. Depending on your parameters, it can return a single random question, a specific question by ID, or a batch of up to 50 questions.

Fetching a Single Random Question

2.8.1

If you call the /q endpoint with no parameters (or minimal parameters), SdashAPI defaults to returning exactly one random question from the entire bank. This is incredibly useful for "Question of the Day" features.

GET https://sdashapi.com/api/v1/q

Notice that when the limit is exactly 1, the data property is a JSON Object, not an Array.

Fetching a Specific Question by ID

2.8.2

Every question in our database has a unique integer id. If a user bookmarks a question or shares a link to a question, you can retrieve that exact question by passing the id parameter.

GET https://sdashapi.com/api/v1/q?id=8931

Fetching Multiple Questions (Batching)

2.8.3

To build a full quiz (e.g., a 10-question test), you should not make 10 separate API calls. That would severely impact your rate limits and slow down your application. Instead, use the limit parameter.

GET https://sdashapi.com/api/v1/q?limit=10

CRITICAL BEHAVIOR: When limit is greater than 1, SdashAPI changes the structure of the response. The data property becomes a JSON Array containing the question objects. You must use data.forEach() or data.map() to iterate over them.

Maximum Limits

2.8.4

To protect our infrastructure, the absolute maximum limit you can request in a single API call is 50 questions. If you pass a limit of 100, the API will safely truncate it and only return 50. If you need to build a 100-question exam, you must make two separate calls with a limit of 50 each.

How do I evaluate answers?

Next, we will look at how SdashAPI formats answers and solutions.

Next Guide: Fetching Answers →
Avatar

How can we help?

We reply immediately

Hello! 👋 How can we help you today?