Download the PHP package cardtechie/tradingcardapi-sdk-php without Composer
On this page you can find all versions of the php package cardtechie/tradingcardapi-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cardtechie/tradingcardapi-sdk-php
More information about cardtechie/tradingcardapi-sdk-php
Files in cardtechie/tradingcardapi-sdk-php
Package tradingcardapi-sdk-php
Short Description Official PHP SDK for Trading Card API - comprehensive tools for accessing trading card data, players, sets, and market information with enhanced error handling and Laravel integration
License MIT
Homepage https://github.com/cardtechie/tradingcardapi-sdk-php
Informations about the package tradingcardapi-sdk-php
Trading Card API SDK for PHP
A modern PHP SDK for integrating with the Trading Card API. This Laravel package provides a clean, type-safe interface for accessing trading card data including cards, sets, players, teams, and more.
โจ Features
- ๐ง Laravel Integration - Built specifically for Laravel applications
- ๐ก๏ธ Type Safety - Full PHPStan Level 4 compliance with strict typing
- ๐งช Well Tested - Comprehensive test suite (Pest) covering the SDK's public surface
- ๐ฆ Easy Installation - Simple Composer installation and configuration
- ๐ OAuth2 Authentication - Automatic token management and renewal
- ๐จ Enhanced Error Handling - Specific exception classes for different error types
- ๐ Rich Documentation - Clear examples and comprehensive API coverage
- โก Built on Guzzle - HTTP transport via the battle-tested GuzzleHTTP client
๐ Requirements
- PHP 8.2 or higher
- Laravel 10.0 or higher
- GuzzleHTTP 7.5 or higher
๐ Installation
Install the package via Composer:
Publish the configuration file:
Add your API credentials to your .env file:
๐ฏ Quick Start
Using the Facade
Using the Helper Function
Error Handling
The SDK provides comprehensive error handling with specific exception classes:
Direct Class Usage
Meta and links
Top-level JSON:API meta and links are document-scoped โ they describe the
whole response (pagination totals, self/next/prev links). The SDK attaches
them to the main parsed object only, and you read them with getMeta() /
getLinks():
Included relationship models do not carry the top-level meta/links โ calling
getMeta() / getLinks() on an included model returns an empty stdClass by
design. Document-scoped links describe the main collection, so copying them onto
an included resource (e.g. a sideloaded Player) would be misleading.
๐ฅ Working with Players
The Player resource provides comprehensive CRUD operations and relationship management:
Basic Operations
Listing and Searching
Player Relationships
Creating Player Hierarchies
Working with Deleted Players
Player Model Attributes
๐ Available Resources
The SDK provides access to the following Trading Card API resources:
| Resource | Description | Methods |
|---|---|---|
| Cards | Individual trading cards | get(), create(), update(), delete() |
| Sets | Card sets and collections | get(), list(), create(), update(), delete(), checklist($id), workflow($id), addMissingCards($id), addChecklist($request, $id) |
| Players | Player information | get(), list(), all(), getList() (deprecated โ use all()), create(), update(), delete(), listDeleted(), deleted($id) |
| Teams | Team data | get(), list(), all(), getList() (deprecated โ use all()), create(), update(), delete(), listDeleted(), deleted($id) |
| Genres | Card categories/types | get(), list(), create(), update(), delete(), listDeleted(), deleted($id) |
| Brands | Trading card brands | get(), list(), create(), update(), delete() |
| Manufacturers | Trading card manufacturers | get(), list(), create(), update(), delete() |
| Years | Trading card years | get(), list(), create(), update(), delete() |
| ObjectAttributes | Object attributes | get(), list(), create(), update(), delete() |
| SetSources | Set data sources | get(), list(), create(), update(), delete(), forSet($setId) |
| Stats | Entity statistics and analytics | get($type), getCounts(), getSnapshots(), getGrowth() |
| Attributes | Card attributes | get(), list(), all(), create(), update(), delete() |
| CardImages | Card image upload and management | list(), get($id), upload($file, $cardId, $imageType), update($id, $attributes), delete($id), getDownloadUrl($id, $size) |
| Internal\Workflow (internal only) | Set workflow management and bulk operations | actionableSets(), updateSetTodo($todoId, $attributes), bulkInitializeWorkflow(), getBulkInitializeStatus($jobId), getSetTodos($setId), getReviewQueue($step?, $params?), flagForReview($todoId, $reason), resolveReview($todoId, $notes?) |
| Internal\AuditLog (internal only) | Audit log tracking and creation | getAuditLogs($params?), createAuditEvent($attributes?) |
Set Names and Serial Suffixes
Set name values returned by the API now include a print-run suffix using hobby convention: /X for numbered sets (e.g. "Black Foil /10") and 1/1 for superfractors (serial = 1). The raw print run is available separately on the int|null $serial attribute, so you can read the formatted name and the numeric serial independently.
Worked examples of the different serial formats:
serial = 99โ name ends with "โฆ /99" (e.g. "Black Refractor /99")serial = 1โ name ends with "โฆ 1/1" (superfractor, e.g. "Superfractor 1/1")serial = nullโ base name with no suffix (e.g. "Base")
Stats Resource
The Stats resource provides analytics and tracking capabilities for entity counts:
SetSource Resource
The SetSource resource manages data sources for trading card sets (checklists, metadata, images):
Internal Namespace
Internal use only โ not part of the public API contract; may change without semver guarantees.
The
Internal\namespace is intended for internal callers (admin tooling, tradingcardapi-mcp, tradingcardapi-tools). Credentials must carry theinternalOAuth scope; calls will fail with a 403 if this scope is absent.
Access the internal client via $api->internal():
Internal\Workflow Resource
The internal Workflow resource manages set workflow steps (todos) and bulk initialization via /internal/* routes:
Internal\AuditLog Resource
The internal AuditLog resource provides access to audit logging endpoints via /internal/* routes:
CardImage Resource
The CardImage resource handles card image uploads and management:
๐ง Configuration
The configuration file (config/tradingcardapi.php) supports:
HTTP Timeouts
By default the SDK applies a 10-second request timeout and a 5-second connect timeout to every request. Guzzle ships with no timeout at all, so without these a hung API would block the calling PHP-FPM worker indefinitely.
| Env var | Default | Meaning |
|---|---|---|
TRADINGCARDAPI_TIMEOUT |
10 |
Total seconds to wait for a response. 0 disables. |
TRADINGCARDAPI_CONNECT_TIMEOUT |
5 |
Seconds to wait while establishing the connection. 0 disables. |
A connect timeout makes NetworkException::connectionTimeout reachable โ it
could never fire previously because no timeout was ever set.
Retry / Backoff
Retrying transient failures is opt-in (disabled by default to preserve
existing behavior). When enabled, the SDK retries 429 and 5xx responses
and connection errors with exponential backoff (base_delay * 2^(attempt-1)
ms). If a 429 carries a numeric Retry-After header, that value is honored
in preference to the computed backoff.
| Env var | Default | Meaning |
|---|---|---|
TRADINGCARDAPI_RETRY_ENABLED |
false |
Enable automatic retries. |
TRADINGCARDAPI_RETRY_MAX_ATTEMPTS |
3 |
Max retries after the initial request. |
TRADINGCARDAPI_RETRY_BASE_DELAY_MS |
1000 |
Base backoff delay in milliseconds. |
OAuth Scopes
Configure the OAuth scopes to request when authenticating. Available scopes:
read:published(default) - Access published content onlyread:draft- Access published and draft contentread:all-status- Access all content regardless of statuswrite- Create and update resourcesdelete- Delete resources
Examples
Read-only access to published content:
Admin access with full permissions:
Content management (no delete):
Multiple scopes should be separated by spaces. If not specified, the default scope (read:published) is used.
๐งช Development & Testing
This project uses modern PHP development tools and practices:
Prerequisites
- Docker and Docker Compose
- Make (optional, for convenience commands)
Getting Started
Available Commands
Code Quality Standards
This project maintains high code quality standards:
- โ PHPStan Level 4 - Strict static analysis
- โ PSR-12 - Code style compliance via Laravel Pint
- โ
Comprehensive Test Suite - Extensive coverage using Pest (run
make test-coveragefor a local report) - โ Automated CI/CD - Quality checks on all PRs
๐ Documentation
- Error Handling Guide - Comprehensive guide to exception handling
- Response Validation - Response validation and schema handling
- Version Management - Release process and versioning
- Trading Card API Documentation - Complete API reference
Upgrade Notes (0.3.0)
The 0.3.0 Resource-layer standardization introduces three consumer-visible changes:
getList()is deprecated in favor ofall()on thePlayer,Team, andPlayerteamresources.getList()still works (it delegates toall()with identical behavior) but is marked@deprecated, so static analysis (e.g. PHPStanmethod.deprecated) will flag remaining call sites. Migrate->getList(...)to->all(...).RateLimitException::__constructpositional slots were realigned with the baseTradingCardApiException:$httpStatusCode(default429) is now positional slot 6 and$contextslot 7. ConstructRateLimitExceptionwith named arguments to be safe against the slot change โ see the Error Handling Guide.- Set names now carry a print-run serial suffix (
/Xfor numbered sets,1/1for superfractors). The formattednameincludes the suffix and the raw print run is available on theserialattribute โ see Set Names and Serial Suffixes.
๐ค Contributing
We welcome contributions! Open an issue or start a thread in GitHub Discussions before submitting a pull request. See CONTRIBUTING.md for the full contributor guide โ development setup, coding standards, testing requirements, the changelog-fragment and pull-request process, and issue reporting.
Development Workflow
- Fork the repository
- Create a feature branch
- Make your changes
- Run quality checks:
make check - Submit a pull request
๐ Bug Reports & Feature Requests
Please use the GitHub Issues to report bugs or request features.
๐ Security
Please review our Security Policy for reporting security vulnerabilities.
๐ Release Process
This project uses a sophisticated, automated release management system adapted from the main Trading Card API repository.
Version Management
The SDK uses intelligent, branch-aware semantic versioning:
- Production releases (
1.2.3) - Created frommainbranch - Beta releases (
1.3.0.beta-5) - Created fromdevelopbranch - Release candidates (
1.3.0.rc-2) - Created fromrelease/*branches - Development versions (
1.2.3-alpha.4) - Feature branches
Development Commands
Automated Release Process
- Development: Features are developed on feature branches
- Integration: Changes are merged to
developfor testing - Release Preparation: Release branches are created for final testing
- Production Release: Stable releases are merged to
main - Automation: GitHub Actions handles versioning, changelog updates, and Packagist publishing
Cutting a Release
Maintainers: see the Release Runbook for the concrete,
step-by-step procedure โ how a release is cut, the required repository secrets,
how to trigger a release manually via workflow_dispatch, how to verify the
GitHub Release and Packagist update, and rollback notes.
See docs/VERSION-MANAGEMENT.md for the underlying versioning model.
๐ Changelog
See CHANGELOG.md for recent changes.
๐ฅ Credits
- Josh Harrison - Lead Developer
- All Contributors
๐ License
This project is licensed under the MIT License. See LICENSE.md for details.
Made with โค๏ธ by CardTechie
All versions of tradingcardapi-sdk-php with dependencies
guzzlehttp/guzzle Version ^7.5.0
illuminate/contracts Version ^10.0|^11.0|^12.0
spatie/laravel-package-tools Version ^1.13.0