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.0(3mo ago)33246.6k↑11%34[1 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 3mo 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 1mo ago

READMEChangelog (10)Dependencies (4)Versions (24)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

58

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 52.1% 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 ~71 days

Recently: every ~123 days

Total

23

Last Release

118d 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://www.gravatar.com/avatar/e677d18576ffa9811a9fc8041b89b48c8aa6edce3783fa097efaf45c572d49f7?d=identicon)[ndeet](/maintainers/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 (111 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)")[![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)")[![sillyh4ck3r](https://avatars.githubusercontent.com/u/7612355?v=4)](https://github.com/sillyh4ck3r "sillyh4ck3r (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)")[![leonardooleg](https://avatars.githubusercontent.com/u/34482346?v=4)](https://github.com/leonardooleg "leonardooleg (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

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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