Calling the Analytics Reporting API

Prereqs

Like most of our APIs, you will need to know the environment and companyId in order to properly call our RESTful endpoints. If you are unsure of these values, you can retrieve them:

curl -XGET \
  https://api.spredfast.com/v1/me \
  -H 'Authorization: Bearer <accessToken>'


{
  "data": {
    "sfEntityType": "User",
    "email": "[email protected]",
    "companies": [
      {
        "sfEntityType": "AvailableCompany",
        "id": "123",
        "name": "Your Company",
        "environment": "Production"
      }
    ]
  },
  "status": {
    "succeeded": true
  }
}

Locate the company from which you wish to download a report, and use its environment as the {env} and ids the {companyId} for all API RESTful paths. You can find instructions for obtaining your accessToken can be found in a previous blog post.

Generating stream item exports

Stream item reports are created through the Stream Item Data endpoint.

The snippet below gives an example request which generates a report and notifies a user via email when it is ready to download. For more information on the request arguments, or additional APIs, please see the v2 docs:

curl --location --request POST 'https://api.spredfast.com/v2/analytics/export/stream_items?format=csv&header=true&delimiter=,&email_recipients=<email>' \
--header 'Authorization: Bearer <accessToken>' \
--header 'Content-Type: application/json' \
--data-raw '{
     "query": {
          "start":"2021-05-01",
          "stop":"2021-05-02",
          "use_action_date": "false",
          "only_responded_items": "false",
          "fields": [47,51]
     }
}'

Did this page help you?