Quick start
Make your first call to the Elium API with Insomnia: register a connected app, get a token and query a story.
This guide takes you to your first API call without going into detail. It uses Insomnia, a free desktop client, to sign in and send queries. Once it works, you can use any GraphQL library or HTTP client.
Register a connected app
The API uses OAuth 2.0: a program calls Elium on behalf of a user. In Elium, that program is a connected app.
- Click your avatar, choose Settings, then select Advanced > Connected apps.
- Click New application.
- Enter a title, such as
Insomnia, and a redirect URL, such ashttp://localhost:3000/. Insomnia handles the redirect itself, so nothing needs to run at that address. - Under Scopes, all three scopes are ticked by default. Keep API and untick MCP and MCP (writable): this app only calls the API.
- Turn on Trusted if you do not want to approve the app when you sign in, then click Save.
API and connected applications describes all the options: several redirect URLs, scopes and trusted apps.
Copy the connection details
The app now appears in the list. Click the three dots at the end of its row, then OAuth details.... The OAuth configuration window shows every value Insomnia needs, each with a copy button. The client secret is hidden: click it to show it.
Configure Insomnia
In Insomnia, create a new request and choose the GraphQL type.
In the Auth tab, select OAuth 2.0.
Set Grant type to Authorization Code. Then copy each value from the OAuth configuration window into Insomnia:
| In Insomnia | Copy from Elium |
|---|---|
| URL (at the top of the request) | Endpoint (https://your-platform-name.elium.com/graphql) |
| Authorization URL | Authorisation URL |
| Access token URL | Access token URL |
| Redirect URL | Redirect URL |
| Client ID | Client Id |
| Client secret | Client Secret |
| Scope (under Advanced Options) | Scopes (apiv1) |
Tick Use PKCE (Proof Key for Code Exchange) and keep the SHA-256 method. Elium accepts PKCE from every application and requires it from an application that has no client secret.
Click Fetch tokens. Insomnia opens the Elium sign-in page. Sign in, approve the app if it asks you to, and Insomnia stores the tokens.
Authentication explains what Insomnia just did, for when you build the flow into your own program.
Your first query
Check that you are signed in by asking for the current user. Paste this in the GraphQL body and click Send:
query {
me {
id
}
}
The response is JSON, with the result under a data key:
{
"data": {
"me": {
"id": "TWU6MTIz"
}
}
}
Read a story
In the API, an article is a story. To find one, use its slug, the number in its address: for https://your-platform-name.elium.com/tile/view/123/, the slug is 123.
Replace the slug with one from your platform and send:
query {
story(slug: 123) {
slug
version {
title
}
user {
name
}
}
}
The response gives the title of the latest version and the name of the owner:
{
"data": {
"story": {
"slug": 123,
"version": {
"title": "My first story"
},
"user": {
"name": "John Doe"
}
}
}
}
You can ask for as many fields and sub-fields as you need. Insomnia completes field names as you type, and its schema button shows the documentation of each one.
Where to go now
- Authentication covers the OAuth flows in detail, including the one for scripts that run without a user.
- GraphQL IDs and nodes explains the difference between a slug and a GraphQL ID.
- Stories, spaces and users describes the objects you will query.