# Export analytics data

Source: https://swapcard.dev/analytics-api/export/download


Download the raw actions users performed in your events, as a stream of JSON lines you can load into your own tools.

## Before you begin

- An API key created in Swapcard Studio, sent in the `Authorization` header. See [Authentication](/organizer/authentication).
- The IDs of the events you want to export.

## Send an export request
Send a `POST` request with the event IDs and a time range. Both `time_gt` and `time_lt` are required.

```bash title="Request"
curl -X POST 'https://developer.swapcard.com/event-admin/export/analytics' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <TOKEN>' \
  -d '{
    "event_ids": ["RXZlbnRfMQ==", "RXZlbnRfMg=="],
    "time_gt": "2022-09-01T00:00:00.000Z",
    "time_lt": "2022-10-01T00:00:00.000Z"
  }'
```

:::note
Actions are delayed by 10 minutes: the most recent action returned occurred at least 10 minutes ago.
:::

## Request body

<HttpParameters
title="Request body"
params={[
  {
    "name": "event_ids",
    "type": "string array",
    "description": "The IDs of the events in which the actions occurred.",
    "label": "Required"
  },
  {
    "name": "time_gt",
    "type": "string",
    "description": "RFC 3339 date-time. Only actions that occurred after this timestamp are returned.",
    "label": "Required"
  },
  {
    "name": "time_lt",
    "type": "string",
    "description": "RFC 3339 date-time. Only actions that occurred before this timestamp are returned.",
    "label": "Required"
  },
  {
    "name": "cursor",
    "type": "string",
    "description": "Starting position for consecutive calls. Use the cursor of the last row you received."
  },
  {
    "name": "events",
    "type": "string array",
    "description": "The action types to return, such as exhibitor_show or meeting_create. See the action type pages for the full list."
  },
  {
    "name": "group_ids",
    "type": "string array",
    "description": "Only return actions triggered by users in these event groups."
  },
  {
    "name": "user_ids",
    "type": "string array",
    "description": "Only return actions triggered by these users."
  },
  {
    "name": "exhibitor_ids",
    "type": "string array",
    "description": "Only return actions triggered by these exhibitors."
  },
  {
    "name": "limit",
    "type": "integer",
    "description": "Maximum number of rows streamed. Default is infinite."
  },
]}
>
</HttpParameters>

## Read the response stream
A successful response is a stream of newline-separated JSON objects, ordered from the least to the most recent. Each line is one action. Without a `limit`, the stream is potentially infinite, so process it line by line.

```json title="Response"
{"cursor":"eyJFeGVtcGxlQ3Vyc29yIjogMX0=","time":"2020-09-04T15:00:17.737Z","event":"people_view_search","platform":"web-user","event_id":"RXZlbnRfMQ==","properties":{"query":"market","event_view_id":"RXZlbnRWaWV3XzA="},"user_id":"VXNlcl8w","group_ids":["RXZlbnRHcm91cF8w"]}
{"cursor":"eyJFeGVtcGxlQ3Vyc29yIjogMn0=","time":"2020-09-04T15:00:17.961Z","event":"exhibitor_show","platform":"android","event_id":"RXZlbnRfMQ==","properties":{},"user_id":"VXNlcl8x","group_ids":["RXZlbnRHcm91cF8w","RXZlbnRHcm91cF8x"],"exhibitor_ids":["RXhoaWJpdG9yXzA="],"with_exhibitor_ids":["RXhoaWJpdG9yXzE="]}
```

<HttpParameters
title="Response schema"
params={[
  {
    "name": "cursor",
    "type": "string",
    "description": "Stream row cursor. When you call the endpoint with this cursor, it returns all the rows that come after it."
  },
  {
    "name": "event",
    "type": "string",
    "description": "Action name. See the action type pages."
  },
  {
    "name": "created_at",
    "type": "string",
    "description": "RFC 3339 date-time when the action occurred."
  },
  {
    "name": "event_id",
    "type": "string",
    "description": "The event in which the action was triggered."
  },
  {
    "name": "user_id",
    "type": "string",
    "description": "The user who triggered the action. Null when the user isn't logged in, for example in guest mode.",
    "label": "Nullable"
  },
  {
    "name": "exhibitor_ids",
    "type": "string array",
    "description": "The exhibitors the user belonged to when they triggered the action.",
    "label": "Nullable"
  },
  {
    "name": "group_ids",
    "type": "string array",
    "description": "The groups the user belonged to when they triggered the action.",
    "label": "Nullable"
  },
  {
    "name": "with_user_id",
    "type": "string",
    "description": "Only for actions performed with another user: the user they interacted with.",
    "label": "Nullable"
  },
  {
    "name": "with_exhibitor_ids",
    "type": "string array",
    "description": "Only for actions performed with another user: the exhibitors that user belonged to when the action was triggered.",
    "label": "Nullable"
  },
  {
    "name": "with_group_ids",
    "type": "string array",
    "description": "Only for actions performed with another user: the groups that user belonged to when the action was triggered.",
    "label": "Nullable"
  },
  {
    "name": "body",
    "type": "object",
    "description": "Action metadata. Its fields depend on the action type; see the action type pages.",
    "label": "Nullable"
  }
]}
>
</HttpParameters>

## Fetch the next actions
To continue an export where you stopped, send the `cursor` of the last row you processed in your next request. The response starts with the actions that come after that row.

## Filter by action type

Pass action names in `events` to export only those actions. Each action type page lists the action names and the fields of their `body`:

- [Page views](actions/views.mdx): page views, searches, filters and session video streams
- [Connections](actions/connection.mdx): connections, connection requests and contacts
- [Meetings](actions/meetings.mdx): meeting requests, meetings and participants
- [Chat](actions/chat.mdx): messages and video calls
- [Bookmarks](actions/bookmarks.mdx): exhibitor, session and product bookmarks
