WikiCrowd API

This page documents the JSON API for WikiCrowd.

Authentication

Authentication is handled using Laravel Sanctum. Clients should first authenticate to obtain an API token. This token must be included in the Authorization header as a Bearer token for all authenticated requests: Authorization: Bearer <YOUR_TOKEN>.

Endpoints

Question Groups

GET /api/groups

Retrieves a list of question groups.

Example curl command:

curl -X GET "https://wikicrowd.toolforge.org/api/groups"

Response: A JSON object where each key is a main group category (e.g., "animals", "food", "refinement"). Each category contains:

  • display_name: (string) The human-readable name of the main group.
  • display_description: (string, optional) A description for the main group (primarily for "Refinement").
  • subGroups: (array) A list of specific sub-groups. Each sub-group object has:
    • id: (integer) The ID of the sub-group.
    • name: (string) The internal name/identifier of the sub-group (e.g., "depicts/animals/Q144", "depicts-refine/some-identifier").
    • display_name: (string) The human-readable name for the sub-group.
    • unanswered: (integer) The count of unanswered questions in this sub-group.

Questions

GET /api/questions/{groupName}/{desiredId?} (Requires Authentication)

Fetches questions for a specific group.

  • {groupName}: (string) The name of the question group (e.g., animals/Q144 or depicts-refine/some-name). You can get this from the name property of a sub-group in the /api/groups response.
  • {desiredId}: (integer, optional) The ID of a specific question to retrieve. If not provided, or if the desired question is not found or already answered, a random unanswered question from the group is returned.

Example curl command (replace {groupName} and <YOUR_TOKEN>):

curl -X GET -H "Authorization: Bearer <YOUR_TOKEN>" "https://wikicrowd.toolforge.org/api/questions/{groupName}"

To request a specific question ID (replace {groupName}, {questionId} and <YOUR_TOKEN>):

curl -X GET -H "Authorization: Bearer <YOUR_TOKEN>" "https://wikicrowd.toolforge.org/api/questions/{groupName}/{questionId}"

Response: A JSON object containing:

  • question: (object) The question object, including its id, properties (like image URL, depicts information), etc.
  • next_question_id: (integer|null) The ID of another random unanswered question in the same group, or null if no other questions are available. This can be used to pre-fetch or navigate.

Answers

POST /api/answers (Requires Authentication)

Submits an answer to a question.

Request Body (JSON):

  • question_id: (integer, required) The ID of the question being answered.
  • answer: (string, required) The answer. Must be one of: yes, no, skip.

Example curl command (replace <YOUR_TOKEN>, {question_id}, and {answer_value}):

curl -X POST -H "Authorization: Bearer <YOUR_TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json" -d '{
    "question_id": {question_id},
    "answer": "{answer_value}"
}' "https://wikicrowd.toolforge.org/api/answers"

Response (Success - 201 Created):

{
    "message": "Answer submitted successfully.",
    "answer": { /* Answer object */ }
}

Response (Validation Error - 422 Unprocessable Entity):

{
    "message": "The given data was invalid.",
    "errors": { /* Validation error details */ }
}

Response (Question Not Found - 404 Not Found):

{
    "message": "Question not found."
}