Complete noobie question here. I'm trying to access the REST API for ExactTarget to access Campaign data and open / clicks etc using Python

I have installed the FuelSDK and can perform requests such as those found on GIT here.

This post references the REST/SOAP api to connect campaigns with clickers.

Can anyone tell me how to access the REST urls in Python?


Please read exacttarget api reference

You couldn't access resources without authorization. First you should request for an Access Token:

import json, requests


payload = {
    'clientId': client_Id,
    'clientSecret': client_Secret

url = "https://auth.exacttargetapis.com/v1/requestToken";

r = requests.post(url,

body = json.loads(r.content)
token = body["accessToken"]
expiresIn = body["expiresIn"]
print token

Now you can access your resources using Access Token:

url="https://www.exacttargetapis.com/hub/v1/campaigns?$page=1&$pageSize=2&$orderBy=Name ASC"

r = requests.get(url, headers = {"Authorization":"Bearer " + token})
print r.content

Before using Python, I recommend you to try Postman, it will help you to understand requests etc.

| improve this answer | |
  • I dont have access to exacttarget , please add here errors if you have any – Ilya Lepesh May 5 '16 at 16:29

You have several options. If you absolutely want to use python, there are several libraries that can help you achieve this. two of them are simple-salesforce and Beatbox.


here is an example using beatbox:

import beatbox

"salesforceusername and password"
username = 'yourUsername'
password = "yourPassword"
token    = 'yourToken'

svc = beatbox.PythonClient()
svc.login(username, password+token)

"""Simple SOQL query that returns all cases"""
res = svc.query("SELECT id FROM case")


you can equally use this library to create/uptade or simply access Sobjects.

If you decide to use python, be carefull with the version you are using. I did the above using python2.7

| improve this answer | |

You can use simple-salesforce pip install simple-salesforce

from simple_salesforce import Salesforce

email = user@gmail.com
password = 'your_password'
security_token = 'admlnlkrsl'

sf = Salesforce(username=email, password=password, security_token=security_token)

Where to find security token?

In SalesForce, using Lightning Theme:

  1. Click in the top right corner your profile icon -> Settings;
  2. In the tree select My Personal Information -> Reset My Security Token;
  3. Click Reset Security Token;
  4. Check your email for a new token.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.