API Keys are unique alphanumeric strings or tokens that are used to authenticate and authorize access to the GAIA API.

Why use an API Key:

  1. Authentication: API keys serve as a form of identification for applications or users accessing an API. By including the API key in API requests, the API can verify the identity of the requester and ensure that only authorized applications or users can access its resources.

  2. Authorization: API keys also play a role in authorization, determining what actions or resources the requester is allowed to access. The API key may be associated with certain permissions or roles that define the level of access and functionality available to the requester.

  3. Security: API keys enhance the security of an API by preventing unauthorized access. With a unique API key, the API provider can track and monitor API usage, enforce usage limits, and implement security measures such as rate limiting, throttling, and access control.

  4. Usage Tracking: API keys allow API providers to track and monitor how their API is being used. They can collect data on the number of requests made, the endpoints accessed, and other metrics that help analyze usage patterns and optimize API performance.

How to Generate an API Key

In GAIA API the API generations requires for a user to be authenticated, meaning Authentication must be enable

Step-by-step guide

  1. Enable Authentication and choose your authentication method
  2. Generate the API Key with either direct http request to the API Keys Endpoint or you can go to the Swagger documentation and do it from there
  3. Copy the resulting API Key and apply it to every request sent to the GAIA API as a header

    Authorization: Search <API KEY>

All the request made to the GAIA API must include the Authorization: Search <API KEY>

Example 

Here an example calling the Search Endpoint using the API Key

curl -X 'POST' \
  'http://localhost:8085/es/api/v1/search/' \
  -H 'accept: application/json' \
  -H 'Authorization: Search U2VhcmNop1orHY8nL535WF2pb-BwVUcvtR0vkwgtlRLWz_I96S' \
  -H 'Content-Type: application/json' \
  -d '{
  "q": "testing",
  "size": 25,
  "page": 1
}'