Expand my Community achievements bar.

SOLVED

Retrieve All Segments using API

Avatar

Level 2

Hello to everyone,

I cannot find a way to retrieve all segments using the Endpoint Segment API. The request returns only a few segments without any particular reason. 

 

For example, given two segments (from the same Report Suite, created by the same person (me) and containing the same dimensions) one is extracted and the other is not.

Can anyone help me with this? What other characteristic of the segment could affect the API response?

Thank you in advance!

 

This is the request:

headers = {
    'Accept': 'application/json',
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json',
    'x-api-key': CLIENT_ID,
    'x-proxy-global-company-id': global_company_id,
}

params_seg1 = {
'expansion':'reportSuiteName,ownerFullName,modified,tags,compatibility,definition,publishingStatus,definitionLastModified,categories'
}

url = f"https://analytics.adobe.io/api/{global_company_id}/segments"
response = requests.get(url, params=params_seg1, headers=headers)

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

API
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Have you tried using the API Swagger tool and documentation.. it looks like there is a way to pass a limit, you could increase that limit to something high enough to achieve your needs...  or make multiple calls to pull back group 1, then group 2, then group 3, etc by page

 

https://adobedocs.github.io/analytics-2.0-apis/#/Segments/segments_getSegments 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Have you tried using the API Swagger tool and documentation.. it looks like there is a way to pass a limit, you could increase that limit to something high enough to achieve your needs...  or make multiple calls to pull back group 1, then group 2, then group 3, etc by page

 

https://adobedocs.github.io/analytics-2.0-apis/#/Segments/segments_getSegments 

Avatar

Level 2

Thank you! I just needed to add "limit:400" to parameters of the API request and it pulled all the segments.

 

Have a good day!

Avatar

Community Advisor

Yay, glad you are sorted out.

 

Glad you have less than 400 segments.. if you had something like 2000, then you might have wanted to use the "page" option

Avatar

Level 2

Thank you for the advice, fortunately I added a tag to all the segments I needed and I passed the tagNames to the request in order to pull them