Adwords API Python retrieve user list id of existing audience

262 views
Skip to first unread message

fran...@leadsmarket.com

unread,
Apr 5, 2019, 3:02:29 PM4/5/19
to AdWords API and Google Ads API Forum
Hello,

I'm having trouble finding the information I need to retrieve a listid from AdwordsUserList Service. I see how to create a new list and retrieve the id as shown, below:

user_list = {
'xsi_type': 'CrmBasedUserList',
'name': audience_name + ' ' + str(uuid.uuid4()),
'description': 'A list of customers that originated from email addresses',
'membershipLifeSpan': 10000,
'uploadKeyType': 'CONTACT_INFO'
}

# Create an operation to add the user list.
operations = [{
'operator': 'ADD',
'operand': user_list
}]

result = self.user_list_service.mutate(operations)
user_list_id = result['value'][0]['id']


But if I already have a list and only want to retrieve the user_list_id of an existing list, how do I do that?

Thanks

googleadsapi...@google.com

unread,
Apr 5, 2019, 4:42:05 PM4/5/19
to fran...@leadsmarket.com, AdWords API and Google Ads API Forum
Hello Francisco, 

You may use the AdWordsUserListService.get() operation to pull the User list Id. If you're using the Google Ads API, you can use the User List resource to pull the Id. Let me know if you have any other questions.

Regards,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Akashdeep Singh

unread,
Jun 13, 2020, 9:48:34 PM6/13/20
to AdWords API and Google Ads API Forum
Hey there,

It took bit of time to understand how to set it up, but in future it will be helpful for others who try doing it. Note the name Id needs to have uppercase I and same with Name it needs to have uppercase N, which is pretty strange because you do not need when adding it.

Read : https://developers.google.com/adwords/api/docs/reference/v201809/AdwordsUserListService.Selector <- Under fields, all the possible fields available. 

user_list_selector = client.GetService('AdwordsUserListService', 'v201809')

CustomerServiceSelector = {
'fields': ['Id'],
"predicates": [{
"field": 'Name',
"operator": "EQUALS",
"values": ["Your_custom_audience_name"]
}],
}

result = user_list_selector.get(CustomerServiceSelector)
entries = result['entries']
id_of_audience = entries[0]['id']
print(id_of_audience)

Best Regards,
Akash
Reply all
Reply to author
Forward
0 new messages