PHPackages                             cointokio/coingecko-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. cointokio/coingecko-api-client

ActiveLibrary[API Development](/categories/api)

cointokio/coingecko-api-client
==============================

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

v2.1.0(1mo ago)0431GPL-2.0-or-laterPHP

Since Jan 31Pushed 3w ago1 watchersCompare

[ Source](https://github.com/cointokio/coingecko-api-client)[ Packagist](https://packagist.org/packages/cointokio/coingecko-api-client)[ Docs](https://github.com/cointokio/coingecko-api-client)[ RSS](/packages/cointokio-coingecko-api-client/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

CoinGecko API Client for WordPress
==================================

[](#coingecko-api-client-for-wordpress)

A PHP client for fetching data from the [CoinGecko API](https://www.coingecko.com/en/api/documentation) intended to be used in WordPress plugins or themes. Being a good WordPress citizen, this client uses the WordPress core [HTTP API](https://developer.wordpress.org/plugins/http-api/) to fetch its data.

Installation
------------

[](#installation)

This package is [available on packagist.org](https://packagist.org/packages/cointokio/coingecko-api-client) and can be added as a dependency to your project via [Composer](https://getcomposer.org).

`composer require cointokio/coingecko-api-client`

Use
---

[](#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](https://developer.wordpress.org/reference/classes/wp_error/) object. Note that access to the CoinGecko API requires an API key.

### API key

[](#api-key)

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.

### API endpoint

[](#api-endpoint)

CoinGecko exposes two hosts so the host must be selected explicitly:

- Demo (free): `https://api.coingecko.com/api/v3`, authenticated with `x-cg-demo-api-key`.
- Pro (paid): `https://pro-api.coingecko.com/api/v3`, authenticated with `x-cg-pro-api-key`.

The client defaults to the Demo host. If you have a [Pro](https://www.coingecko.com/en/api/pricing) key, point the client at the Pro host so it switches to the `x-cg-pro-api-key` header automatically:

```
$client = new Cointokio\CoinGecko\Client(
	'your-pro-api-key',
	'https://pro-api.coingecko.com/api/v3'
);

```

As with the API key, the endpoint can also be supplied via a constant (`COINGECKO_API_ENDPOINT`) so `new Cointokio\CoinGecko\Client()` with no arguments works.

The auth header is only attached when the configured host is one of the two recognised CoinGecko hosts. Pointing the client at any other host (e.g. a local mock) deliberately suppresses the key header so credentials cannot leak to a third-party server.

### Example — demo key, default host

[](#example--demo-key-default-host)

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

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

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

```

### Example — pro key, paid host

[](#example--pro-key-paid-host)

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

$client = new Cointokio\CoinGecko\Client(
	'your-pro-api-key',
	'https://pro-api.coingecko.com/api/v3'
);

$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-demo-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
----------------

[](#coding-standards)

This project aims to adhere to the [VIP Coding Standards](https://github.com/Automattic/VIP-Coding-Standards).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance71

Regular maintenance activity

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~525 days

Total

4

Last Release

37d ago

Major Versions

v1.0.1 → v2.0.02025-03-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc3005a412327fcadf1d65f43882764e5ab756255cfa17bbf0f65913ffd76f22?d=identicon)[cointokio](/maintainers/cointokio)

---

Top Contributors

[![barryceelen](https://avatars.githubusercontent.com/u/4179791?v=4)](https://github.com/barryceelen "barryceelen (31 commits)")

---

Tags

phpapiclientwordpresscoingecko.comCoingecko

### Embed Badge

![Health badge](/badges/cointokio-coingecko-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/cointokio-coingecko-api-client/health.svg)](https://phpackages.com/packages/cointokio-coingecko-api-client)
```

###  Alternatives

[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3673.2M19](/packages/kunalvarma05-dropbox-php-sdk)[mozex/anthropic-php

PHP client for the Anthropic API: messages, streaming, tool use, thinking, web search, code execution, batches, and more.

49552.5k17](/packages/mozex-anthropic-php)[google-gemini-php/symfony

Symfony Bundle for Gemini

1513.7k2](/packages/google-gemini-php-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
