Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.smartretry.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

SmartRetry provides official SDKs and supports community libraries to simplify integration in your preferred language.

Official SDKs

Python

Official Python SDK with full API coverage, type hints, and async support.

Node.js

Official Node.js SDK with TypeScript definitions and Promise-based API.

Installation

Install the SmartRetry Python SDK using pip:
pip install smartretry
Or with Poetry:
poetry add smartretry
Requirements: Python 3.8+

Quick start

from smartretry import SmartRetry

# Initialize the client
client = SmartRetry(
    api_key="YOUR_API_KEY",
    environment="sandbox"  # or "production"
)

# Create a sale
result = client.payments.sale(
    terminal_id="ABC123",
    amount=49.99,
    currency="USD",
    merchant_transaction_id="order-123",
    order={
        "payment_instrument": {
            "card_number": "4111111111111111",
            "expiry_month": 12,
            "expiry_year": 2027,
            "payment_method": "cards"
        },
        "payer": {
            "first_name": "Jane",
            "last_name": "Doe",
            "email": "jane@example.com"
        }
    },
    idempotency_key="order-123"
)

print(f"Transaction ID: {result.transaction_id}")
print(f"Accepted: {result.accepted}")

SDK features

Both official SDKs include:
FeatureDescription
Full API coverageAll endpoints from payments to recurring to future transactions
Type safetyFull type hints (Python) and TypeScript definitions (Node.js)
Automatic retriesBuilt-in exponential backoff for rate limits and transient errors
IdempotencyAutomatic idempotency key generation and handling
Error handlingTyped exceptions with detailed error information
Webhook verificationHelper methods to verify webhook signatures
Async supportNative async/await patterns

Error handling

from smartretry import SmartRetry
from smartretry.exceptions import (
    SmartRetryError,
    ValidationError,
    AuthenticationError,
    RateLimitError,
    APIError
)

client = SmartRetry(api_key="YOUR_API_KEY")

try:
    result = client.payments.sale(...)
except ValidationError as e:
    print(f"Invalid request: {e.detail}")
    print(f"Field: {e.reason_code}")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except APIError as e:
    print(f"API error: {e.status_code} - {e.detail}")
except SmartRetryError as e:
    print(f"Unexpected error: {e}")

Webhook verification

from smartretry import SmartRetry
from flask import Flask, request

app = Flask(__name__)
client = SmartRetry(api_key="YOUR_API_KEY")

@app.route("/webhooks", methods=["POST"])
def handle_webhook():
    payload = request.data
    signature = request.headers.get("X-SmartRetry-Signature")

    try:
        event = client.webhooks.verify(
            payload=payload,
            signature=signature,
            secret="YOUR_WEBHOOK_SECRET"
        )

        if event.type == "transaction.approved":
            handle_approval(event.data)
        elif event.type == "transaction.declined":
            handle_decline(event.data)

        return "", 200
    except client.webhooks.SignatureVerificationError:
        return "Invalid signature", 400

Direct API access

If you prefer not to use an SDK, you can call the REST API directly using any HTTP client. See the REST API documentation and individual endpoint pages for request/response formats. All API endpoints include code examples in cURL, Python (requests), and Node.js (fetch).
Even when using direct HTTP calls, we recommend implementing the retry logic and error handling patterns shown in the rate limiting guide.

Community libraries

The following community-maintained libraries are available but not officially supported:
LanguageLibraryMaintainer
Rubysmartretry-rubyCommunity
PHPsmartretry-phpCommunity
Gogo-smartretryCommunity
Javasmartretry-javaCommunity
Community libraries are not maintained by SmartRetry. Review the code and check for recent updates before using in production.

Need help?