定制 cointokio/coingecko-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

cointokio/coingecko-api-client

最新稳定版本:v2.0.0

Composer 安装命令:

composer require cointokio/coingecko-api-client

包简介

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

README 文档

README

A PHP client for fetching data from the CoinGecko API 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.

Installation

This package is available on packagist.org and can be added as a dependency to your project via Composer.

composer require cointokio/coingecko-api-client

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 CoinGecko API. Each method represents a separate API endpoint and will either return a list of response data or a WP_Error object. Note that access to the CoinGecko API requires an API key.

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

/*
 * There are two ways to supply your CoinGecko API key:
 *
 * - Pass the API key into the Client constructor (shown below). The client stores
 *   this value and passes it to each request class.
 * - Define the PHP constant COINGECKO_API_KEY. Endpoint classes extend Request,
 *   which reads that constant when the key string passed from Client is empty—so
 *   `new Cointokio\CoinGecko\Client()` with no arguments still works if the
 *   constant is defined before you call any API methods.
 */
$client = new Cointokio\CoinGecko\Client( 'your-api-key' );

/*
 * Use the ping() method to check the CoinGecko API status.
 *
 * @see https://www.coingecko.com/api/documentations/v3#/ping
 */
$response = $client->ping();

The following example uses the $client->coins()->get_markets() method to fetch data from CoinGecko's /coins/markets endpoint. Note that access to the CoinGecko API requires an API key.

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

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

/*
 * Get a list of price, market cap, volume and market-related data.
 *
 * @see https://www.coingecko.com/api/documentations/v3#/coins/get_coins_markets
 *
 * Note that the $client->coins() method returns an instance of the
 * \Cointokio\CoinGecko\Coins class. This allows us to use the Coins class methods
 * more easily via method chaining, eg.:
 *
 * $client->coins()->get_list()
 * $client->coins()->get_markets()
 *
 * @see https://github.com/cointokio/coingecko-api-client/blob/main/class-client.php#L41
 * @see https://github.com/cointokio/coingecko-api-client/blob/main/classes/class-coins.php
 * @see https://en.wikipedia.org/wiki/Method_chaining
 */
$response = $client->coins()->get_markets(
	'eur',
	array( 'ids' => 'btc, eth' )
);

Coding Standards

This project aims to adhere to the VIP Coding Standards.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2022-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固