PHPackages                             nocksapp/nocks-sdk-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. nocksapp/nocks-sdk-php

ActiveLibrary[API Development](/categories/api)

nocksapp/nocks-sdk-php
======================

PHP SDK for the Nocks API

v2.1.0(7y ago)438321MITPHPPHP &gt;=5.4.0

Since Sep 10Pushed 7y ago3 watchersCompare

[ Source](https://github.com/nocksapp/nocks-sdk-php)[ Packagist](https://packagist.org/packages/nocksapp/nocks-sdk-php)[ Docs](https://nocks.com/)[ RSS](/packages/nocksapp-nocks-sdk-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (32)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/60543461afaf9f4647c2734f1eab813b5837a897e6adef8e3b28204cf2e40699/68747470733a2f2f706f7365722e707567782e6f72672f6e6f636b736170702f6e6f636b732d73646b2d7068702f762f737461626c65)](https://packagist.org/packages/nocksapp/nocks-sdk-php)[![Total Downloads](https://camo.githubusercontent.com/aa4746eb42d3c46453c79779e94d66d2252a9d56a0c32c75858b42fa2cfd6a3a/68747470733a2f2f706f7365722e707567782e6f72672f6e6f636b736170702f6e6f636b732d73646b2d7068702f646f776e6c6f616473)](https://packagist.org/packages/nocksapp/nocks-sdk-php)[![Latest Unstable Version](https://camo.githubusercontent.com/41895da86e8851c1678762a0c17d4028b536e4a991e3a6a1cdd046b8882aafe1/68747470733a2f2f706f7365722e707567782e6f72672f6e6f636b736170702f6e6f636b732d73646b2d7068702f762f756e737461626c65)](https://packagist.org/packages/nocksapp/nocks-sdk-php)

Nocks SDK PHP
=============

[](#nocks-sdk-php)

Nocks SDK PHP is a `php` package for [Nocks](https://docs.nocks.com/). It can be used in any php `>=5.4.0` environment. The `SDK` supports both the calls to the Nocks `api` endpoints as well to the `oauth` endpoints.

---

- [Installation](#installation)
- [Getting started](#getting-started)
- [Examples](#examples)
- [Support](#support)

---

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

[](#installation)

This SDK uses composer.

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

For more information on how to use/install composer, please visit:

To install this SDK into your project with composer, simply use:

`$ composer require nocksapp/nocks-sdk-php`

Getting Started
---------------

[](#getting-started)

### Oauth

[](#oauth)

The `NocksOauth` class provides the following methods:

- getOauthUri
- requestToken
- refreshToken
- passwordGrantToken
- scopes
- tokenScopes

#### Example

[](#example)

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

use Nocks\SDK\NocksOauth;
use Nocks\SDK\Constant\Platform;

try {
    $clientId = '1';
    $clientSecret = '1234';
    $scopes = ['user.read'];
    $redirectUri = 'https://www.example.com';

    $nocksOauth = new NocksOauth(Platform::SANDBOX, $clientId, $clientSecret, $scopes, $redirectUri);
    $uri = $nocksOauth->getOauthUri();

    // For example, redirect the user to the Nocks login page
    header('Location: ' . $uri);
    die();
} catch (\Nocks\SDK\Exception\Exception $e) {
    // Handle any SDK exception
}
```

Please checkout the [oauth docs](https://docs.nocks.com/#oauth-applications) and [examples](#examples) to see how the `oauth` methods can be used.

### API

[](#api)

The `NocksApi` class provides all the `Nocks` resources. Please checkout the [resources docs](https://docs.nocks.com/#public-resources) and [examples](#examples).

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

use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = 'your_access_token';
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $user = $nocksApi->user->findAuthenticated();
} catch (\Nocks\SDK\Exception\Exception $e) {
    // Handle any SDK exception
}
```

### Results

[](#results)

The result returned from a method call in the SDK will differ, please check the `PHPDocs` to see what will be returned from a method. Most of the time it will be a `Model` or a `NocksResponse`.

#### Model

[](#model)

A `Model` is just a simple `object` which holds the `data` returned from the api. Each `Model` will provide the necessary `getters` and `setters` for the specific `data`.

#### NocksResponse

[](#nocksresponse)

A `NocksResponse` is an object which holds a `data array` and a `pagination object`. This is typically returned from a `.find` method.

Example:

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

use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = 'your_access_token';
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $result = $nocksApi->transaction->find();
    $result->getPagination(); // Do something with pagination

    // Loop through transactions
    foreach ($result->getData() as $transaction) {
        // Do something with the transaction
    }
} catch (\Nocks\SDK\Exception\Exception $e) {
    // Handle any SDK exception
}
```

### Exceptions

[](#exceptions)

The SDK uses the following exceptions. All exceptions are inherit from `Nocks\SDK\Exception\Exception`.

- Nocks\\SDK\\Exception\\Exception (super)
    - Nocks\\SDK\\Exception\\HttpException (super)
        - Nocks\\SDK\\Exception\\BadRequestException
        - Nocks\\SDK\\Exception\\ForbiddenException
        - Nocks\\SDK\\Exception\\GoneException
        - Nocks\\SDK\\Exception\\InternalServerError
        - Nocks\\SDK\\Exception\\MethodNotAllowedException
        - Nocks\\SDK\\Exception\\NotAcceptable
        - Nocks\\SDK\\Exception\\NotFoundException
        - Nocks\\SDK\\Exception\\ServiceUnavailable
        - Nocks\\SDK\\Exception\\TooManyRequests
        - Nocks\\SDK\\Exception\\UnauthorizedException
    - Nocks\\SDK\\Exception\\ValidationException
    - Nocks\\SDK\\Exception\\ScopeConfigurationException

#### HttpException

[](#httpexception)

A `HttpException` is thrown when a http call to `Nocks` fails. The HttpException is the `super` exception and the actual exception that is thrown is corresponding to the http `statuscode`, see [the documentation](https://docs.nocks.com/#errors).

#### ValidationException

[](#validationexception)

A `ValidationException` may occur when you call a function with `invalid` parameters or when there are `missing` required parameters. For example:

```
use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = 'your_access_token';
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $userToUpdate = new User();
    // $userToUpdate->setUuid('1234'); Will occur in an exception when not set
    $user = $nocksApi->user->update($userToUpdate);
} catch (\Nocks\SDK\Exception\ValidationException $e) {
    // A ValidationException will be thrown when the $userToUpdate has no uuid
}
```

`Note that the SDK doesn't check your request data, if there is something wrong with your data, the http call will resolve in a HttpException`

#### ScopeConfigurationException

[](#scopeconfigurationexception)

A `ScopeConfigurationException` may occur when calling a function which depends on a certain scope parameter that was not provided. For example, calling a `private` resource while there was no `accessToken` configured:

```
use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;

try {
    $accessToken = null;
    $nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);

    $userToUpdate = new User([
        'uuid' => '1234',
        'locale' => 'nl_NL',
    ]);
    $user = $nocksApi->user->update($userToUpdate);
} catch (\Nocks\SDK\Exception\ScopeConfigurationException $e) {
    // A ScopeConfigurationException will be thrown when the $accessToken is null
}
```

Examples
--------

[](#examples)

In the [examples directory](./examples) you will find examples for each call that is supported in this SDK.

Support
-------

[](#support)

Need help or support? Please check .

Found a bug? Please check the existing GitHub issues and open a new issue if necessary. Or even better, create a pull request to directly resolve the issue you have found!

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 74% 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 ~45 days

Recently: every ~53 days

Total

30

Last Release

2574d ago

Major Versions

v0.0.21 → v1.0.02018-06-13

v1.0.4 → v2.0.02019-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/02e2777bfbb48d2d0427eee1b911160c3616d6805531c952b7eb8d82f3cce76c?d=identicon)[nocksapp](/maintainers/nocksapp)

---

Top Contributors

[![patrickkivits](https://avatars.githubusercontent.com/u/727174?v=4)](https://github.com/patrickkivits "patrickkivits (37 commits)")[![nocksapp](https://avatars.githubusercontent.com/u/13950417?v=4)](https://github.com/nocksapp "nocksapp (13 commits)")

---

Tags

apisdkpaymentbitcointransactionblockchainnocksgulden

### Embed Badge

![Health badge](/badges/nocksapp-nocks-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/nocksapp-nocks-sdk-php/health.svg)](https://phpackages.com/packages/nocksapp-nocks-sdk-php)
```

###  Alternatives

[blocktrail/blocktrail-sdk

The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API

4921.1k3](/packages/blocktrail-blocktrail-sdk)[mocking-magician/coinbase-pro-sdk

Library for coinbase pro API calls

223.2k](/packages/mocking-magician-coinbase-pro-sdk)

PHPackages © 2026

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