Skip to the content.

API DOCUMENTATION FOR TRIVIA API 🍱🥧

GET '/api/v1.0/categories'

get request

{
  "1": "Science",
  "2": "Art",
  "3": "Geography",
  "4": "History",
  "5": "Entertainment",
  "6": "Sports"
}

GET '/categories'

{
  "categories": {
    "1": "Science",
    "2": "Art",
    "3": "Geography",
    "4": "History",
    "5": "Entertainment",
    "6": "Sports"
  }
}

GET '/questions?page=${integer}'

{
  "questions": [
    {
      "id": 1,
      "question": "This is a question",
      "answer": "This is an answer",
      "difficulty": 5,
      "category": 2
    }
  ],
  "totalQuestions": 100,
  "categories": {
    "1": "Science",
    "2": "Art",
    "3": "Geography",
    "4": "History",
    "5": "Entertainment",
    "6": "Sports"
  },
  "currentCategory": "History"
}

GET '/categories/${id}/questions'

{
  "questions": [
    {
      "id": 1,
      "question": "This is a question",
      "answer": "This is an answer",
      "difficulty": 5,
      "category": 4
    }
  ],
  "totalQuestions": 100,
  "currentCategory": "History"
}

DELETE '/questions/${id}'


POST '/quizzes'

{
    'previous_questions': [1, 4, 20, 15]
    quiz_category': 'current category'
 }
{
  "question": {
    "id": 1,
    "question": "This is a question",
    "answer": "This is an answer",
    "difficulty": 5,
    "category": 4
  }
}

POST '/questions'

{
  "question": "Heres a new question string",
  "answer": "Heres a new answer string",
  "difficulty": 1,
  "category": 3
}

POST '/questions'

{
  "searchTerm": "this is the term the user is looking for"
}
{
  "questions": [
    {
      "id": 1,
      "question": "This is a question",
      "answer": "This is an answer",
      "difficulty": 5,
      "category": 5
    }
  ],
  "totalQuestions": 100,
  "currentCategory": "Entertainment"
}

SAMPLE CURL REQUEST 🕵️‍♀️

————— CURL QUERIES TO TEST ENDPOINTS ————-

curl http://127.0.0.1:5000/books/8 -X PATCH -H "Content-Type: application/json" -d '{"rating":"1"}'
curl http://127.0.0.1:5000/questions
curl -X DELETE http://127.0.0.1:5000/questions/8 
curl -X POST -H "Content-Type: application/json" -d '{"question":"what is my name", "answer":"Stephen Nwankwo", "category":"5", "difficulty":"2"}' http://127.0.0.1:5000/questions