Samion
Samion

Reputation: 105

Azure-devops rest api - pagination and rate limit

I am trying to pull Azure-Devops entities data (teams, projects, repositories, members etc...) and process that data locally, I cannot find any documentation regarding rate-limiting and pagination, does anyone has any experience with that?

There is some documentation for pagination on the members api:
https://learn.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/members/get?view=azure-devops-rest-6.0

But that is the only one, i couldn't find any documentation for any of the git entities,
e.g: repositories.
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/list?view=azure-devops-rest-6.0

If someone could point me to the right documentation, Or shed some light on these subjects it would be great.

Thanks.

Upvotes: 7

Views: 10573

Answers (3)

Ben Hulan
Ben Hulan

Reputation: 557

It looks like you can pass $top and continuationToken to list Azure Git Refs.

The documentation is here:

https://learn.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-6.0

Upvotes: 1

Ankit Prasad
Ankit Prasad

Reputation: 51

I think for most of the apis you have query parameter as $top/$skip.You can use these parameter to do pagination. Lets say the default run gives 200 documents in the response. For the next run skip those 200 by providing $skip=200 in the query parameter of the request to get the next 200 items. You can keep on iterating until count attribute of the response becomes 0.

For those apis were you don't have these parameter you can use continuation-token as mentioned by Leo Liu-MSFT.

Upvotes: 3

Leo Liu
Leo Liu

Reputation: 76928

I cannot find any documentation regarding rate-limiting and pagination, does anyone has any experience with that?

There is a document about Service limits and rate limits, which introduced service limits and rate limits that all projects and organizations are subject to.

For the Rate limiting:

Azure DevOps Services, like many Software-as-a-Service solutions, uses multi-tenancy to reduce costs and to enhance scalability and performance. This leaves users vulnerable to performance issues and even outages when other users of their shared resources have spikes in their consumption. To combat these problems, Azure DevOps Services limits the resources individuals can consume and the number of requests they can make to certain commands. When these limits are exceeded, subsequent requests may be either delayed or blocked.

You could refer Rate limits documentation for details

For the pagination, generally, REST API will have paginated response and ADO REST API normally have limits of 100 / 200 (depending which API) per page in each response. The way to retrieve next page information is to refer the response header x-ms-continuationtoken and use this for next request parameter as continuationToken.

But Microsoft does not document this very well - this should have been mentioned in every API call that supports continuation tokens:

Builds - List

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&continuationToken={continuationToken}&maxBuildsPerDefinition={maxBuildsPerDefinition}&deletedFilter={deletedFilter}&queryOrder={queryOrder}&branchName={branchName}&buildIds={buildIds}&repositoryId={repositoryId}&repositoryType={repositoryType}&api-version=5.1

If I use above REST API with $top=50, as expected I get 50 back and a header called "x-ms-continuationtoken", then we could loop output the result with continuationtoken:

enter image description here

You could check this similar thread for some more details.

Upvotes: 7

Related Questions