- 1 Minute to read
- DarkLight
End-to-end Example
- 1 Minute to read
- DarkLight
This example shows how the implement full data integration flow starting from authorizing the service, creating a source and attaching it to the flow. In this case, Snapchat is used as an example.
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 the example Snapchat authorizer with refresh token flow is used. This requires an independent implementation of OAuth 2.0, so you are able to 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
For creating a source (in this case Snapchat is used) you need to supply ID of the newly created authorizer (returned in the response of the previous step) and couple of other parameters that are specific for each source type.
Parameter | Description |
---|---|
oAuthId | ID of the authorized service. Use value from the reponse of the previous step. |
organizationId | ID of the Snapchat organization. You can use specific API endpoint to retrieve all organization IDs. |
accountId | ID 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 HTTP endpoint.
Request
{
"sources":["63b872052946b21e6d063cb2"],
"app":"google_data_studio",
"label":"GDS Flow"
}
Response
As you can see from the response, API andpoint 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"
}