Sell entries
Entry question
Competitions can require a buyer to answer a question correctly before they enter. Ask it in your own interface, then pass the proof of a correct answer to checkout.
Get a question
Pass competitionId to get a question that fits that competition's prize (a watch question for a watch, an electronics question for a laptop).
curl https://www.bitraffle.io/api/v1/entry-question?competitionId=71 \
-H "Authorization: Bearer $BITRAFFLE_SECRET_KEY"const res = await fetch("https://www.bitraffle.io/api/v1/entry-question?competitionId=71", {
headers: { Authorization: `Bearer ${process.env.BITRAFFLE_SECRET_KEY}` },
});
const { data } = await res.json();import os, requests
res = requests.get(
"https://www.bitraffle.io/api/v1/entry-question?competitionId=71",
headers={"Authorization": f"Bearer {os.environ['BITRAFFLE_SECRET_KEY']}"},
)
data = res.json()["data"]Response
{
"data": {
"required": true,
"question": {
"id": 17,
"question": "On an analogue watch, how many degrees does the minute hand move in one minute?",
"options": [
"1",
"6",
"12",
"30"
],
"category": "watch"
}
}
}If required is false, skip straight to checkout.
Check the answer
Send the index of the option the buyer chose. A correct answer returns a pass.
curl -X POST https://www.bitraffle.io/api/v1/entry-question/verify \
-H "Authorization: Bearer $BITRAFFLE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "questionId": 17, "answerIndex": 1 }'const res = await fetch("https://www.bitraffle.io/api/v1/entry-question/verify", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BITRAFFLE_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ questionId: 17, answerIndex: 1 }),
});
const { data } = await res.json(); // { correct: true, pass: "…" }import os, requests
res = requests.post(
"https://www.bitraffle.io/api/v1/entry-question/verify",
headers={"Authorization": f"Bearer {os.environ['BITRAFFLE_SECRET_KEY']}"},
json={"questionId": 17, "answerIndex": 1},
)
data = res.json()["data"] # {"correct": True, "pass": "…"}| Response | Next |
|---|---|
{ correct: true, pass } | Send pass as skillPass when you start the checkout session. It works once, and expires after 15 minutes. |
{ correct: false } | Tell the buyer and let them try again with a new question. |