PHPackages                             btcpayserver/btcpayserver-greenfield-php - 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. btcpayserver/btcpayserver-greenfield-php

ActiveLibrary[API Development](/categories/api)

btcpayserver/btcpayserver-greenfield-php
========================================

BTCPay Server Greenfield API PHP client library.

v2.9.1(2mo ago)34290.9k↓12.3%33[9 issues](https://github.com/btcpayserver/btcpayserver-greenfield-php/issues)[2 PRs](https://github.com/btcpayserver/btcpayserver-greenfield-php/pulls)3MITPHPPHP &gt;=8.0CI failing

Since Oct 1Pushed 2mo ago7 watchersCompare

[ Source](https://github.com/btcpayserver/btcpayserver-greenfield-php)[ Packagist](https://packagist.org/packages/btcpayserver/btcpayserver-greenfield-php)[ RSS](/packages/btcpayserver-btcpayserver-greenfield-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (8)Versions (25)Used By (3)

BTCPay Server Greenfield API PHP client library
===============================================

[](#btcpay-server-greenfield-api-php-client-library)

This library makes it easier to integrate BTCPay Server in your PHP application.

Approach
--------

[](#approach)

This library takes an opinionated approach to Greenfield API with the aim of making your developer life as easy and convenient as possible. For this reason, we have decided to structure arguments a bit differently, but still allow full and advanced use cases.

The general reasoning behind the arguments an API client takes are in this order:

- First the required parameters =&gt; method arguments with NULL not allowed
- Recommended parameters =&gt; method arguments with NULL as default
- Optional parameters =&gt; arguments with NULL as default
- Lastly the advanced parameters =&gt; Inside an extra class

Methods that return a Unix timestamp always end with `Timestamp` like `getReceivedTimestamp()` to avoid format and timezone confusion. These are always in seconds (not milliseconds).

Features
--------

[](#features)

- No external dependencies. You can just drop this code in your project using composer or without composer.
- Requires PHP 8.0 and up. End-of-life'd versions will not be actively supported.
- All calls needed for eCommerce are included, but there are more we still need to add.

TODO
----

[](#todo)

- convert examples to tests
- Getters and setters
- Expand beyond the eCommerce related API calls and make this library 100% complete.

How to use with composer
------------------------

[](#how-to-use-with-composer)

```
composer require btcpayserver/btcpayserver-greenfield-php

```

If you use some framework or other project you likely are ready to go. If you start from scratch make sure to include Composer autoloader.

```
require __DIR__ . '/../vendor/autoload.php';

```

How to use without composer (not recommended)
---------------------------------------------

[](#how-to-use-without-composer-not-recommended)

In the `src` directory we have a custom `autoload.php` which you can require and avoid using composer if needed.

```
// Require the autoload file.
require __DIR__ . '/../src/autoload.php';

// Example to get all stores.
$apiKey = '';
$host = ''; // e.g. https://your.btcpay-server.tld

try {
    $client = new \BTCPayServer\Client\Store($host, $apiKey);
    var_dump($client->getStores());
} catch (\Throwable $e) {
    echo "Error: " . $e->getMessage();
}

```

Best practices
--------------

[](#best-practices)

- Always use an API key with as little permissions as possible.
- If you only interact with specific stores, use an API key that is limited to that store or those stores only.
- When processing an incoming webhook, always load the data fresh using the API as the data may be stale or changed in the meantime. Webhook payloads can be resent on error, so you could be seeing outdated information. By loading the data fresh, you are also protecting yourself from possibly spoofed (fake) requests.

FAQ
---

[](#faq)

### Where to get the API key from?

[](#where-to-get-the-api-key-from)

The API keys for Greenfield API are *not* on the store level "Access Tokens" anymore. You need to go to your account profile: "My Settings" (user profile icon) -&gt; "API Keys" instead. You can even redirect the users to generate the API keys there.

Contribute
----------

[](#contribute)

We run static analyzer [Psalm](https://psalm.dev/) and [PHP-CS-fixer](https://github.com/FriendsOfPhp/PHP-CS-Fixer) for codestyle when you open a pull-request. Please check if there are any errors and fix them accordingly.

### Codestyle

[](#codestyle)

We use PSR-12 code style to ensure proper formatting and spacing. You can test and format your code using composer commands. Before doing a PR you can run `composer cs-check` and `composer cs-fix` which will run php-cs-fixer.

### Greenfield API coverage

[](#greenfield-api-coverage)

Currently implemented functionality is tracked in [this sheet](https://docs.google.com/spreadsheets/d/1A1tMWYHGVkFWRgqfkW9GSGBRjzKZzsu5XMIW1NLs-xg/edit#gid=0) and will be updated sporadically. Check to see which areas still need work in case you want to contribute.

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity49

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 50.7% 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 ~72 days

Recently: every ~147 days

Total

24

Last Release

66d ago

Major Versions

v1.3.6 → v2.0.02022-10-27

v2.3.0 → 3.x-dev2023-08-01

PHP version history (2 changes)v1.0.0PHP &gt;=7.3.0

v2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1136761?v=4)[ndeet](/maintainers/ndeet)[@ndeet](https://github.com/ndeet)

![](https://www.gravatar.com/avatar/4c5d7eced5c1e83ea0d795059900fae188d6f5c09f91f2774ab6034e5d945da2?d=identicon)[woutersamaey](/maintainers/woutersamaey)

---

Top Contributors

[![ndeet](https://avatars.githubusercontent.com/u/1136761?v=4)](https://github.com/ndeet "ndeet (112 commits)")[![woutersamaey](https://avatars.githubusercontent.com/u/71019?v=4)](https://github.com/woutersamaey "woutersamaey (59 commits)")[![JudithWebdev](https://avatars.githubusercontent.com/u/60744952?v=4)](https://github.com/JudithWebdev "JudithWebdev (13 commits)")[![mp21-org](https://avatars.githubusercontent.com/u/1374810?v=4)](https://github.com/mp21-org "mp21-org (7 commits)")[![damanic](https://avatars.githubusercontent.com/u/5227303?v=4)](https://github.com/damanic "damanic (7 commits)")[![petzsch](https://avatars.githubusercontent.com/u/1374810?v=4)](https://github.com/petzsch "petzsch (7 commits)")[![utxo-one](https://avatars.githubusercontent.com/u/111649294?v=4)](https://github.com/utxo-one "utxo-one (5 commits)")[![ingridbeilova](https://avatars.githubusercontent.com/u/77632918?v=4)](https://github.com/ingridbeilova "ingridbeilova (5 commits)")[![BitcoinMitchell](https://avatars.githubusercontent.com/u/27309467?v=4)](https://github.com/BitcoinMitchell "BitcoinMitchell (2 commits)")[![leonardooleg](https://avatars.githubusercontent.com/u/34482346?v=4)](https://github.com/leonardooleg "leonardooleg (1 commits)")[![Pezhvak](https://avatars.githubusercontent.com/u/3134479?v=4)](https://github.com/Pezhvak "Pezhvak (1 commits)")[![bartko-s](https://avatars.githubusercontent.com/u/675883?v=4)](https://github.com/bartko-s "bartko-s (1 commits)")[![sillyh4ck3r](https://avatars.githubusercontent.com/u/7612355?v=4)](https://github.com/sillyh4ck3r "sillyh4ck3r (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/btcpayserver-btcpayserver-greenfield-php/health.svg)

```
[![Health](https://phpackages.com/badges/btcpayserver-btcpayserver-greenfield-php/health.svg)](https://phpackages.com/packages/btcpayserver-btcpayserver-greenfield-php)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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