PHPackages                             zero-to-prod/spapi-tokens - 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. zero-to-prod/spapi-tokens

ActiveLibrary[API Development](/categories/api)

zero-to-prod/spapi-tokens
=========================

Get a Restricted Data Token (RDT) for Amazon Selling Partner API (SPAPI).

v3.1.3(1y ago)13.3k[1 PRs](https://github.com/zero-to-prod/spapi-tokens/pulls)4MITPHPPHP &gt;=7.1CI passing

Since Feb 2Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/zero-to-prod/spapi-tokens)[ Packagist](https://packagist.org/packages/zero-to-prod/spapi-tokens)[ Docs](https://github.com/zero-to-prod/spapi-tokens)[ Fund](https://github.com/sponsors/zero-to-prod)[ RSS](/packages/zero-to-prod-spapi-tokens/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (16)Used By (4)

Zerotoprod\\SpapiTokens
=======================

[](#zerotoprodspapitokens)

[![](art/logo.png)](art/logo.png)

[![Repo](https://camo.githubusercontent.com/9a90a3efeee26aed7d7f2feee9cd84566a26f9c362cc773b184d076210906e1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d677261793f6c6f676f3d676974687562)](https://github.com/zero-to-prod/spapi-tokens)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/43a9cd184aba993e2816e0aa5106decdfe4fec0d94e3b4905baea7faa4a05003/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f73706170692d746f6b656e732f746573742e796d6c3f6c6162656c3d74657374)](https://github.com/zero-to-prod/spapi-tokens/actions)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/b4ebd67cdab7549b1cf172f842397094255a0b0eb562c9e290a2738e23a92dd2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f73706170692d746f6b656e732f6261636b77617264735f636f6d7061746962696c6974792e796d6c3f6c6162656c3d6261636b77617264735f636f6d7061746962696c697479)](https://github.com/zero-to-prod/spapi-tokens/actions)[![Packagist Downloads](https://camo.githubusercontent.com/63dde05e52ff4b70694a5411e9cacbf502c89625f3a6bd2fa7ae0cb649d71f14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a65726f2d746f2d70726f642f73706170692d746f6b656e733f636f6c6f723d626c7565)](https://packagist.org/packages/zero-to-prod/spapi-tokens/stats)[![php](https://camo.githubusercontent.com/50b2213e4f678bb98dc090e1bd8383a78ba6ab38a90567e5f4176487a5dbd986/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a65726f2d746f2d70726f642f73706170692d746f6b656e732e7376673f636f6c6f723d707572706c65)](https://packagist.org/packages/zero-to-prod/spapi-tokens/stats)[![Packagist Version](https://camo.githubusercontent.com/eea098ee2081f3a0f4b62b70003aa84b68dbaefcc624041a0ff7244ca7c7b2a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a65726f2d746f2d70726f642f73706170692d746f6b656e733f636f6c6f723d663238643161)](https://packagist.org/packages/zero-to-prod/spapi-tokens)[![License](https://camo.githubusercontent.com/9838661c0c4809992487ecbd331ada809a4ff38f88357c95f9ff44bd7efa9918/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a65726f2d746f2d70726f642f73706170692d746f6b656e733f636f6c6f723d70696e6b)](https://github.com/zero-to-prod/spapi-tokens/blob/main/LICENSE.md)[![wakatime](https://camo.githubusercontent.com/4b8cea92e7025a63320d11e9fe844f14ca58888755095de0f0b5a605dc04d9b3/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f6769746875622f7a65726f2d746f2d70726f642f73706170692d746f6b656e732e737667)](https://wakatime.com/badge/github/zero-to-prod/spapi-tokens)[![Hits-of-Code](https://camo.githubusercontent.com/24758280d9d6737aec45c2a5b7529e8e417574d1f0f8d42defed9e3a8e8c65f6/68747470733a2f2f686974736f66636f64652e636f6d2f6769746875622f7a65726f2d746f2d70726f642f73706170692d746f6b656e733f6272616e63683d6d61696e)](https://hitsofcode.com/github/zero-to-prod/spapi-tokens/view?branch=main)

Contents
--------

[](#contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Documentation Publishing](#documentation-publishing)
    - [Automatic Documentation Publishing](#automatic-documentation-publishing)
- [Usage](#usage)
- [Local Development](./LOCAL_DEVELOPMENT.md)
- [Contributing](#contributing)

Introduction
------------

[](#introduction)

Get a Restricted Data Token (RDT) for Amazon Selling Partner API (SPAPI).

Requirements
------------

[](#requirements)

- PHP 7.1 or higher.

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

[](#installation)

Install `Zerotoprod\SpapiTokens` via [Composer](https://getcomposer.org/):

```
composer require zero-to-prod/spapi-tokens
```

This will add the package to your project’s dependencies and create an autoloader entry for it.

Documentation Publishing
------------------------

[](#documentation-publishing)

You can publish this README to your local documentation directory.

This can be useful for providing documentation for AI agents.

This can be done using the included script:

```
# Publish to default location (./docs/zero-to-prod/spapi-tokens)
vendor/bin/zero-to-prod-spapi-tokens

# Publish to custom directory
vendor/bin/zero-to-prod-spapi-tokens /path/to/your/docs
```

### Automatic Documentation Publishing

[](#automatic-documentation-publishing)

You can automatically publish documentation by adding the following to your `composer.json`:

```
{
    "scripts": {
        "post-install-cmd": [
            "zero-to-prod-spapi-tokens"
        ],
        "post-update-cmd": [
            "zero-to-prod-spapi-tokens"
        ]
    }
}
```

Usage
-----

[](#usage)

Call the Tokens API to get a [Restricted Data Token](https://developer-docs.amazon.com/sp-api/docs/tokens-api-v2021-03-01-reference) (RDT) for restricted resources.

```
use Zerotoprod\SpapiTokens\SpapiTokens;

$response = SpapiTokens::from('access_token','targetApplication')
            ->createRestrictedDataToken('path', ['dataElements']);

$response['response']['restrictedDataToken'];
$response['response']['expiresIn'];
```

Testing
-------

[](#testing)

You can fake the response for testing purposes.

```
use Zerotoprod\SpapiTokens\SpapiTokens;
use Zerotoprod\SpapiTokens\Support\Testing\SpapiTokensResponseFactory;
use Zerotoprod\SpapiTokens\Support\Testing\SpapiTokensFake;

SpapiTokensFake::fake(
    SpapiTokensResponseFactory::factory()->make()
);

$response = SpapiTokens::from('access_token','targetApplication')
            ->createRestrictedDataToken('path', ['dataElements']);
```

Contributing
------------

[](#contributing)

Contributions, issues, and feature requests are welcome! Feel free to check the [issues](https://github.com/zero-to-prod/spapi-tokens/issues) page if you want to contribute.

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Create a new Pull Request.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance56

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.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 ~0 days

Total

14

Last Release

461d ago

Major Versions

v1.0.6 → v2.0.02025-02-02

v2.0.1 → v3.0.02025-02-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/502649f05d36c87d494988bd99193a4d908d345335d99c080928a726277371f5?d=identicon)[zero-to-prod](/maintainers/zero-to-prod)

---

Top Contributors

[![zero-to-prod](https://avatars.githubusercontent.com/u/61474950?v=4)](https://github.com/zero-to-prod "zero-to-prod (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

zero-to-prodspapi-tokens

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zero-to-prod-spapi-tokens/health.svg)

```
[![Health](https://phpackages.com/badges/zero-to-prod-spapi-tokens/health.svg)](https://phpackages.com/packages/zero-to-prod-spapi-tokens)
```

###  Alternatives

[zero-to-prod/data-model

Transforms Data into Type-Safe DTOs.

14226.2k32](/packages/zero-to-prod-data-model)

PHPackages © 2026

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