Volcano API

📚 SDKs & Libraries

Official SDKs and community libraries for Card Market API

SDKs & Libraries

Speed up your development with our official SDKs and community-maintained libraries. Choose from a variety of programming languages and frameworks.

Official SDKs

Our official SDKs are maintained by the Card Market team and include full TypeScript support, comprehensive error handling, and automatic retries.

JavaScript/TypeScript SDK

Our JavaScript SDK supports both Node.js and browser environments with full TypeScript support.

Installation

npm:

npm install @cardmarket/api-sdk

yarn:

yarn add @cardmarket/api-sdk

pnpm:

pnpm add @cardmarket/api-sdk

Quick Start

import { CardMarketAPI } from '@cardmarket/api-sdk';

// Initialize with API key
const api = new CardMarketAPI({
  apiKey: 'your-api-key-here',
  environment: 'production' // or 'sandbox'
});

// Make API calls
async function example() {
  try {
    // Get user information
    const user = await api.users.getCurrentUser();
    console.log('User:', user);

    // Create an order
    const order = await api.orders.create({
      cardId: 'card-123',
      quantity: 1,
      price: 99.99
    });
    console.log('Order created:', order);

    // Get wallet address
    const address = await api.wallet.getAddress({
      type: 'user',
      chainType: 'USDT'
    });
    console.log('Wallet address:', address);
  } catch (error) {
    console.error('API Error:', error);
  }
}

Authentication

// API Key authentication (for server-side)
const api = new CardMarketAPI({
  apiKey: 'your-api-key-here'
});

// Bearer token authentication (for user sessions)
const api = new CardMarketAPI({
  bearerToken: 'user-bearer-token'
});

// Dynamic token management
api.setAuthToken('new-bearer-token');

Advanced Features

// Custom configuration
const api = new CardMarketAPI({
  apiKey: 'your-api-key',
  baseURL: 'https://api.market.decenctype.com',
  timeout: 10000,
  retries: 3,
  retryDelay: 1000
});

// Webhook handling
api.webhooks.verify(payload, signature, secret);

// Pagination
const orders = await api.orders.list({
  page: 1,
  limit: 50,
  status: 'completed'
});

Python SDK

Our Python SDK supports both synchronous and asynchronous operations with full type hints.

Installation

pip install cardmarket-api-sdk

Quick Start

from cardmarket import CardMarketAPI

# Initialize client
api = CardMarketAPI(api_key='your-api-key-here')

# Synchronous usage
user = api.users.get_current_user()
print(f"User: {user}")

# Create an order
order = api.orders.create(
    card_id='card-123',
    quantity=1,
    price=99.99
)
print(f"Order created: {order}")

# Async usage
import asyncio

async def async_example():
    async_api = CardMarketAPI(api_key='your-api-key', async_mode=True)
    
    user = await async_api.users.get_current_user()
    orders = await async_api.orders.list(status='completed')
    
    await async_api.close()

asyncio.run(async_example())

Error Handling

from cardmarket import CardMarketAPI, CardMarketError, RateLimitError

api = CardMarketAPI(api_key='your-api-key')

try:
    user = api.users.get_current_user()
except RateLimitError as e:
    print(f"Rate limit exceeded. Retry after: {e.retry_after}")
except CardMarketError as e:
    print(f"API Error: {e.message} (Code: {e.code})")
except Exception as e:
    print(f"Unexpected error: {e}")

Django Integration

# settings.py
CARDMARKET_API_KEY = 'your-api-key-here'

# views.py
from django.conf import settings
from cardmarket import CardMarketAPI

api = CardMarketAPI(api_key=settings.CARDMARKET_API_KEY)

def user_profile(request):
    try:
        user_data = api.users.get_current_user()
        return JsonResponse({'user': user_data})
    except CardMarketError as e:
        return JsonResponse({'error': str(e)}, status=400)

Go SDK

High-performance Go SDK with comprehensive error handling and built-in retries.

Installation

go get github.com/cardmarket/cardmarket-go

Quick Start

package main

import (
    "context"
    "fmt"
    "log"
    
    "github.com/cardmarket/cardmarket-go"
)

