ActiveCollab API 分页和速率限制 [英] ActiveCollab API Paginantion and Rate Limit

查看:37
本文介绍了ActiveCollab API 分页和速率限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://developers.activecollab.com 上找不到有关 API 分页或速率限制的信息/api-documentation/

如果我们获取太多数据,我们允许进行多少次调用,是否存在分页?

How many calls are we allowed to make and does pagination exists if we are fetching too much data?

推荐答案

许多 ActiveCollab API 端点都有分页,但不是全部.您可以通过观察 X-Angie-PaginationCurrentPageX-Angie-PaginationItemsPerPageX-Angie-PaginationTotalItems 标头来检测分页数据集回应.这些标题出现在所有分页响应中,它们描述了如何设置分页(每页的项目数)以及数据集中有多少项目.

Many ActiveCollab API end-points are paginated, but not all. You can detect a paginated data set by observing X-Angie-PaginationCurrentPage, X-Angie-PaginationItemsPerPage and X-Angie-PaginationTotalItems headers in the responses. 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.

通过在API请求查询中添加page对数据进行分页,例如:/api/v1/paginated-resources?page=12.

Data is paginated by adding page to the API request query, for example: /api/v1/paginated-resources?page=12.

分页数据集有两种常见且实用的方法:

There are two common and pracical approaches to paginated data sets:

  1. 根据分页标题逐页浏览,
  2. 在查询字符串中输入循环和增量 page 值,直到得到空结果(没有数据的页面不会出错,但返回空数据集).
  1. Go page by page based on pagination headers,
  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).

这个#2 原则的例子,限制为 1000 页,以防万一:

Example of this #2 principle, with limit to 1000 pages, just in case:

$page = 0;

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

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

这篇关于ActiveCollab API 分页和速率限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