Community Discussion
JSON Error when calling API in Python
Hey all,
New to this API and testing it out, but I'm having some issues returning some fairly basic data from my account using Python and reading it via a json command. Here's a very simple code and the error I'm getting:
```
account_id = account_response.json()['results'][0]['id']
account_url = url + "/api/1.0/api/1.0/{account_id}/campaigns/base".format(account_id = account_id)
campaigns_response = requests.get(account_url, headers=headers)
campaigns_response.json()
```
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I'm not sure why this is happening, as when I run campaigns_response.ok, I get a 'True' return. Also, when I run a simple call to get my account details:
```
headers = {'Authorization': f'Bearer {access_token}'}
account_response = requests.get(url + '/backstage/api/1.0/users/current/allowed-accounts/', headers=headers)
```
This runs fine.
Any help/insight would be much appreciated.
Thanks!
Posted by Miguel 5 months ago
Taboola to Google Sheet Script
Hi there,
Is there a script available that I can use within Google Sheets to import campaign data such as costs on an hourly/daily basis from my Taboola Ad account? If so I'd be very grateful if someone could share this with me :)
Posted by Matt Seldon about 3 years ago
upload picture
Calling with Python https://backstage.taboola.com/backstage/api/1.0/operations/upload-image Interface upload image, no return value
Posted by lee over 3 years ago
How to extract revenues by publisher with Python Script (split by platform)
Hello all,
I have this script to extract my campaign data splited by plateform (see bellow).
But now, I want to know how to extract the revenues earn by my publisher.
Do you knwo how I can do that ?
___________________________
My Script :
client_id =XXXXXXXXXXX
client_secret = XXXXXXXXXXXXX
start_date = "2021-06-08"
end_date = "2021-06-08"
account_id = "XXXXXXXX"
dimension = "content_provider_breakdown"
folder_path = r"/Users//Documents/"
url = "https://backstage.taboola.com/backstage/oauth/token"
payload = f"client_id={client_id}&client_secret={client_secret}&grant_type=client_credentials"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("POST", url, data=payload, headers=headers)
data = response.json()
access_token = data["access_token"]
url = f"https://backstage.taboola.com/backstage/api/1.0/{account_id}/reports/campaign-summary/dimensions/{dimension}"
url = f"https://backstage.taboola.com/backstage/api/1.0/{account_id}"
querystring = {"start_date":start_date,"end_date":end_date,"platform":"DESK"}
bearer = f"Bearer {access_token}"
headers = {"Authorization": bearer}
response = requests.request("GET", url, headers=headers, params=querystring)
data = response.json()
_____________________________
Posted by Charles M. over 3 years ago
Export Datas from Python using your API.
Hello,
I would like to know how to export datas from taboola using your API through Python.
Do you have a script wich allows me to extract datas directly from a Jupyter Notebook.
There is some informaiton on this site but i'm not a developper, just a data analyst:
https://github.com/dolead/pytaboola
(Currently I use the export button then I clean and export datas using python with numpy and pandas library but I don't know how to directly export data from a notebook using your API)
Thank you in advance,
Charles Martinaud
Posted by Charles Martinaud over 3 years ago