Get started
Quickstart
Get an API key and make your first GraphQL request in under five minutes.
1. Get an API key
Create an API key as described in Authentication. Store it in an environment variable — never commit it to source control.
export LOCO_API_KEY="your-api-key"2. Make your first request
All requests are POSTs to one endpoint with a JSON body containing a query.
curl https://api.thelocoapp.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LOCO_API_KEY" \
-d '{"query": "{ me { id } }"}'A successful response always has a data key:
{
"data": {
"me": { "id": "…" }
}
}3. Call it from code
const res = await fetch("https://api.thelocoapp.com/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.LOCO_API_KEY}`,
},
body: JSON.stringify({
query: `query Restaurants($first: Int) {
restaurants(first: $first) {
edges { node { id } }
pageInfo { hasNextPage endCursor }
}
}`,
variables: { first: 10 },
}),
});
const { data, errors } = await res.json();Next steps
- Build a complete app in the first app tutorial.
- Learn how lists work in Paginate through results.
- Browse every operation in the API reference.