Skip to main content

List Questions

curl https://api.inspir.uk/api/forum/questions?tag=Biology
Get all forum questions with answers, votes, and user information. Public endpoint.

Query Parameters

tag
string
Filter by tag. Use “All” or omit to get all questions.

Response

questions
array
{
  "questions": [
    {
      "id": "q-123",
      "user_id": "user-456",
      "user": {
        "id": "user-456",
        "username": "biologystudent"
      },
      "title": "What is the difference between mitosis and meiosis?",
      "details": "I'm confused about the key differences between these two processes. Can someone explain?",
      "tags": ["Biology", "Cell Division"],
      "created_at": "2024-01-15T10:30:00Z",
      "answers": [
        {
          "id": "a-789",
          "question_id": "q-123",
          "user_id": "user-101",
          "user": {
            "id": "user-101",
            "username": "biologyexpert"
          },
          "text": "Mitosis produces two identical daughter cells with the same number of chromosomes, while meiosis produces four genetically different cells with half the chromosomes.",
          "vote_count": 5,
          "created_at": "2024-01-15T11:00:00Z"
        }
      ]
    }
  ]
}

Get Question

curl https://api.inspir.uk/api/forum/questions/q-123
Get a single question with all details. Public endpoint.

Response

question
object
Complete question object with answers sorted by votes
{
  "question": {
    "id": "q-123",
    "user_id": "user-456",
    "user": {
      "id": "user-456",
      "username": "biologystudent"
    },
    "title": "What is the difference between mitosis and meiosis?",
    "details": "I'm confused about the key differences...",
    "tags": ["Biology", "Cell Division"],
    "created_at": "2024-01-15T10:30:00Z",
    "answers": [
      {
        "id": "a-789",
        "text": "Mitosis produces two identical daughter cells...",
        "vote_count": 5,
        "user": {
          "id": "user-101",
          "username": "biologyexpert"
        },
        "created_at": "2024-01-15T11:00:00Z"
      }
    ]
  }
}

Errors

{
  "error": "Question not found"
}

Create Question

curl -X POST https://api.inspir.uk/api/forum/questions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "What is photosynthesis?",
    "details": "Can someone explain how photosynthesis works?",
    "tags": ["Biology", "Plants"]
  }'
Create a new question in the forum. Requires authentication.

Request

title
string
required
Question title
details
string
required
Question details/body
tags
string[]
required
Array of tags (at least one required)

Response

question
object
Created question object with empty answers array
{
  "question": {
    "id": "q-124",
    "user_id": "user-456",
    "user": {
      "id": "user-456",
      "username": "biologystudent"
    },
    "title": "What is photosynthesis?",
    "details": "Can someone explain how photosynthesis works?",
    "tags": ["Biology", "Plants"],
    "created_at": "2024-01-15T12:00:00Z",
    "answers": []
  }
}

Errors

{
  "error": "Title and details are required"
}

Create Answer

curl -X POST https://api.inspir.uk/api/forum/questions/q-123/answers \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Photosynthesis is the process by which plants convert light energy into chemical energy."
  }'
Add an answer to a question. Requires authentication.

Request

text
string
required
Answer content (non-empty)

Response

answer
object
Created answer object with vote_count initialized to 0
{
  "answer": {
    "id": "a-790",
    "question_id": "q-123",
    "user_id": "user-101",
    "user": {
      "id": "user-101",
      "username": "biologyexpert"
    },
    "text": "Photosynthesis is the process by which plants convert light energy into chemical energy.",
    "vote_count": 0,
    "created_at": "2024-01-15T12:30:00Z"
  }
}

Errors

{
  "error": "Answer text is required"
}

Upvote Answer

curl -X POST https://api.inspir.uk/api/forum/answers/a-789/upvote \
  -H "Authorization: Bearer YOUR_TOKEN"
Upvote an answer. Users can only upvote each answer once. Requires authentication.

Response

vote
object
Created vote record
{
  "vote": {
    "id": "v-456",
    "answer_id": "a-789",
    "user_id": "user-456",
    "created_at": "2024-01-15T13:00:00Z"
  }
}

Errors

{
  "error": "You have already upvoted this answer"
}

Remove Upvote

curl -X DELETE https://api.inspir.uk/api/forum/answers/a-789/upvote \
  -H "Authorization: Bearer YOUR_TOKEN"
Remove your upvote from an answer. Requires authentication.

Response

message
string
Confirmation message
{
  "message": "Upvote removed successfully"
}

Get Leaderboard

curl https://api.inspir.uk/api/forum/leaderboard
Get top 10 users by reputation. Public endpoint.

Response

leaderboard
array
{
  "leaderboard": [
    {
      "user_id": "user-101",
      "user": {
        "id": "user-101",
        "username": "biologyexpert"
      },
      "reputation": 1250
    },
    {
      "user_id": "user-202",
      "user": {
        "id": "user-202",
        "username": "mathwhiz"
      },
      "reputation": 980
    }
  ]
}

Get User Reputation

curl https://api.inspir.uk/api/forum/reputation \
  -H "Authorization: Bearer YOUR_TOKEN"
Get the current user’s reputation score. Requires authentication.

Response

reputation
number
User’s reputation score (0 if no reputation record exists)
{
  "reputation": 450
}

Get Forum Stats

curl https://api.inspir.uk/api/forum/stats
Get overall forum statistics. Public endpoint.

Response

stats
object
{
  "stats": {
    "total_questions": 1247,
    "total_answers": 3892,
    "total_upvotes": 8456
  }
}

Build docs developers (and LLMs) love