SDKs & Libraries

Official SDKs for integrating Soledgic into your application.

📦

TypeScript / JavaScript

Our TypeScript SDK provides type-safe access to all Soledgic APIs.

Installation

npm install @soledgic/sdk

Usage

import { Soledgic } from '@soledgic/sdk';

// Initialize with your API key
const soledgic = new Soledgic(process.env.SOLEDGIC_API_KEY);

// Record a sale
const sale = await soledgic.recordSale({
  referenceId: 'order_123',
  creatorId: 'creator_456',
  amount: 2999, // $29.99 in cents
  description: 'Digital product sale'
});

console.log(sale.transactionId);
// => "txn_abc123"

console.log(sale.breakdown);
// => { total: 29.99, creatorAmount: 23.99, platformAmount: 6.00 }

More Examples

// Get a creator's balance
const balance = await soledgic.getBalance('creator_456');
console.log(`Available: $${balance.available}`);

// Process a payout
const payout = await soledgic.processPayout({
  creatorId: 'creator_456',
  paymentMethod: 'stripe'
});

// Record a refund
const refund = await soledgic.recordRefund({
  originalSaleReference: 'order_123',
  reason: 'Customer requested'
});

// Get transactions
const transactions = await soledgic.getTransactions({
  creatorId: 'creator_456',
  type: 'sale',
  startDate: '2025-01-01',
  perPage: 50
});
🐍

Python

Our Python SDK works with Python 3.8 and above.

Installation

pip install soledgic

Usage

import os
from soledgic import Soledgic

# Initialize with your API key
client = Soledgic(api_key=os.environ['SOLEDGIC_API_KEY'])

# Record a sale
sale = client.record_sale(
    reference_id='order_123',
    creator_id='creator_456',
    amount=2999,  # $29.99 in cents
    description='Digital product sale'
)

print(f"Transaction ID: {sale.transaction_id}")
print(f"Creator earns: ${sale.breakdown.creator_amount}")

# Get a creator's balance
balance = client.get_balance('creator_456')
print(f"Available: ${balance.available}")

# Process a payout
payout = client.process_payout(
    creator_id='creator_456',
    payment_method='stripe'
)
🌐

REST API

Don't see your language? Use our REST API directly with any HTTP client.

cURL Example

curl -X POST https://api.soledgic.com/v1/record-sale \
  -H "x-api-key: sk_test_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "reference_id": "order_123",
    "creator_id": "creator_456",
    "amount": 2999,
    "description": "Digital product sale"
  }'

Ruby

require 'net/http'
require 'json'

uri = URI('https://api.soledgic.com/v1/record-sale')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['x-api-key'] = ENV['SOLEDGIC_API_KEY']
request['Content-Type'] = 'application/json'
request.body = {
  reference_id: 'order_123',
  creator_id: 'creator_456',
  amount: 2999
}.to_json

response = http.request(request)
result = JSON.parse(response.body)

Go

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
    "os"
)

func recordSale() {
    payload := map[string]interface{}{
        "reference_id": "order_123",
        "creator_id":   "creator_456",
        "amount":       2999,
    }

    body, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST",
        "https://api.soledgic.com/v1/record-sale",
        bytes.NewBuffer(body))

    req.Header.Set("x-api-key", os.Getenv("SOLEDGIC_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
}

Webhook Helpers

Our SDKs include helpers for verifying webhook signatures.

TypeScript

import { Soledgic } from '@soledgic/sdk';

const soledgic = new Soledgic(process.env.SOLEDGIC_API_KEY);

// Verify webhook signature
const isValid = soledgic.webhooks.verifySignature(
  payload,
  signature,
  webhookSecret
);

// Parse webhook event
const event = soledgic.webhooks.parseEvent(payload);

if (event.type === 'sale.created') {
  console.log('New sale:', event.data.transaction_id);
}

Python

from soledgic import Soledgic

client = Soledgic(api_key=os.environ['SOLEDGIC_API_KEY'])

# Verify webhook signature
is_valid = client.webhooks.verify_signature(
    payload=payload,
    signature=signature,
    secret=webhook_secret
)

# Parse webhook event
event = client.webhooks.parse_event(payload)

if event.type == 'sale.created':
    print(f"New sale: {event.data['transaction_id']}")

Resources