Sparklines
This guide explains, step by step, how to retrieve sparkline metrics via the API. It focuses on practical, reproducible examples using cURL. All examples use the production gateway base URL, application/json, and include request and response snippets.
Why this matters
- Sparklines are compact time series intended for small trend lines in dashboards or tables. They trade depth for speed and size. When you only need to show recent activity at a glance, the sparkline endpoint is ideal.
- Typical sparkline series include data transmitted and received over a short time window.
Assumptions
- The examples assume you have a valid Bearer token. If you need help obtaining a token, see [./auth](Auth Guide).
- Base URL for all API calls is https://gateway.production.netfoundry.io/frontdoor
- Expected headers for all API calls:
- Authorization: Bearer YOUR_ACCESS_TOKEN
- Accept: application/hal+json or application/json
Operations
Retrieve the data
Use this when you need a compact overview for a single frontdoor.
THe sparkline endpoint accepts duration
to control the time window.
duration
: ISO‑8601 duration relative to "now" (e.g.,PT15M
,PT1H
,P1D
).
Request (last 1 hour as a relative range):
curl -s \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
"https://gateway.production.netfoundry.io/frontdoor/3d6d2b6e-6c7a-4a7f-8c3d-9a9d2e1f0b1c/metrics/sparklines?duration=PT1H"
Example response:
{
"frontdoorId" : "b90501aa-294d-4087-92bd-84222cdbdb54",
"sparklines" : [ {
"scope" : "account",
"id" : "a80lipp1at55cubfobyhp",
"period" : null,
"samples" : [ {
"rx" : 8331,
"tx" : 1321,
"timestamp" : null
}, {
"rx" : 123,
"tx" : 1113,
"timestamp" : null
}, {
"rx" : 21756,
"tx" : 2334,
"timestamp" : null
} ]
} ]
}
Technical Notes
Paths
- GET /frontdoor/\{frontdoorId\}/sparklines
Common errors
400 Bad Request (client error)
{
"error": "invalid_request",
"message": "Value for <property> must be of <type>"
}
Possible reasons include:
- Clock skew: If tokens seem instantly expired, check system time synchronization on the machine making requests.
- Token format: Authorization header must be exactly
Authorization: Bearer <token>
with a space after Bearer orAuthorization: Basic <username:token>
with a space after Basic and a color separator.
401 Unauthorized (missing/expired token)
{
"error": "unauthorized",
"message": "Bearer token is missing or invalid"
}
Possible reasons include:
- Clock skew: If tokens seem instantly expired, check system time synchronization on the machine making requests.
- Token format: Authorization header must be exactly
Authorization: Bearer <token>
with a space after Bearer orAuthorization: Basic <username:token>
with a space after Basic and a color separator.
403 Forbidden (not_authorized)
{
"error": "not_found",
"message": "Frontdoor 3d6d2b6e-6c7a-4a7f-8c3d-9a9d2e1f0b1c not found"
}
Possible reasons include:
- Invalid token: The token is not valid.
- The token does not grant access to the requested resource.
- Clock skew: If tokens seem instantly expired, check system time synchronization on the machine making requests.
- Token format: Authorization header must be exactly
Authorization: Bearer <token>
with a space after Bearer orAuthorization: Basic <username:token>
with a space after Basic and a color separator.