gpt4 book ai didi

php - Coinbase api get请求未返回所有记录

转载 作者:行者123 更新时间:2023-12-02 03:54:25 26 4
gpt4 key购买 nike

这里我尝试使用 coinbase api 获取所有帐户:

require 'MyInclude/vendor/autoload.php';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
use Coinbase\Wallet\Resource\Account;
use Coinbase\Wallet\ActiveRecord\AccountActiveRecord;

$apiKey = 'API KEY';
$apiSecret = 'API SECERET';
$configuration = Configuration::apiKey($apiKey, $apiSecret);

$client = Client::create($configuration);

$accounts = $client->getAccounts();

输出:此数组中只有 25 个帐户

如何获取所有帐户???

最佳答案

查看 API 文档。

All GET endpoints which return an object list support cursor based pagination with pagination information inside a pagination object. This means that to get all objects, you need to paginate through the results by always using the id of the last resource in the list as a starting_after parameter for the next call.

https://developers.coinbase.com/api/v2#pagination

因此您的请求仅返回前 25 个结果。为了获取所有帐户,您需要使用返回的 next_uri 进行循环(请参阅示例响应)。

{
"pagination": {
"ending_before": null,
"starting_after": null,
"limit": 25,
"order": "desc",
"previous_uri": null,
"next_uri": "/v2/accounts?&limit=25&starting_after=5d5aed5f-b7c0-5585-a3dd-a7ed9ef0e414"
},
"data": [
...
]
}

关于php - Coinbase api get请求未返回所有记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44432154/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com