Get a Space's analytics - Spacefast Docs

Get a Space's analytics

Returns traffic for one Space over window, which defaults to the last 7 days: a request, view, and bandwidth series, the top 10 paths and hostnames, and daily unique visitors. Buckets are hourly for 48h and daily for 7d and 30d. A view is a request that answered under 400 and did not come from a crawler, assets included. Figures are read at request time from the box serving the Space, so a Space whose runtime is not provisioned yet fails.

GET/v1/spaces/{spaceId}/analytics

Authorization

AuthorizationBearer token · headerrequired

`Authorization: Bearer ` with the Space key (`sfc_` prefix) of an unclaimed Space. The same key is the fragment of the claim URL and the token in the Space's `/__/` sign-in URL.

or

AuthorizationBearer token · headerrequired

`Authorization: Bearer ` with an API key (`sfa_` prefix), an OAuth access token, a session token, or a Space machine credential (`sfm_` prefix).

Path parameters

spaceIdstringrequired

min length 1

Query parameters

windowstring

Allowed:48h``7d``30d

Responses

200Response for status 200

$schemastring

Canonical JSON Schema URL for this response body. The server also sends it in the `Link: rel="describedby"` response header.

dataobjectrequired

Show propertiesHide properties

Space ID the traffic was aggregated for.

Window the summary covers.

Allowed:48h``7d``30d

Start of the window as an ISO 8601 timestamp.

End of the window as an ISO 8601 timestamp.

Bucket width of series: hourly for 48h, daily for 7d and 30d.

Allowed:hourly``daily

Requests answered below status 400 that were not identified as crawler traffic, assets included.

Response bytes served over the window.

Unique visitors per UTC day. A day is the finest resolution the estimate is produced at, and the numbers are never summed across days.

Show propertiesHide properties

Array of object

Start of the UTC day as an ISO 8601 timestamp.

Estimated unique visitors that day.

The ten most requested paths over the window, largest first.

Show propertiesHide properties

Array of object

The ten most requested hostnames over the window, largest first.

Show propertiesHide properties

Array of object

Per-bucket traffic across the window, oldest bucket first.

Show propertiesHide properties

Array of object

Start of the bucket as an ISO 8601 timestamp.

All requests in the bucket, crawlers and errors included.

Requests in the bucket that count as views.

Response bytes served in the bucket.

defaultError. Every 4xx and 5xx response is one RFC 9457 problem document served as `application/problem+json`.

$schemastring

Canonical JSON Schema URL for this response body. The server also sends it in the `Link: rel="describedby"` response header.

URL of the documentation page for this error. Derived from `code`.

Human-readable name of the error type. Derived from `code`.

HTTP status of the response, repeated in the body.

min -9007199254740991 · max 9007199254740991

What went wrong in this request.

Stable snake_case error code. Match on this, not on `detail`.

RFC 6901 JSON Pointer to the request field or batch entry that failed, for example `/files/37/path`. Present on validation failures.

Machine-readable context keyed by the error code.

Recovery steps safe to show to a person.

Commands or API requests to run next, usable as written.

ID of this request, from the `X-Request-Id` header or generated. Quote it when contacting support.

Try it

Server

Base URLhttps://api.spacefast.com

Custom base URLOverrides the selected server when set.

Authorization

Bearer tokenRemember on this deviceInclude my values in samples

Parameters

spaceIdpath*windowquery—48h7d30d

Send

Request

cURL

curl -X GET "https://api.spacefast.com/v1/spaces/string/analytics" \
  -H "Authorization: Bearer YOUR_TOKEN"

JavaScript

const response = await fetch("https://api.spacefast.com/v1/spaces/string/analytics", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN"
  }
});

Python

import requests

response = requests.get(
    "https://api.spacefast.com/v1/spaces/string/analytics",
    headers={
        "Authorization": "Bearer YOUR_TOKEN"
    },
)

Response

200default

{
  "$schema": "http://example.com",
  "data": {
    "spaceId": "string",
    "window": "48h",
    "since": "string",
    "until": "string",
    "granularity": "hourly",
    "views": 0,
    "bandwidthBytes": 0,
    "visitorsByDay": [
      {
        "date": "string",
        "visitors": 0
      }
    ],
    "topPaths": [
      {
        "path": "string",
        "views": 0
      }
    ],
    "topHosts": [
      {
        "host": "string",
        "views": 0
      }
    ],
    "series": [
      {
        "bucket": "string",
        "requests": 0,
        "views": 0,
        "bandwidthBytes": 0
      }
    ]
  }
}
{
  "$schema": "http://example.com",
  "type": "string",
  "title": "string",
  "status": -9007199254740991,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": [
    "string"
  ],
  "next": [
    "string"
  ],
  "requestId": "string"
}