- Help Topics: 1. A Short Introduction to IGSDB V2 2. What's Changed
4.4. Using API Tokens
The IGSDB API uses token-based authentication for both REST and GraphQL queries. This means that you need to include your API token in the request header 'Authorization' when making a request to the API.
How to get an API token
To get an API token, you need to have a user account on this site. If you don't have an account, you can get one by contacting us at rdmitchell@lbl.gov.
Once you have an account, you can get your API token by following these steps:
- Make sure you're logged in. If you are, you should see an "Account" item in the far right of the nav menu above.
- Select Account > User Profile. Your API token will be on your User Profile page.
Using your API token
To use your API token, you need to include it in the request header '
Authorization
' when making a request to the API.
For example, to get a list of all IGSDB products in JSON form, you can make an HTTP GET request
to the following endpoint: /api/v1/products/
and include the token in the request.
REST example
For example, run the following command in a terminal on your machine to get a list of all IGSDB products in JSON form:
curl -XGET https://igsdb.herokuapp.com/api/products/ -H 'Authorization:Token ( your user's API token )'
GraphQL example
A token must also be sent when sending a GraphQL query. For example, to get a list of all IGSDB products in JSON form, you can make an HTTP POST request to the following endpoint:
curl -X POST http://localhost:8001/graphql/ \
-H 'Authorization: Token ( your user's API token )' \
-H 'Content-Type: application/json' \
-d '{"query": "query { allOpticalData { edges { node { locator nearnormalHemisphericalVisibleTransmittances nearnormalHemisphericalVisibleReflectances } } } }"}'