Connect n8n
Read your students in n8n with a Header Auth credential and an HTTP Request node, then follow the pages with an If node.
You will read the list of your students in n8n without writing code: a credential that holds your key, an HTTP Request node, then a loop to read every page.
You need a key that can read students, with Students › Read (students:read) ticked. If you do not have one, create it in the app, under Settings › Integrations › API keys: it is shown only once.
1. Create the Header Auth credential
In n8n, open Credentials and create a credential of type Header Auth. Give it a name you will recognize, then fill in:
| Field | Value |
|---|---|
| Name | Authorization |
| Value | Bearer fd_live_xxxxxxxx |
Replace fd_live_xxxxxxxx with your key. Keep the word Bearer, a space, then your whole key. n8n keeps the key in the credential: it does not appear in the node.
2. Set up the HTTP Request node
Add an HTTP Request node to your workflow, after a manual trigger to start with, and fill in:
| Field | Value |
|---|---|
| Method | GET |
| URL | https://api.fitdistance.io/api/partner/v1/students |
| Authentication | Generic Credential Type › Header Auth |
| Send Query Parameters | limit = 50 |
For Authentication, pick the credential from step 1. For Send Query Parameters, turn the option on, then add a limit parameter set to 50.
3. Run the node
Run the node. It needs the scope students:read and costs one credit, debited before the call. The output has three fields to know:
data: the students of this page, 50 at most.has_more:truewhen more pages remain.next_cursor: the marker of the next page, which you pass ascursor.
{
"data": [{ "id": 1, "first_name": "Léa", "last_name": "Dupont" }],
"next_cursor": "xxxxxxxx",
"has_more": true
}A 401 UNAUTHORIZED means the key is missing, copied wrongly or revoked: check the word Bearer. A 403 SCOPE_MISSING means a scope is missing, and details.scope names it. Neither costs a credit. A refused parameter, such as limit=500, gives a 400 VALIDATION and costs a credit.
4. Read every page
A page costs one credit, whatever its number of students. To follow next_cursor from page to page, first add an If node after the first HTTP Request. Its condition is that {{ $json.has_more }} is true.
On the true output, add a second HTTP Request node, set up like the first with one more parameter:
| Field | Value |
|---|---|
| Method | GET |
| URL | https://api.fitdistance.io/api/partner/v1/students |
| Authentication | Generic Credential Type › Header Auth |
| Send Query Parameters | limit = 50, cursor = {{ $json.next_cursor }} |
Finally, connect the output of this second node to the input of the If. The loop stops when has_more is false. To spend less, set limit to 200, the maximum, in both HTTP Request nodes.
The double braces tell n8n to read the value in the incoming item: here, the previous page. If you add a filter such as since, keep it identical from one page to the next: the marker only holds with the same filters. Connect the rest of your workflow to both HTTP Request nodes to handle each page. A fast loop can exceed the pace limit of your key, 10 calls per second and 300 per minute: a 429 carries Retry-After, the number of seconds to wait, and costs nothing.
What next
For a complete automation, work through a use case: an email for each new student, a reminder for students without a check-in, a reminder for inactive students or another use case from the home page. The use cases that write say so at the top of the page: their key must be able to write. The student fields are described in the reference.