Documentation:
Available Environments
There are two environments to connect to, a sandbox environment accesible at:
1. The "sandbox" environment, which is an old copy of the production envirionment and is useful for this testing purposes.
https://api.r8.beer/v1/api/graphql/
2. The production environment that is linked to the live data available on www.ratebeer.com:
https://api.ratebeer.com/v1/api/graphql
Example:
This example runs a
curl command from a bash shell, and connects to the sandbox endpoint.
curl -v 'https://api.r8.beer/v1/api/graphql/' \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-H 'x-api-key: <YOUR_API_KEY>' \
--data-binary '{"query":"query {\n beer(id: 4934) {\n id\n name\n }\n}","variables":"{}","operationName":null}'
It provides 3 headers:
1.
content-type with a value of 'application/json' to indicate that the body uses the
JSON format.
2.
accept with a value of 'application/json' to indicate we're expecting
JSON format in response.
3.
x-api-key the value for which you'll need to supply the
API Key you've received.
The body which is written in GraphQL requests the name of the beer which has an id of 4934:
query {
beer(id: 4934) {
name
}
}
The response body of this example should return the following JSON:
{"data":{"beer":{"id":"4934","name":"Westvleteren 12 (XII)"}}}
Usage limitations
5,000 Requests / Month
1 Request / Second
Full Documentation
For a full reference on the graphql schema are available use the graphiql interface accessible here:
https://api.r8.beer/graphiql
You will be prompted for your API key. Schema is available in the Documentation Explorer in the top right.
More reading on GraphQL
For information on GraphQL please see these resources:
1.
Introduction to GraphQL
2.
GraphQL by Facebook