# 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

`Authorization`Bearer token · headerrequired

\`Authorization: Bearer <key>\` 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 \`/\__/<key>\` sign-in URL.

or

`Authorization`Bearer token · headerrequired

\`Authorization: Bearer <token>\` with an API key (\`sfa\_\` prefix), an OAuth access token, a session token, or a Space machine credential (\`sfm\_\` prefix).

## Path parameters

`spaceId`stringrequired

min length 1

## Query parameters

`window`string

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

## Responses

### 200Response for status 200

`$schema`string<uri>

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

`data`objectrequired

### Show propertiesHide properties

- `spaceId`stringrequired

Space ID the traffic was aggregated for.

- `window`stringrequired

Window the summary covers.

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

- `since`stringrequired

Start of the window as an ISO 8601 timestamp.

- `until`stringrequired

End of the window as an ISO 8601 timestamp.

- `granularity`stringrequired

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

Allowed:`hourly``daily`

- `views`numberrequired

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

- `bandwidthBytes`numberrequired

Response bytes served over the window.

- `visitorsByDay`object\[\]required

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`

- `date`stringrequired

Start of the UTC day as an ISO 8601 timestamp.

- `visitors`numberrequired

Estimated unique visitors that day.

- `topPaths`object\[\]required

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

### Show propertiesHide properties

Array of `object`

- `path`stringrequired

- `views`numberrequired

- `topHosts`object\[\]required

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

### Show propertiesHide properties

Array of `object`

- `host`stringrequired

- `views`numberrequired

- `series`object\[\]required

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

### Show propertiesHide properties

Array of `object`

- `bucket`stringrequired

Start of the bucket as an ISO 8601 timestamp.

- `requests`numberrequired

All requests in the bucket, crawlers and errors included.

- `views`numberrequired

Requests in the bucket that count as views.

- `bandwidthBytes`numberrequired

Response bytes served in the bucket.

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

`$schema`string<uri>

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

- `type`stringrequired

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

- `title`stringrequired

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

- `status`integerrequired

HTTP status of the response, repeated in the body.

min -9007199254740991 · max 9007199254740991

- `detail`stringrequired

What went wrong in this request.

- `code`stringrequired

Stable snake\_case error code. Match on this, not on \`detail\`.

- `pointer`string

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

- `details`object

Machine-readable context keyed by the error code.

- `suggestions`string\[\]

Recovery steps safe to show to a person.

- `next`string\[\]

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

- `requestId`stringrequired

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

`spaceId`path*`window`query—48h7d30d

### Send

## Request

### cURL

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

### JavaScript

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

### Python

```python
import requests

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

## Response

### 200default

```json
{
  "$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
      }
    ]
  }
}
```

```json
{
  "$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"
}
```
