Questions API

The Questions API provides access to the Jarvis Questions database, including random questions, categories, Question of the Day (QOTD), search capabilities and question management tools.

Base Endpoint
/api/questions/[action]/[object]
Part Description
action The operation to perform.
object Optional value used by the action.
Available Endpoints
Endpoint Description
/api/questions List active questions.
/api/questions/random Return a random active question.
/api/questions/qotd Returns today's Question of the Day. If one does not exist, a new question is selected, marked as today's QOTD and returned.
/api/questions/id/{id} Return a specific question.
/api/questions/category/{category} Return questions from a category.
/api/questions/categories List all categories with question counts.
/api/questions/search/{text} Search question text.
/api/questions/recent Recent questions ordered by creation date.
/api/questions/count Question statistics.
Query Parameters
Parameter Example Description
limit 25 Maximum number of results returned.
category funny Filter questions by category.
active true Filter active or inactive questions.
Examples
GET /api/questions
GET /api/questions?limit=50
GET /api/questions/random
GET /api/questions/random?category=gaming
GET /api/questions/qotd
GET /api/questions/id/123
GET /api/questions/category/funny
GET /api/questions/search/food
GET /api/questions/recent?limit=10
GET /api/questions/count
Question Of The Day Logic
QOTD Generation
  • If a question already exists with today's QOTD date, it is returned.
  • If no QOTD exists for today, a random active question is selected.
  • The selected question cannot be one of the last 30 questions previously used as a QOTD.
  • The selected question's qotd field is updated to today's date.
  • The newly assigned question is returned.
Example Question Response
{
    "id": 42,
    "question": "What is your favourite game of all time?",
    "category": "gaming",
    "active": true,
    "created_at": "2026-11-03T12:15:00+00:00",
    "qotd": "2026-11-04"
}
Example Category Response
[
    {
        "category": "gaming",
        "question_count": 125
    },
    {
        "category": "relationships",
        "question_count": 87
    }
]
Example Count Response
{
    "total": 1250,
    "active": 1198,
    "used_as_qotd": 365
}

Authentication & Rate Limits

All Jarvis APIs require a valid API token. Tokens are issued through the Jarvis Developer Portal and are associated with an account plan which determines access levels and request limits.

Authentication

Every request must include a valid API token. Requests made without a token or with an invalid token will be rejected.

Authorization Header (Recommended)
Authorization: YOUR_API_TOKEN
X-API-Token Header
X-API-Token: YOUR_API_TOKEN
Query String
GET /api/flags/random?token=YOUR_API_TOKEN
For security reasons, the Authorization header method is strongly recommended. Avoid exposing API tokens in URLs where possible.
Example Requests
cURL
curl \
-H "Authorization: YOUR_API_TOKEN" \
https://jarvisbot.uk/api/flags/random
JavaScript (Fetch)
fetch("https://jarvisbot.uk/api/jokes/random", {
    headers: {
        "Authorization": "YOUR_API_TOKEN"
    }
})
.then(r => r.json())
.then(console.log);
PHP
$response = file_get_contents(
    "https://jarvisbot.uk/api/questions/random",
    false,
    stream_context_create([
        'http' => [
            'header' => [
                'Authorization: YOUR_API_TOKEN'
            ]
        ]
    ])
);

$data = json_decode($response, true);
Account Plans
Plan Daily Requests API Access
Free 100 Requests Basic APIs
Premium 10,000 Requests All APIs
Enterprise Unlimited All APIs + Priority Support
Rate Limiting

API usage is automatically monitored based on your account type. Once your limit is reached, requests will be temporarily blocked until your allowance resets.

Plan Limit Window
Free 100 Requests 24 Hours
Premium 10,000 Requests 24 Hours
Enterprise Unlimited No Restriction
Authentication Error Response
{
    "success": false,
    "error": "invalidToken",
    "msg": "API token required"
}
Invalid Token Response
{
    "success": false,
    "error": "invalidToken",
    "msg": "Invalid API token"
}
Rate Limit Response
{
    "success": false,
    "error": "rateLimit",
    "msg": "API limit exceeded",
    "plan": "free",
    "limit": 100
}
Best Practices
  • Store API tokens securely and never expose them publicly.
  • Use the Authorization header whenever possible.
  • Cache responses where appropriate to reduce API calls.
  • Monitor your daily usage to avoid rate limiting.
  • Upgrade your account if your application requires higher throughput.
Supported APIs
  • Flags API
  • Dictionary API
  • Questions API
  • Riddles API
  • Jokes API
  • Pickup Lines API
  • Truth Or Dare API
  • Harry Potter Spells API
  • Future Jarvis APIs
Need additional capacity or custom limits? Contact the Jarvis team to discuss Premium and Enterprise API access.