简体   繁体   English

ActiveCollab API 分页和速率限制

[英]ActiveCollab API Paginantion and Rate Limit

I cannot find information about API Pagination or Rate limits at https://developers.activecollab.com/api-documentation/我在https://developers.activecollab.com/api-documentation/上找不到有关 API 分页或速率限制的信息

How many calls are we allowed to make and does pagination exists if we are fetching too much data?如果我们获取太多数据,我们允许进行多少次调用,是否存在分页?

Many ActiveCollab API end-points are paginated, but not all.许多 ActiveCollab API 端点是分页的,但不是全部。 You can detect a paginated data set by observing X-Angie-PaginationCurrentPage , X-Angie-PaginationItemsPerPage and X-Angie-PaginationTotalItems headers in the responses.您可以通过观察响应中的X-Angie-PaginationCurrentPageX-Angie-PaginationItemsPerPageX-Angie-PaginationTotalItems标头来检测分页数据集。 These headers are present in all paginated responses, and they describe how pagination is set (number of items per page) and how many items are in the data set.这些标题出现在所有分页响应中,它们描述了如何设置分页(每页的项目数)以及数据集中有多少项目。

Data is paginated by adding page to the API request query, for example: /api/v1/paginated-resources?page=12 .通过在 API 请求查询中添加page来对数据进行分页,例如: /api/v1/paginated-resources?page=12

There are two common and pracical approaches to paginated data sets:分页数据集有两种常见且实用的方法:

  1. Go page by page based on pagination headers, Go 基于分页标题逐页,
  2. Enter a loop and incremenet page value in the query string until you get an empty result (pages where there are no data don't error, but return empty data set).在查询字符串中输入循环和递增page值,直到得到空结果(没有数据的页面不会出错,但返回空数据集)。

Example of this #2 principle, with limit to 1000 pages, just in case:这个 #2 原则的示例,限制为 1000 页,以防万一:

$page = 0;

do {
    $response = $this->makeRequest(
        sprintf(
            '/api/v1/paginated-resource?page=%d', 
            ++$page
        )
    );

    // Do something with response
} while (!empty($response) && $page < 1000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM