End-to-End Example
  • 1 Minute to read
  • Dark
    Light

End-to-End Example

  • Dark
    Light

Article summary

This Snapchat end-to-end example demonstrates implementation of a full data integration flow. This includes service authorization, source creation and connection to the flow,

Prerequisites

  • You have obtained an API access, Client ID and Client Secret to your Snapchat app.
  • You have implemented an OAuth 2.0 authorization flow to obtain refresh tokens from the users.

Authorizing a Service

In this example, we use a Snapchat authorizer with a refresh token flow is used.
This method requires an independent implementation of OAuth 2.0 to make sure you can obtain refresh tokens from your users.

Request

POST /services

{
    "service": "snapchat_static",
    "data": {
        "staticKey": "REFRESH_TOKEN",
        "clientId": "YOUR_APP_CLIENT_ID",
        "clientSecret": "YOUR_APP_CLIENT_SECRET"
    }
}

Response

{
    "id":1000
}

Creating a Source

To create a source (in this case Snapchat), the following will be needed:

  • Provide the ID of the newly created authorizer (returned in the response of the previous step)
  • Other parameters specific for each source type
ParameterDescription
oAuthIdID of the authorized service. Use the value generated by the reponse of the previous step.
organizationIdID of the Snapchat organization. You can use specific API endpoint to retrieve all organization IDs.
accountIdID of the Snapchat account. You can use specific API endpoint to retrieve all account IDs.

Request

POST /connectors/snapchat/create-source

{"connectorId":"snapchat","templateId":"index","oAuthId":OAUTH_ID,"organizationId":"ORGANIZATION_ID","accountId":"ACCOUNT_ID","label":"Snapchat Insights","breakdown":"campaign","metrics":["spend","impressions"],"labels":["stats_id","stats_type","stats_start_time","stats_end_time"],"action_report_time":"conversion","swipe_up_attribution_window":"28_DAY","view_attribution_window":"1_DAY","sync_frequency":"day","day_of_week":"2","day_of_month":"1","hour":"3","minute":"25","timezone":"UTC","dateRange":"{{30d1}}","dateRangePreview":"{{30d1}}","search":"","request":null,"type":"snapchat","strategy":"incremental"}

Response

{
  "id": "string",
  "label": "string"
}

Adding a Source to the Flow

In this step, we create a simple flow that sends the data to Google Data Studio via an HTTP endpoint.

Request

{
    "sources":["63b872052946b21e6d063cb2"],
    "app":"google_data_studio",
    "label":"GDS Flow"
}

Response

As you can see from the response, the API endpoint is attached to the flow which allows you to directly access the data.

{
    "label":"GDS Flow",
    "source":[{"source_id":"63b872052946b21e6d063cb2"}],
    "api":{
        "app":"google_data_studio",
        "id":"63c47935b11d93741a0f1583"
    },
    "id":"63c47935b11d93741a0f1582"
}

Was this article helpful?