PHPackages                             ditshej/op-cards-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. ditshej/op-cards-php

ActiveLibrary[API Development](/categories/api)

ditshej/op-cards-php
====================

PHP SDK for the One Piece TCG card API

v0.1.0(2mo ago)01MITPHPPHP ^8.4CI passing

Since May 18Pushed 2mo agoCompare

[ Source](https://github.com/ditshej/op-cards-php)[ Packagist](https://packagist.org/packages/ditshej/op-cards-php)[ RSS](/packages/ditshej-op-cards-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (6)Versions (3)Used By (0)

op-cards-php
============

[](#op-cards-php)

[![CI](https://github.com/ditshej/op-cards-php/actions/workflows/ci.yml/badge.svg)](https://github.com/ditshej/op-cards-php/actions/workflows/ci.yml/badge.svg)[![Packagist Version](https://camo.githubusercontent.com/2eb976e5d6d91927bfd1cb811f8ac1c923aafdb6c12f07a28d8b9553c2f882ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469747368656a2f6f702d63617264732d706870)](https://packagist.org/packages/ditshej/op-cards-php)[![License](https://camo.githubusercontent.com/b7c2feebbaf4ddea77867836e214bfe110168e28e742806f20b507c435ee6bcd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6469747368656a2f6f702d63617264732d706870)](LICENSE)

PHP client library for [one-piece-cards-api](https://github.com/ditshej/one-piece-cards-api) — a self-hostable HTTP API serving One Piece TCG card data. Use this package to talk to **your own** instance of that API from any PHP application. Framework-agnostic core with optional Laravel integration.

---

How it works
------------

[](#how-it-works)

This SDK does not call any shared or public service. You bring your own backend:

1. Install and host [one-piece-cards-api](https://github.com/ditshej/one-piece-cards-api) on a server you control. It exposes the HTTP endpoints (`/packs`, `/cards`, …) and issues bearer tokens.
2. Install this package in your PHP project and point it at your instance's base URL and token.

> **Note:** `op-cards.ditshej.ch` is the maintainer's private instance and is not a public API. Replace it with your own host in the examples below.

---

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

[](#installation)

```
composer require ditshej/op-cards-php
```

Requires PHP 8.4+ and `guzzlehttp/guzzle`.

---

Configuration
-------------

[](#configuration)

The client requires two values:

VariableDescription`OPCARDS_TOKEN`Bearer token issued by your API instance`OPCARDS_BASE_URI`Base URL of your API instance, e.g. `https://op-cards.ditshej.ch/api/v1/` *(maintainer's instance — replace with yours)*---

Standalone usage
----------------

[](#standalone-usage)

```
use Ditshej\OpCards\OpCardsClient;

$client = new OpCardsClient(
    token: $_ENV['OPCARDS_TOKEN'],
    baseUri: $_ENV['OPCARDS_BASE_URI'],
);
```

---

Laravel integration
-------------------

[](#laravel-integration)

The package supports auto-discovery. Once installed, the `OpCardsServiceProvider` is registered automatically.

Add the credentials to your `.env`:

```
OPCARDS_TOKEN=your-token
OPCARDS_BASE_URI=https://op-cards.ditshej.ch/api/v1/  # maintainer's instance — replace with yours
```

Optionally publish the config file:

```
php artisan vendor:publish --tag=opcards-config
```

This creates `config/opcards.php` where you can override the values.

Use the Facade anywhere in your Laravel app:

```
use Ditshej\OpCards\Laravel\Facades\OpCards;

$packs = OpCards::packs();
```

Or inject `OpCardsClient` directly:

```
use Ditshej\OpCards\OpCardsClient;

class CardController extends Controller
{
    public function __construct(private OpCardsClient $client) {}
}
```

---

Available methods
-----------------

[](#available-methods)

MethodReturnsDescription`packs()``PackResource[]`All available card packs`pack(string $id)``PackResource`Single pack by ID`cards(?CardFilter $filter)``array{data: CardResource[], meta: array}`Paginated card list, optionally filtered`card(string $id)``CardResource`Single card by ID`allCards(?CardFilter $filter)``CardResource[]`All cards across all pages, flat array---

Filtering cards
---------------

[](#filtering-cards)

`CardFilter` is a fluent builder for the `cards()` and `allCards()` endpoints:

```
use Ditshej\OpCards\Filters\CardFilter;

// Paginated — single page
$result = $client->cards(
    (new CardFilter)
        ->color('Red')
        ->cost(3, 5, 7)      // multi-value: cost=3 OR cost=5 OR cost=7
        ->rarity('L')
        ->perPage(50)
        ->page(2)
);

$cards = $result['data']; // CardResource[]
$meta  = $result['meta']; // current_page, last_page, per_page, total

// Fetch all pages automatically
$allCards = $client->allCards(
    (new CardFilter)->color('Red')->pack('OP01')
);
```

### All filter methods

[](#all-filter-methods)

MethodDescription`color(string $value)`Card color (e.g. `'Red'`, `'Blue'`)`category(string $value)`Card category (e.g. `'Character'`, `'Event'`)`cost(int ...$values)`Exact cost — single value or multiple`costBetween(int $min, int $max)`Cost range (inclusive)`powerBetween(int $min, int $max)`Power range (inclusive)`rarity(string $value)`Rarity (e.g. `'L'`, `'R'`, `'C'`)`attribute(string $value)`Attribute (e.g. `'Strike'`, `'Slash'`)`type(string $value)`Card type / crew name`keyword(string $value)`Keyword ability`pack(string $id)`Filter by pack ID`cardSet(string $value)`Filter by card set (e.g. `'OP-01'`)`search(string $query)`Full-text search`altArt(bool $value)`Include/exclude alternate art variants`perPage(int $value)`Results per page`page(int $value)`Page number---

Error handling
--------------

[](#error-handling)

All API errors throw exceptions that extend `Ditshej\OpCards\Exceptions\ApiException`:

ExceptionHTTP status`AuthenticationException`401`NotFoundException`404`RateLimitException`429`ApiException`all other errorsAll exceptions expose `getStatusCode(): int` in addition to the standard `getMessage()` and `getCode()`.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance86

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

67d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11797064?v=4)[Raphi W](/maintainers/ditshej)[@ditshej](https://github.com/ditshej)

---

Top Contributors

[![ditshej](https://avatars.githubusercontent.com/u/11797064?v=4)](https://github.com/ditshej "ditshej (88 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ditshej-op-cards-php/health.svg)

```
[![Health](https://phpackages.com/badges/ditshej-op-cards-php/health.svg)](https://phpackages.com/packages/ditshej-op-cards-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1943.1k5](/packages/aimeos-prisma)[volcengine/volcengine-php-sdk

118.7k](/packages/volcengine-volcengine-php-sdk)

PHPackages © 2026

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