Batch and asynchronous processing
In some cases where lots of Riddles are needed, it may be more efficient to build them in batches. This drastically reduces the overhead of each HTTP request and allows for faster processing.
Additionally, single Riddles can also be built asynchronously - this makes migrating to an asynchronous flow much easier with your existing code and processes.
Building in batches
A batch is a collection of Riddle builds, sent in one payload to the builder API.
Example object
For example if I want to create a quiz and poll with one request, only one request to the builder batch API endpoint is needed with the batch
property set to an array of build configurations:
{
"batch": [
{
"type": "Quiz",
"build": {
"title": "My new quiz",
"blocks": [
{
"title": "What is the capital of France?",
"type": "SingleChoice",
"items": {
"Berlin": false,
"Madrid": false,
"Paris": true
}
}
]
}
},
{
"type": "Poll",
"build": {
"title": "My new poll",
"blocks": [
{
"title": "What is your favorite color?",
"type": "SingleChoice",
"items": [
"Red",
"Green",
"Blue"
]
}
]
}
}
]
}
Note: Just like in the normal Builder API endpoint, the parameters publish
(to publish all Riddles in the batch) and project
(to assign all Riddles in the batch to a specific project) are supported.
Important factors to consider when using batches
- The batch size is limited to 100 Riddles per request.
- The Riddles are created asynchronously and the response will contain a list of UUIDs for Riddles which are only initialized, i.e. not visible yet in the Creator.
Building single Riddles asynchronously
Building asynchronously means that a single Riddle build is processed in the background and the response will contain a UUID for the Riddle which is only initialized, i.e. not visible yet in the Creator.
Example object
To mark the build as asynchronous, the queue
property must be set to true
in the request. The request would look like this:
{
"type": "Quiz",
"queue": true,
"blocks": [
{
"title": "What is the capital of France?",
"type": "SingleChoice",
"items": {
"Berlin": false,
"Madrid": false,
"Paris": true,
}
}
]
}