What is the differences of 'line_item_id' in campaign ,line_item and promoted_tweets?



Hi, im trying to fetch campaign name and creative (promoted tweet )

But i can not match campaign name with each creative(promoted tweet).

Does anyone know how to do this?

Here is my code.

app_card_id_url ='/1/accounts/{}/cards/image_app_download'.format(account.id)

#get campaign id and name and put into list
campaign = Request(client, 'get', campaign_url).perform().body['data']
for c in campaign:
    #result is like this   {'campaign_name':'aaa','campaign_id':1234}

#get line_item id and put into list
line_item_res = Request(client, 'get', line_item_url).perform().body['data']
for i in line_item_res:
    line_itme_d['line_item_id']=i['id'] #line_item id

    #result is like this   {'campaign_id':1234, 'line_item_id':'0001'}

# get card-id and put into list
card_id_res = Request(client, 'get', card_id_url).perform().body['data']
for c in card_id_res:
    cr['creative_id']=c['id']  #card id

    #result is like this   {'line_item_id':001, 'creative_id':'z1b1'}

#collection of campaign_id and name, list_item_id
#this code match each 'id' by layer 
for x in campaign_list:
    for y in line_item_list:
        if x['campaign_id']  == y['campaign_id']:
            x.update({'line_item_id': y['line_item_id']})
            for c in creative_list:
                if y['line_item_id'] == c['line_item_id']:
                    x.update({'creative_id': c['creative_id']})



Hi, @quicknewsofapps. Thanks for your question.

You can do this as follows.

  1. Use the GET accounts/:account_id/campaigns endpoint to retrieve the details for your campaigns—you might have to use the cursor parameter to get more results—and find the campaign ID (listed as id in the response) you’re interested in.
  2. Use the GET accounts/:account_id/line_items endpoint to retrieve the line item details associated with the campaign you identified in 1. Do this by setting the campaign ID as the value for the campaign_ids parameter. This limits the results to just the line items associated with that campaign. The line item IDs are listed as id in the response.
  3. Use the GET accounts/:account_id/promoted_tweets endpoint to retrieve the references promoted tweets associated with the line items you identified in 2. Use the line item ID(s) as the values for the line_item_ids parameter. The result looks something like this:
  "request": {
    "params": {
      "account_id": "xxxxx",
      "line_item_ids": [
  "data": [
      "line_item_id": "aaaa",
      "display_properties": [],
      "id": "b1b1b",
      "paused": false,
      "created_at": "2016-09-01T00:00:00Z",
      "updated_at": "2016-09-01T00:00:00Z",
      "approval_status": "ACCEPTED",
      "tweet_id": "{tweet_id}",
      "deleted": false
  "data_type": "promoted_tweet",
  "total_count": 1,
  "next_cursor": null

You can then use the tweet_id and the GET statuses/show/:id endpoint to retrieve the tweet details.

$ twurl -H api.twitter.com "/1.1/statuses/show.json?id={tweet_id}" 

Hope this helps!


Thanks for your response.

And I have additional question about promoted_tweet.

I retrieve 39 campaign and line_item ID but I just got 35 promoted tweet.
We have inserted into 50 or more ads(of course as promoted_tweet).

Do you know why i can not retrieve 50 or more ads information which i have inserted?

p2 = {
    'entity_ids': list_of_lineitem, #this "list_of_lineitem" is list of 39 line itmes
    'entity': 'PROMOTED_TWEET',
    'start_time': param['START_TIME'],
    'end_time': param['END_TIME'],
    'granularity': 'TOTAL',
    'metric_groups': param['METRIC'],
    'placement': 'ALL_ON_TWITTER',

 sync = Request(client, 'get', card_id_url,params=p2).perform().body['data']

I got 35 data with this code.



@quicknewsofapps: We need more information before we can start looking into this. We need:

  • the account ID
  • the list of campaign IDs you’re interested in
  • the list of line item IDs you’re seeing from your requests
  • the 35 promoted tweet IDs you’re seeing


@quicknewsofapps: Just following up to see if we can help.