func main() {
    // Initialize client
    client := cardmarket.NewClient("your-api-key-here")
    
    ctx := context.Background()
    
    // Get user information
    user, err := client.Users.GetCurrent(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("User: %+v\n", user)
    
    // Create an order
    order, err := client.Orders.Create(ctx, &cardmarket.CreateOrderRequest{
        CardID:   "card-123",
        Quantity: 1,
        Price:    99.99,
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Order created: %+v\n", order)
}

Configuration

// Custom configuration
config := cardmarket.Config{
    APIKey:     "your-api-key",
    BaseURL:    "https://api.market.decenctype.com",
    Timeout:    30 * time.Second,
    MaxRetries: 3,
    RetryDelay: time.Second,
}

client := cardmarket.NewClientWithConfig(config)

Middleware Support

// Custom middleware
client.Use(func(next cardmarket.RoundTripper) cardmarket.RoundTripper {
    return cardmarket.RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
        // Add custom headers
        req.Header.Set("X-Custom-Header", "value")
        
        // Log request
        log.Printf("Making request to: %s", req.URL)
        
        return next.RoundTrip(req)
    })
})

PHP SDK

Modern PHP SDK with PSR-7 compatibility and comprehensive documentation.

Installation

composer require cardmarket/api-sdk

Quick Start

<?php
require_once 'vendor/autoload.php';

use CardMarket\ApiClient;
use CardMarket\Configuration;

// Initialize client
$config = Configuration::getDefaultConfiguration()
    ->setApiKey('X-API-KEY', 'your-api-key-here');

$client = new ApiClient($config);

try {
    // Get user information
    $user = $client->users()->getCurrentUser();
    echo "User: " . json_encode($user) . "\n";
    
    // Create an order
    $order = $client->orders()->create([
        'cardId' => 'card-123',
        'quantity' => 1,
        'price' => 99.99
    ]);
    echo "Order created: " . json_encode($order) . "\n";
    
} catch (CardMarket\ApiException $e) {
    echo "API Error: " . $e->getMessage() . "\n";
    echo "Response body: " . $e->getResponseBody() . "\n";
}

Laravel Integration

// config/cardmarket.php
return [
    'api_key' => env('CARDMARKET_API_KEY'),
    'environment' => env('CARDMARKET_ENV', 'production'),
];

// Service Provider
use CardMarket\ApiClient;
use CardMarket\Configuration;

$this->app->singleton(ApiClient::class, function ($app) {
    $config = Configuration::getDefaultConfiguration()
        ->setApiKey('X-API-KEY', config('cardmarket.api_key'));
    
    return new ApiClient($config);
});

// Controller
use CardMarket\ApiClient;

class UserController extends Controller
{
    public function show(ApiClient $client)
    {
        try {
            $user = $client->users()->getCurrentUser();
            return response()->json($user);
        } catch (CardMarket\ApiException $e) {
            return response()->json(['error' => $e->getMessage()], 400);
        }
    }
}

Community Libraries

These libraries are maintained by the community. While not officially supported, they provide additional options for integration.

LanguageLibraryMaintainerGitHub
Rubycardmarket-ruby@rubydevLink
Javacardmarket-java@javamasterLink
C#CardMarket.NET@dotnetproLink
Rustcardmarket-rs@rustaceanLink

SDK Features Comparison

FeatureJavaScriptPythonGoPHP
TypeScript Support
Async/Await
Automatic Retries
Webhook Verification
Rate Limit Handling
Pagination Support
Custom Headers
Middleware Support

Getting Support

Need help with our SDKs? Here are your options:

  • GitHub Issues: Report bugs or request features on each SDK's repository
  • Documentation: Comprehensive guides and API reference for each SDK
  • Discord Community: Get help from other developers using our SDKs
  • Email Support: Reach out to our team at sdk-support@cardmarket.com

Contributing

We welcome contributions to our SDKs! Each repository has its own contribution guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for your changes
  4. Submit a pull request

Looking for a specific language? Let us know what SDK you'd like to see next by creating an issue in our SDK roadmap repository.