承接 cointokio/coinmarketcap-api-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cointokio/coinmarketcap-api-client

Composer 安装命令:

composer require cointokio/coinmarketcap-api-client

包简介

Fetch data from the CoinMarketCap API, intended for use in WordPress plugins or themes.

README 文档

README

A PHP client for fetching data from the CoinMarketCap Pro Cryptocurrency API endpoint intended to be used in WordPress plugins or themes. Being a good WordPress citizen, this client uses the WordPress core HTTP API to fetch its data.

Note that this package only covers the Cryptocurrency endpoint family, with the addition of the Key Info endpoint for use as a health probe.

Use

Include the main class-client.php file and create an instance of the Client class and use its methods to fetch data from the CoinMarketCap API. Each method maps to one of the Implemented endpoints listed above and will either return the decoded response body as an array or a WP_Error object. Note that access to the CoinMarketCap API requires an API key.

require_once '/your/cool/path/to/coinmarketcap-client/class-client.php';

/*
 * There are two ways the Client class can use your CoinMarketCap API key:
 *
 * - Pass the API key to the Client class directly like in the example below.
 * - Define a global COINMARKETCAP_API_KEY constant.
 */
$client = new Cointokio\CoinMarketCap\Client( 'your-api-key' );

/*
 * Use the key()->get_info() method to inspect the configured API key
 * (does not consume call credits).
 *
 * @see https://pro.coinmarketcap.com/api/documentation/pro-api-reference/tools/key-info
 */
$response = $client->key()->get_info();

The following example uses the $client->cryptocurrency()->quotes_latest() method to fetch data from the /v3/cryptocurrency/quotes/latest endpoint.

require_once '/your/cool/path/to/coinmarketcap-client/class-client.php';

$client = new Cointokio\CoinMarketCap\Client( 'your-api-key' );

/*
 * Get the latest market quote for one or more cryptocurrencies. The
 * `convert` argument bundles multiple fiat conversions into a single call.
 *
 * @see https://pro.coinmarketcap.com/api/documentation/pro-api-reference/cryptocurrency/cryptocurrency-quotes-latest
 *
 * Note that the $client->cryptocurrency() method returns an instance of the
 * \Cointokio\CoinMarketCap\Cryptocurrency class. This allows us to use the
 * Cryptocurrency class methods more easily via method chaining, eg.:
 *
 * $client->cryptocurrency()->quotes_latest()
 *
 * @see https://en.wikipedia.org/wiki/Method_chaining
 */
$response = $client->cryptocurrency()->quotes_latest( '1,1027', 'USD,EUR' );

convert limit

Every CoinMarketCap plan caps the number of convert values accepted per quotes/latest request, with the free Basic plan capped at one. Bundling more than the per-plan cap into a single call is rejected with a 400 ("Your plan is limited to N convert options"), surfaced by the client as WP_Error( 'http_400', ... ). To stay portable across plan tiers, issue one quotes_latest() request per fiat:

foreach ( $fiats as $fiat ) {
    $response = $client->cryptocurrency()->quotes_latest( $ids_csv, $fiat );
    // Aggregate per-fiat responses into your own structure.
}

Coding Standards

This project aims to adhere to the VIP Coding Standards.

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固