PHPackages                             zero-to-prod/spapi-lwa-cli - 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. [CLI &amp; Console](/categories/cli)
4. /
5. zero-to-prod/spapi-lwa-cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

zero-to-prod/spapi-lwa-cli
==========================

A CLI for connecting to Amazons Selling Partner API with Login With Amazon (LWA).

v2.1.0(1y ago)1227[1 PRs](https://github.com/zero-to-prod/spapi-lwa-cli/pulls)1MITPHPPHP &gt;=8.1CI passing

Since Feb 2Pushed 8mo ago1 watchersCompare

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

READMEChangelog (5)Dependencies (5)Versions (7)Used By (1)

Zerotoprod\\SpapiLwaCli
=======================

[](#zerotoprodspapilwacli)

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

[![Repo](https://camo.githubusercontent.com/9a90a3efeee26aed7d7f2feee9cd84566a26f9c362cc773b184d076210906e1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d677261793f6c6f676f3d676974687562)](https://github.com/zero-to-prod/spapi-lwa-cli)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/15ac08d04a102f5153b93c9e4ecadac659986b708d806690b54dd3b7966aa65e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f73706170692d6c77612d636c692f746573742e796d6c3f6c6162656c3d74657374)](https://github.com/zero-to-prod/spapi-lwa-cli/actions)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/e433d893c793c701b7c6e6303c8914b74cb6474254b6881f1d4fc9d1526b1107/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f73706170692d6c77612d636c692f6275696c645f646f636b65725f696d6167652e796d6c3f6c6162656c3d6275696c645f646f636b65725f696d616765)](https://github.com/zero-to-prod/spapi-lwa-cli/actions)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/c770eabee7bf7a9acf6a41a75b594056a71e82614121cfe59402ab82328068dd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f73706170692d6c77612d636c692f6261636b77617264735f636f6d7061746962696c6974792e796d6c3f6c6162656c3d6261636b77617264735f636f6d7061746962696c697479)](https://github.com/zero-to-prod/spapi-lwa-cli/actions)[![Packagist Downloads](https://camo.githubusercontent.com/17b4c7f899bdbde64c6515edb1fb8ff6b9e10745b8bafc9b5ed8edd4afc8b858/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a65726f2d746f2d70726f642f73706170692d6c77612d636c693f636f6c6f723d626c7565)](https://packagist.org/packages/zero-to-prod/spapi-lwa-cli/stats)[![php](https://camo.githubusercontent.com/2f98a2cbfcc0ac3536b38759065618556b58dd9abf41e18af27b8d305b0365a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a65726f2d746f2d70726f642f73706170692d6c77612d636c692e7376673f636f6c6f723d707572706c65)](https://packagist.org/packages/zero-to-prod/spapi-lwa-cli/stats)[![Packagist Version](https://camo.githubusercontent.com/ada858c9ce27819259f4d84c786dbe2b784a5a405266ae476f59ceb17206f97d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a65726f2d746f2d70726f642f73706170692d6c77612d636c693f636f6c6f723d663238643161)](https://packagist.org/packages/zero-to-prod/spapi-lwa-cli)[![License](https://camo.githubusercontent.com/976059a20c0ab4e95f2b5a53d3987765d07bb402ee5142df988e9e9bd337bd4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a65726f2d746f2d70726f642f73706170692d6c77612d636c693f636f6c6f723d70696e6b)](https://github.com/zero-to-prod/spapi-lwa-cli/blob/main/LICENSE.md)[![wakatime](https://camo.githubusercontent.com/44ff96163ffa5d020940fd1e8c462b6459a6e1da700bf6c4122cf9bd2abf34a1/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f6769746875622f7a65726f2d746f2d70726f642f73706170692d6c77612d636c692e737667)](https://wakatime.com/badge/github/zero-to-prod/spapi-lwa-cli)[![Hits-of-Code](https://camo.githubusercontent.com/026f1ce11511373ac2d38d4bfa6159bee456934fb47458a61d1346447f2ae71b/68747470733a2f2f686974736f66636f64652e636f6d2f6769746875622f7a65726f2d746f2d70726f642f73706170692d6c77612d636c693f6272616e63683d6d61696e)](https://hitsofcode.com/github/zero-to-prod/spapi-lwa-cli/view?branch=main)

Contents
--------

[](#contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Documentation Publishing](#documentation-publishing)
    - [Automatic Documentation Publishing](#automatic-documentation-publishing)
- [Usage](#usage)
    - [Available Commands](#available-commands)
        - [`spapi-lwa-cli:refresh-token`](#spapi-lwa-clirefresh-token)
        - [`spapi-lwa-cli:client-credentials`](#spapi-lwa-cliclient-credentials)
        - [`spapi-lwa-cli:src`](#spapi-lwa-clisrc)
- [Docker Image](#docker-image)
- [Local Development](./LOCAL_DEVELOPMENT.md)
- [Image Development](./IMAGE_DEVELOPMENT.md)
- [Contributing](#contributing)

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

[](#introduction)

A CLI for connecting to Amazons Selling Partner API with [Login With Amazon](https://developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api) (LWA).

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

[](#requirements)

- PHP 8.1 or higher.

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

[](#installation)

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

```
composer require zero-to-prod/spapi-lwa-cli
```

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-lwa-cli)
vendor/bin/zero-to-prod-spapi-lwa-cli

# Publish to custom directory
vendor/bin/zero-to-prod-spapi-lwa-cli /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-lwa-cli"
        ],
        "post-update-cmd": [
            "zero-to-prod-spapi-lwa-cli"
        ]
    }
}
```

Usage
-----

[](#usage)

Run this command to see the available commands:

```
vendor/bin/spapi-lwa-cli list
```

### Available Commands

[](#available-commands)

#### `spapi-lwa-cli:refresh-token`

[](#spapi-lwa-clirefresh-token)

**Description**: Login With Amazon with a refresh\_token.

**Usage**:

```
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token [options]
```

**Arguments**:

- `refresh_token` (required): The LWA refresh token
- `client_id` (required): Get this value when you register your application
- `client_secret` (required): Get this value when you register your application

**Options**:

- `--user_agent[=USER_AGENT]`: User Agent
- `--response`: Returns the full response
- `--refresh_token`: Returns the refresh\_token
- `--token_type`: Returns the token\_type
- `--expires_in`: Returns expires\_in

**Examples**:

```
# Get access token (default behavior)
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret"

# Get the full response
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret" --response

# Get only the token type
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret" --token_type

# With custom user agent
vendor/bin/spapi-lwa-cli spapi-lwa-cli:refresh-token "your-refresh-token" "your-client-id" "your-client-secret" --user_agent="MyApp/1.0"
```

**Sample Output** (access token):

```
Atzr|IwEBIAxHQiJEuOjl-123456789abcdef...

```

**Sample Output** (full response with `--response`):

```
{
    "response": {
        "access_token": "Atzr|IwEBIAxHQiJEuOjl-123456789abcdef...",
        "token_type": "bearer",
        "expires_in": 3600,
        "refresh_token": "Atzr|IwEBIA..."
    },
    "info": {
        "url": "https://api.amazon.com/auth/o2/token",
        "content_type": "application/json; charset=utf-8",
        "http_code": 200,
        "total_time": 0.234567
    }
}
```

#### `spapi-lwa-cli:client-credentials`

[](#spapi-lwa-cliclient-credentials)

**Description**: Login With Amazon with client credentials.

**Usage**:

```
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials [options]
```

**Arguments**:

- `scope` (required): The scope of the LWA authorization grant
- `client_id` (required): Get this value when you register your application
- `client_secret` (required): Get this value when you register your application

**Options**:

- `--user_agent[=USER_AGENT]`: User Agent
- `--response`: Returns the full response
- `--scope`: Returns the scope
- `--token_type`: Returns the token\_type
- `--expires_in`: Returns expires\_in

**Examples**:

```
# Get access token (default behavior)
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret"

# Get the full response
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret" --response

# Get only the scope
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret" --scope

# With custom user agent
vendor/bin/spapi-lwa-cli spapi-lwa-cli:client-credentials "sellingpartnerapi::notifications" "your-client-id" "your-client-secret" --user_agent="MyApp/1.0"
```

**Sample Output** (access token):

```
Atza|IwEBIAxHQiJEuOjl-987654321fedcba...

```

**Sample Output** (full response with `--response`):

```
{
    "response": {
        "access_token": "Atza|IwEBIAxHQiJEuOjl-987654321fedcba...",
        "scope": "sellingpartnerapi::notifications",
        "token_type": "bearer",
        "expires_in": 3600
    },
    "info": {
        "url": "https://api.amazon.com/auth/o2/token",
        "content_type": "application/json; charset=utf-8",
        "http_code": 200,
        "total_time": 0.567890
    }
}
```

#### `spapi-lwa-cli:src`

[](#spapi-lwa-clisrc)

**Description**: Project source link

**Usage**:

```
vendor/bin/spapi-lwa-cli spapi-lwa-cli:src
```

**Arguments**: None

**Options**: None

**Example**:

```
vendor/bin/spapi-lwa-cli spapi-lwa-cli:src
```

**Sample Output**:

```
https://github.com/zero-to-prod/spapi-lwa-cli

```

Docker Image
------------

[](#docker-image)

You can also run the cli using the [docker image](https://hub.docker.com/repository/docker/davidsmith3/spapi-lwa-cli/general):

```
docker run --rm davidsmith3/spapi-lwa-cli
```

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

[](#contributing)

Contributions, issues, and feature requests are welcome! Feel free to check the [issues](https://github.com/zero-to-prod/spapi-lwa-cli/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

Maintenance52

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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 ~0 days

Total

5

Last Release

471d ago

Major Versions

v1.0.1 → v2.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 (15 commits)")

---

Tags

zero-to-prodspapi-lwa-cli

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[shel/neos-terminal

Neos CMS Ui terminal for running Eel expressions and other commands

1441.3k](/packages/shel-neos-terminal)

PHPackages © 2026

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