Authentication


Authentication

Authentication is handled with a simple API key.

An example of an API key is: 3lsgjMYPph1HBauH1DXErdP5POak0dhb2Mp0S060

You can attach your API key to a request in one of three ways:

  1. apiKey querystring parameter.
  2. X-Api-Key HTTP header.

We strongly recommend option 2 so that your API key isn't visible to others in logs or request sniffing.

Example

  • Using the apiKey GET parameter:
curl https://quizapi.io/api/v1/questions -G \
-d apiKey=YOUR_API_KEY \
  • Using the X-Api-Key header:
curl https://quizapi.io/api/v1/questions \
-H 'X-Api-Key: YOUR_API_KEY'

Authentication error

If you don't append your API key correctly, or your API key is invalid, you will receive a 401 - Unauthorized HTTP error:

{
  "error": "Unauthenticated."
}