The Cervinodata API is a flexible and powerful way to bring the data from all your ad platforms and Google Analytics views together in your own application, (python) code or Klipfolio dashboard.
It also includes a couple of handy ways of creating dynamic data ranges. If you want to do more advanced stuff, check out the PHP reference page here, but to start simple, you can find some common use cases here.
This is what the api end point looks like
https://app.cervinodata.com/api/v1/data/ad-campaign-report-per-day/[organisation UUID]?from_date=2020-01-01&date_format=YYYY-MM-DD&format=csv
Changing the from date to a rolling date
The from date (shown as from_data=2020-01-01 in the example above) is now a fixed date. But there are multiple ways to change this to a rolling date.
Here are some common use cases
Rolling 30 days
When should you use this? When the number of records in your report is high (or when you only want to see the current status + a brief history to see some context).
- In url the string: ...?from_data=30 days ago?&date_format=YYYY-MM-DD&format=csv
- This way the api end point will only take into account only the last 30 days in your dashboard. Same applies for any other number of days.
Rolling years
When should you use this? This is very handy if you want to compare this years results with the result of last year, but you do no not want to keep your file growing and growing.
- If you want the data from January 1st of last year, use this: first day of january last year
- In the url string: ...?from_data=first day of january last year?&date_format=YYYY-MM-DD&format=csv
- Please note that If you do not include the name of the month, the url will also give you the data from last year, but starting from the first day of the current month. So, in april, it gives back data from April 1st of 2019.
- And please note that it can only show data if there is historic data available in the database.
- The same applies for first day of this year. It will give back data from April 1st of 2020, so if you want to have the data from Jan 1st of 2020, you should say: first day of january this year
Rolling months
When should you use this? This is very handy if you want to compare this months results with the result of last month, but you do no not want to keep your file growing and growing. Using this command for large data files can significantly improve the speed of your application or dashboard
- In url string: ...?from_data=first day of last month?&date_format=YYYY-MM-DD&format=csv
- This will give you the data starting from the first day of the last month. So, in April, it gives back data from March first of 2020.
- The same applies for first day of this month. It will give back data from April 1st of 2020 (in April, and for 1st of May in May, etc..)
Rolling weeks
- If you say Monday last week it will give you the data starting the Monday of the previous week.
- If you say 2 weeks ago it will look 14 days back.
- If you say Monday 2 weeks ago it will exclude the current week and then count back 2 weeks. It will give back the data starting from the Monday of that month.
- If you want to get the data of last week, starting on Monday, you can use Monday last week or Sunday last week