APICampaign Id vs UI Id


#1

Hello everyone.

I was trying to implement a direct access from my dashboard developed with Twitter Ads API to Twitter Ads UI, but real campaign ID is not equal to campaign id in query string request.

Could you give me more information about this in order to make the relationship

Regards, Hector


#2

Hi Hector,

I was about to post the same question this morning.

Twitter Ads UI has Ids like 10549403 for a Twitter Campaign.
Twitter Ads API has Ids like kvtm for a Twitter Campaign.

It would be nice if twitter provided some kind of translator between the two sets of IDs.


#3

Hey @chris_august7

The campaign id’s are base64 encoded, so a campaign id like kvtm will be mapped to an integer value of 974362 as opposed to 10548403

Hope that helps!


#4

Okay… I’ll try that out. Thanks! That’s great info.


#5

Hey @chris_august7,

Just wanted to correct a mistake from earlier, the campaign id’s on the API are base36 encoded, not base64. You can find more details on our campaigns page.

Thanks!


#6

Based on the values you provided earlier (kvtm == 974362), this code provides a bidirectional mapping that works. Thanks!

# convert from UI to API
Long uiId = 974362;
BigInteger bigInteger = BigInteger.valueOf( uiId );
String apiId = bigInteger.toString(36).toLowerCase();

# convert from API to UI
String apiId = "kvtm";
BigInteger bigInteger = new BigInteger(apiId, 36);
String uiId = bigInteger.toString();

#7

Excellent, glad to hear the issue has been resolved!


#8

@imit8me Thanks for confirming this regarding the campaign ID. But is this the case with all other IDs? We are seeing the same issue with promoted tweet id and account id (API results base-36 while UI is base-10).

Although this is documented for the campaign ID [https://dev.twitter.com/ads/campaigns], I do not see that is the case for the other IDs. Could you confirm that is the case with the above mentioned IDs and if there are any other IDs that follow this pattern?

Thanks!
V


#9

@imit8me ~ It would also be good to know if this applies for funding_instrument_id.


#10

Hi @imit8me - have you had a chance to look at this?

Thanks,
V


#11

Hey @chris_august7 & @p_v,

Promoted Tweet id’s, account id’s and funding instrument id’s are all base-36 encoded. All values being passed to the Ads API must be base-36 encoded.

Here is a sample response for a Promoted Tweet:

{
      "line_item_id": "",
      "display_properties": [],
      "id": "wwrbn",
      "paused": false,
      "created_at": "2016-07-22T17:35:47Z",
      "updated_at": "2016-07-22T17:35:52Z",
      "approval_status": "ACCEPTED",
      "tweet_id": "756543231542693888",
      "deleted": false
    }

Please note that while the tweet_id may be in base-10 the Promoted Tweet id, which is the id field in the response object is base-36 encoded. I hope that helps!

Thanks!


#12

Okay, so based on your response, I will assume that all these IDs are base 10 in the Twitter Ads UI and base36 in the Ads API. Thanks @imit8me.


#13

@chris_august7 You’re welcome! Please note that the Ads account_id is always encoded in base-36 for both the UI and the Ads API