Skip to content

CSV Promise

The high-volume asychronous version of /csv. Send a csv, which is queued and processed. This is the preferred method for processing large csvs.

Users can access the calculated data via the /csvpromise/{id} endpoint. If the csvpromise is ready, this endpoint will return the csvpromise's result.

Create new CSV Promise

Create a new csvpromise. This will return a csvpromise id, which can be used to check the status of the csvpromise, and to retrieve the result.

Endpoint

https://api.good-loop.com/v0/csvpromise/new

Method

POST

Parameters

Name Description Type Required
schema Use for special schemas, like "meta" (for reports from Facebook and Instagram) string No
store Set true to store the rows in your Green Dashboard account boolean No
callback If provided, this will be called with the completed csv when ready string No

Request Body

A csv file, which MUST have the columns: domainformatcountry, and can have any other columns (see the /score endpoint for details). Arbitrary other columns can also be included - these don't affect the calculation and are simply returned as part of the rows.

Example contents of a csv file

date domain,device,country,region,impressions,format
2023-08-14,example.com,mobile,US,NY,1000,video
2023-08-14,example.com,desktop,US,CA,500,display

Example

curl --header 'Authorization: token <your-api-key>' \
--location 'https://api.good-loop.com/v0/csvpromise/new' \
--form 'csv=@"example_report.csv"'
curl --header 'Authorization: token <your-api-key>' \
--location 'https://api.good-loop.com/v0/csvpromise/new?schema=meta' \
--form 'csv=@"meta-report-sample.csv"'

Response

{
  "id":"csvpromise_xxxxxxxx"
}

Get CSV Promise

Get the status of a csvpromise. If the csvpromise is complete, then the result will be returned.

Endpoint

https://api.good-loop.com/v0/csvpromise/<id>

Method

GET

Example

curl --header 'Authorization: token <your-api-key>' \
--location 'https://api.good-loop.com/v0/csvpromise/<id>'

Reponse

date,domain,device,country,region,impressions,format,co2,co2_publisher,co2_creative,co2_supply,domain_measured
2023-08-14,example.com,mobile,US,NY,1000,video,2.1518886558426544,0.043978239569060586,1.2982668914200781,0.8096435248535158,false
2023-08-14,example.com,desktop,US,CA,500,display,1.6443849069161116,0.033606363964861184,0.9920822230293751,0.6186963199218751,false