Skip to main content

PHP SDK Overview

The Trading Card API PHP SDK is a modern Laravel package that provides a clean, type-safe interface for accessing trading card data. Built specifically for Laravel applications with comprehensive error handling and OAuth2 authentication.

Quick Navigation​

What You'll Find Here​

This comprehensive documentation covers everything you need to successfully integrate the Trading Card API PHP SDK into your Laravel applications:

🚀 Getting Started​

Complete installation guide with Laravel-specific setup, environment configuration, and credential management.

💡 Usage Patterns​

Three different ways to use the SDK - facades, helper functions, and direct class usage - with examples for each approach.

📚 Complete API Reference​

Detailed documentation for all 10+ available resources including Cards, Sets, Players, Teams, Genres, and more with practical examples.

🛡️ Error Handling​

Comprehensive exception hierarchy with specific handling for authentication, validation, rate limiting, and network errors.

🏗️ Real-World Examples​

Production-ready code examples for common use cases like price tracking, collection management, and marketplace integration.

Key Features​

  • Laravel Integration: Native Laravel service provider, facades, and helper functions
  • Type Safety: Full PHPStan Level 4 compliance with strict typing
  • OAuth2 Authentication: Automatic token management and renewal
  • Comprehensive Error Handling: Specific exception classes for different error types
  • Rate Limiting: Built-in rate limit handling with retry logic
  • Well Tested: 80%+ test coverage with comprehensive test suite

Current Version​

Latest Stable: v0.1.0 (Released September 15, 2025)

  • Initial stable release with complete API coverage
  • Enhanced error handling and Laravel integration
  • Support for PHP 8.1+ and Laravel 10.x+

📋 View complete changelog →

Quick Installation​

# Install via Composer
composer require cardtechie/tradingcardapi-sdk-php

# Publish Laravel configuration
php artisan vendor:publish --tag="tradingcardapi-config"

# Add credentials to .env
TRADINGCARDAPI_CLIENT_ID=your_client_id
TRADINGCARDAPI_CLIENT_SECRET=your_client_secret

Basic Usage​

// Using the facade (recommended)
use CardTechie\TradingCardApiSdk\Facades\TradingCardApiSdk;

$card = TradingCardApiSdk::card()->get('card-id');
$cards = TradingCardApiSdk::card()->getList(['name' => 'Pikachu']);

// Using the helper function
$set = tradingcardapi()->set()->get('set-id', ['include' => 'cards']);

// Direct class usage (for dependency injection)
use CardTechie\TradingCardApiSdk\TradingCardApi;

class CardService
{
public function __construct(private TradingCardApi $api) {}

public function getCards(): array
{
return $this->api->card()->getList();
}
}

Requirements​

  • PHP: 8.1 or higher
  • Laravel: 10.0 or higher
  • GuzzleHTTP: 7.5 or higher
  • Composer: For installation

Support & Contributing​

License​

This SDK is open-source software licensed under the MIT License.