Data that can be pulled from Ads API



I got Ads API access for my application. But I am unable to pull any data. It throws an error that says: “The Twitter REST API v1 is no longer active. Please migrate to API v1.1.","code”:64. I want to know what data can be pulled by the Ads API and which package is to be used? I already tried Twython and Twitter ads.


Hi @sangs,

I’m quite sure that you’re pulling data from an wrong host.

Could you share with us your request in twurl format?



Hi Borras,

I am a new developer. I started with whatever was available on twitter. Twurl is something I am hearing for the first time. I first registered an application (with our client’s account), got the tokens and applied for access for Ads API. I got the access after 3 weeks. Later I downloaded Twython and started using the basic code. That is when I got the error. Also I tried to pull some data through the console and received an curl command. But I did not understand how to execute that. So I decided to try with python directly



First of all, twurl, -> Is a little program, really similar to curl that allows you to make direct requets to twitter ads api (also for REST api).

You should install it in your computer and set it up, after that, I’d recommend you to try some twurl request against the Twitter Ads API.

You can do it following this link and doing the part called:

Creating a Campaign - Step-by-Step

Later on you can start to try third based libraries as “twython”, but you should make sure you’re pointing the right API endpoint



Thank you. Will try it out. We already have campains in our account NissanDxb. My aim is to pull the campaign data.

Thanks a lot :smiley:


Hello Borras,

I installed twurl, authorized and executed the basic commands like pulling the timeline. It was successful. But I tried to execute the same using twython. It threw the error “Twitter API returned a 401 (Unauthorized), Invalid or expired token”. Can I know why I am getting this error? Also I am still not sure how to execute the curl command I get in the API console.
I am writing the code here:

from twython import Twython, TwythonError

# Requires Authentication as of Twitter API v1.1
twitter = Twython("Access Key", "Access secret", "Consumer key", "Consumer secret")
    user_timeline = twitter.get_user_timeline(screen_name='NissanDxb')
except TwythonError as e:
    print e
print user_timeline

Thanks in advance :slight_smile:


Hi @Sangs I know how twurl works, and how tools that I use works too, I develop in PHP. But I don’t know how twython works. :frowning:


Hi Borras,

Ohh!! Okay. Can you please direct me to someone who uses python on twitter API? Also please let me know if it possible to pull the campaigns data that is available here through this API? Campaigns dashboard


Yes, it’s possible. I do it every 6 minutes :smile:

There’s a library developed by Twitter ->


Wow. I first started with the same package. Got an unauthorized error.

For your reference:

File “c:\Python27\lib\site-packages\twitter_ads-0.2.1-py2.7.egg\twitter_ads\”, line 89, in accounts
_ return Account.load(self, id) if id else Account.all(self)_
_ File “c:\Python27\lib\site-packages\twitter_ads-0.2.1-py2.7.egg\twitter_ads\”, line 46, in load_
_ response = Request(client, ‘get’, resource, params=kwargs).perform()_
_ File “c:\Python27\lib\site-packages\twitter_ads-0.2.1-py2.7.egg\twitter_ads\”, line 74, in perform_
_ raise Error.from_response(response)_
witter_ads.error.NotAuthorized: <NotAuthorized object at 0x2d69c60 code=401 details=[{u’message’: u’This request is not properly authenticated’, u’code’: u’UNAUTHORIZED_ACCESS’}]>

Then I wrote to twitter asking if I can pull the analytics data dashboard (That was also my aim) Andy piper said we cannot pull it through the API anymore, we can download it from the Analytics dashboard . Then i tried pulling the campaign data and I am ending up with the same error :frowning: :cry:


You can pull if you have access to Twitter Ads API (not the REST API).

You should before whitelist your application filling this form :


Yes. I filled the application and got the access almost after 3 weeks. Yet I am not able to pull.


In this case, I don’t know if I can help you.

First of all, try to share with me an easy twurl request related to the Twitter ads API. I’m going to put here an example of a request and of a response. After that, do the same and paste it here :smile:

twurl -H /1/accounts | python -m json.tool


    "data": [
            "approval_status": "ACCEPTED",
            "created_at": "2015-03-26T20:08:15Z",
            "deleted": false,
            "id": "gq0vj7",
            "name": "Sandbox account for @CyberclickAds",
            "salt": "f5a078053515d463117c431f182ab457",
            "timezone": "America/Los_Angeles",
            "timezone_switch_at": null,
            "updated_at": "2015-06-16T12:26:27Z"
    "data_type": "account",
    "next_cursor": null,
    "request": {
        "params": {}
    "total_count": 1

Now is your turn :stuck_out_tongue:


Lol :stuck_out_tongue: Okay. I have pasted my response.

“data”: [],
“data_type”: “account”,
“next_cursor”: null,
“request”: {
“params”: {}
“total_count”: 0

I can see that data is empty. But i am not sure if that is because of my account not being whitelisted or because of my command. I tried to understand your command but I couldn’t. So I ended up copy pasting it :stuck_out_tongue:


Good! It looks like you hace access.

As you can see we made the request against the sandbox environment, made for testing purposes.

If you try this one, we, hopefully, get a response with more content.

twurl -H /1/accounts | python -m json.tool


Yes. I get the response now :slight_smile:

“data”: [
“approval_status”: “ACCEPTED”,
“created_at”: “2014-02-10T11:55:53Z”,
“deleted”: false,
“id”: “18ce53v4otk”,
“name”: “Nissan Dubai”,
“salt”: “76f202efd7df04e74e49cf232c12cfab”,
“timezone”: “Asia/Dubai”,
“timezone_switch_at”: “2014-02-08T20:00:00Z”,
“updated_at”: “2016-04-22T17:31:45Z”
“data_type”: “account”,
“next_cursor”: null,
“request”: {
“params”: {}
“total_count”: 1

Thank you very much :slight_smile: Can you please tell me how can I get the campaign dashboard? And I just want to reconfirm that Analytics dashboard cannot be pulled by ADS API.


So, the thing is that your app is OK and you have access.

You can retrieve stats following this link and making the correct requests.


Hi Borras,
Thank you very much for all your responses. It was a good learning.
I tried using the requests from the link you provided. All that I get is “No JSON object could be decoded”.

I know its difficult for you to troubleshoot my errors. But can you provide me some materials to learn more on Twurl commands?(The internet has very few)

And please reconfirm if we can download the analytics data through this API. Because AndyPiper told me that it can be downloaded only from Gnip. For you ref:


Hi @Sangs!

You get that error because the response turned by Twitter wasn’t a JSON so the “pipe” ( | pyhon -m json.tool) didn’t recognize that, when you get that error try it without the pipe, for example: twurl -H /1/accounts

To learn twurl, best option is try the different options as you can see here:

The important thing is that I think @andypiper was talking about the REST api, not the ADS api . You were in an incorrect forum.



Tried the same command and several other similar commands. The output is

"Usage: twurl authorize --consumer-key key --consumer-secret secret
twurl [options] /1.1/statuses/home_timeline.json

Supported Commands: accounts, alias, authorize, set

Getting started:
-T, --tutorial Narrative overview of how to get started using Twurl

Authorization options:
-u, --username [username] Username of account to authorize (required)
-p, --password [password] Password of account to authorize (required)
-c, --consumer-key [key] Your consumer key (required)
-s, --consumer-secret [secret] Your consumer secret (required)
-a, --access-token [token] Your access token
-S, --token-secret Your token secret

Common options:
-t, --[no-]trace Trace request/response traffic (default: --no-trace)
-d, --data [data] Sends the specified data in a POST request to the HTTP server.
-r, --raw-data [data] Sends the specified data as it is in a POST request to the HTTP server.
-A, --header [header] Adds the specified header to the request to the HTTP server.
-H, --host [host] Specify host to make requests to (default:
-q, --quiet Suppress all output (default: output is printed to STDOUT)
-U, --no-ssl Disable SSL (default: SSL is enabled)
-X, --request-method [method] Request method (default: GET)
-P, --proxy [proxy] Specify HTTP proxy to forward requests to (default: No proxy)
-f, --file [path_to_file] Specify the path to the file to upload
-F, --file-field [field_name] Specify the POST parameter name for the file upload data (default: media)
-b, --base64 Encode the uploaded file as base64 (default: false)
-h, --help Show this message
-v, --version Show version "

I have authorized the account already by executing the commands.
I also verified it using the command: twurl accounts
Output : NissanDxb