Azure DevOps REST API call retrieving only 100 records - azure-devops

I am using the below url for retrieving all the CouldTests, but it is returning only top 100 records. Is it possible to retrieve all the records?.
http://{instance}/{collection}/{project}/_apis/test/runs?api-version=5.0
Any help is appreciated. Thanks in advance
For more about the above Link please refer.:https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/list?view=azure-devops-server-rest-5.0

it is returning only top 100 records.
This is because
On large collections, performance degrades when retrieving the later pages.
To avoid stress on the server, 100 is the default page size of REST api response which you can refer to REST API Result limit.
Is it possible to retrieve all the records?
Yes, as #Shayki Abramczyk said, the solution is to add a top parameter to select the top n records, make sure the n is bigger than the total amount of your all records.
For this solution, you can also check Limited to 100 result TFS api and Azure DevOps REST API: project count returned limited to 100.

You can use the $top parameter in the URL:
http://{instance:/{collection}/{projects}/_apis/test/runs?api-versopn=5.0&$top=500

Accepted answer was not working for me. Probably they have changed the parameter name from $top, to searchCriteria.$top.
If that is not working, try this instead:
https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits?searchCriteria.$top=1000&api-version=6.0
Documentation:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-commits?view=azure-devops-rest-6.0

Related

How to get ALL communities from DSpace rest api

Using the endpoint:
GET https://mydspace.org/rest/communities/
I seem to only get 100 results returned. I can't see any options in the documentation to return more. How do I do this?
Most of the DSpace rest endpoints support a limit parameter. I suppose that there is some maximum size that you can request, but the limit should be able to go higher than 100.
https://demo.dspace.org/rest/communities?limit=500
If you still are unable to retrieve everything in one request (or if you timeout), you can paginate through the results in your code.
https://demo.dspace.org/rest/communities?limit=100
https://demo.dspace.org/rest/communities?offset=100&limit=100
https://demo.dspace.org/rest/communities?offset=200&limit=100
There is an endpoint (in DSpace 6) that will allow you to retrieve the ids and handles for the full hierarchy.
https://demo.dspace.org/rest/hierarchy
It's not very prominent, but pagination of REST responses is documented at https://wiki.duraspace.org/display/DSDOC6x/REST+API#RESTAPI-RESTEndpoints just above "Index / Authentication".

Possible to specify date_preset with insights edge in Facebook Ads API?

For the Marketing API, I know that I'm able to make one call to retrieve all of the adsets from a certain account along with their insights, but am I able to specify the date_preset for the insights edge in that same call?
For example, the following gives me lifetime insights stats:
/v2.4/{accountID}/adcampaigns?fields=insights
To be clear - I know this is possible to retrieve by making separate calls for each adset id (where I know I can specify the date_preset); instead, I'd like to do this via the call where I get a long list of the ad sets plus their insights details in one go.
Yes this is possible using query expansion, however you probably should not do it in this anyway.
Using query expansion results in multiple requests being executed in one HTTP call, in this case one to get all the adcampaigns, and then N requests where N is the number of adcampaigns returned. This will in turn affect your rate limiting.
The most efficient way to request all insights for all adcampaigns (ad sets) is instead to request them at the account level, specifying aggregation level:
/v2.4/act_{ADACCOUNT_ID}/insights?date_preset=last_7_days&level=campaign
This requires just 1 request, or the number of requests to retrieve the total number of pages.
If you really want to achieve this with query expansion, you can do the following for example:
/v2.4/act_{ADACCOUNT_ID}/adcampaigns?fields=insights.date_preset(last_30_days).time_increment(all_days)
You can see the parameters to insights that would normally be query parameters of the form param_name=param_value are now in the form of param_name(param_value).
To specify the date_preset , here is the correct format . Its important to use insights as edge to get the date_preset filtering .
/v2.10/act_{ADACCOUNT_ID}/insights?fields=impressions,clicks,ctr,unique_clicks,unique_ctr,spend,cpc&date_preset=last_3d
The above one is tested with latest Graph Api version(2.10) as of now . FOr more info related to the date_preset values refer to there api docs .
https://developers.facebook.com/docs/marketing-api/insights/parameters

Facebook Graph API search limit & offset

I want to do a query like this:
search?q=KEY_NAME&type=page&fields=id,name,location&limit=500&offset=0
when I do this the first time the result is about 470 results, now I put offset to 471 and repeat the query
search?q=KEY_NAME&type=page&fields=id,name,location&limit=500&offset=471
and the result is empty.
Why? The key_name is a famous word like "fan" and I don't think that there are only 471 results on fb pages!
What is the problem?
Never use a limit that high, afaik a limit of 100 should be the maximum. Everything else may be buggy. If you use this API call, you get more than 500 with paging:
/search?pretty=0&fields=idmname,location&q=fan&type=page&limit=100
Don´t use "offset", always use the "next" link in the JSON document to get the next batch of results: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#paging
The next 100 entries would be available with the following endpoint for me:
/search?pretty=0&fields=idmname,location&q=fan&type=page&limit=100&after=OTkZD
Please refer to this following blog post in which it says
https://developers.facebook.com/blog/post/478/
gist of it.
As such, when querying the following tables and connections, use time-based paging instead of “offset” to ensure you are getting back as many results as possible with each call. For these Graph API connections, use the “since” and “until” parameters

Can response data from core reporting api be grouped?

Explanation:
I am able to query the Google Core reporting APIv3 using the client library to get data on pageviews for specific URLs of a website I am working on. I want to get data(pageviews) for each day within a specified range. So far I am simply looping through the range, sending individual request to the API. in each request I am setting the same value for the start date and the end date.
Problem:
Obviously this gets the job done, BUT it is certainly not the best way to go about it. Because, assumming I want to get data for the past 3 months for each of about 2000 URIs. Then I will need 360000 number of requests and that value is well over the limit quota defined by Google.
Potential solution: So one way I thought of solving this issue is probably to send a request setting start-date and end-date to be a week apart but the API will return a sum of the values rather than the individual values.
main question: So is there a way to insist that these values should not be added up and returned as a sum but rather returned (as associative array or something like that) separately for each.
I hope the question is clear and that there is a solution! Thank you!
Very straightforward:
Metric: ga:pageview, Dimension: ga:date, Set a filter for your pagepath, and set a start-date and end-date.
Example:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3Axxyyzz&dimensions=ga%3Adate&metrics=ga%3Apageviews&filters=ga%3Apagepath%3D%3D%2Ffaq.html&start-date=2013-06-27&end-date=2013-07-11&max-results=50
This will return the pageviews for that the faq.html& page for each day in the time-frame.
You should check out the QueryExplorer. Great tool to find out how to structure queries.

Query multiple insights metrics in one API call

Is it possible to query more than one insights metric in one API call?
For example to get the daily added likes for a page I executed the following call:
https://graph.facebook.com/_object_id_/insights/page_fan_adds_unique/day/
But I would like to have another metric, e.g., page_fan_removes_unique, included as well.
Query the insights object entirely is a possibility, but gives me too much data I don't need, thus decreases performance.
Since your question shows that you're using the Graph API, you may want to use the batch requests method: http://developers.facebook.com/docs/reference/api/batch/
You can group multiple Graph API queries together so you can just query the Insights data you need in one request.
Yes, you can run a multiple FQL query in one API call and then parse the various results.
multi query: http://developers.facebook.com/docs/reference/rest/fql.multiquery/
insights table: http://developers.facebook.com/docs/reference/fql/insights/