Bulk data export

The data export API serves as a proxy to a portion of accesso's data lake. Using the API allows the caller to retrieve data to which they have been authorized. This guide provides an overview of the export endpoint and some basic best practices for using the API.

Exporting data

To export data, the following steps are performed:

  1. Acquiring a service token, if a valid/non-expired one is not already in the caller’s possession.
  2. Initiating the export and fetching the first page of results.
  3. Fetching remaining pages of results.

1. Acquiring a service token

See the Service Tokens documentation for instructions on how to obtain a service token.

2. Initiating the export and fetching first page of results

Due to the amount of data which can possibly be returned, the export API returns its results in pages. The maximum number of records returned by any request is 1,000 records. When an export is requested, only the first page of results will be initially returned. Subsequent pages must be explicitly requested.

The following request is used to invoke an export:

1
2
3
4
5
6
7
curl -X GET -G \
  'https://api.{region}.te2.io/v1/export/{dataType}' \
  -d 'startTime={startTime}' \
  -d 'endTime={endTime}' \
  -d 'venueId={venueId}' \
  -H 'Cache-Control: no-cache' \
  -H 'Authorization: Bearer {token}'

Parameters used above include:

A successful request will return the first page of results and a status of 200. The body of the response has the following format:

1
2
3
4
5
6
7
8
9
10
{
  "data": [
    {
      "property1": "value1",
      "property2": "value2"
    }
  ],
  "queryExecutionId": "{queryExecutionId}",
  "nextToken": "{nextToken}"
}

Parameters used above include:

3. Fetching remaining pages of results

To fetch the remaining pages of results, if any exist, the following request is used:

1
2
3
4
5
6
curl -X GET -G \
  'https://api.{region}.te2.io/v1/export/{dataType}' \
  -d 'queryExecutionId={queryExecutionId}' \
  -d 'nextToken={nextToken}' \
  -H 'Cache-Control: no-cache' \
  -H 'Authorization: Bearer {token}'

Parameters used above include:

A successful request will return a response in the same format as the initial page of results.

Retrieval flow

This is a general example of what an export looks like using the above steps. Your exact set up may differ slightly, however the basic flow will most likely remain the same.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Fetch a service token.
service_token <- fetch_service_token()

# Fetch the initial page of results.
result_page, query_execution_id, next_token <- fetch_first_page(
    service_token,
    start_time,
    end_time,
    venue_id
)

# Store the first page of results.
results <- result_page

# So long as there are additional pages, keep retrieving data
# and appending the returned data to the result set.
while next_token != null do:
  result_page, query_execution_id, next_token <- fetch_next_page(
      service_token,
      query_execution_id,
      next_token
  )

  results <- results + result_page
end while

# Return your exported data.
return results

Rules governing export request parameters

Violating any of the following will result in a returned status of 422:

Best practices

  Do:

  Don’t: