2 3 4 5
Keys SDK Call Hooks Live
Step 2 of 5 ยท ~5 min

Install the SDK

Add the Payments SDK to your project, load your API key from the environment variable you created in Step 1, and verify the installation with a single test request.

1
Install the package
# npm
npm install @paymentsapi/sdk

# or yarn
yarn add @paymentsapi/sdk

# Verify installation
node -e "const p = require('@paymentsapi/sdk'); console.log(p.VERSION);"
# pip
pip install paymentsapi

# or with uv / pipenv
uv add paymentsapi

# Verify installation
python -c "import paymentsapi; print(paymentsapi.__version__)"
Minimum versions
Node.js 18 LTS or later ยท Python 3.9 or later. The SDK uses native fetch in Node and httpx in Python for async support.
2
Initialize the client

Create a single client instance and reuse it across your application. Never instantiate it inside a request handler โ€” that needlessly creates connections on every call.

// src/lib/payments.js โ€” instantiate once, export, import everywhere
require('dotenv').config();
const { PaymentsClient } = require('@paymentsapi/sdk');

const apiKey = process.env.PAYMENTS_SECRET_KEY;
if (!apiKey) {
  throw new Error('PAYMENTS_SECRET_KEY environment variable is not set');
}

const payments = new PaymentsClient({ apiKey });

module.exports = { payments };
# src/lib/payments.py โ€” instantiate once, import everywhere
import os
from dotenv import load_dotenv
from paymentsapi import PaymentsClient

load_dotenv()

api_key = os.environ.get("PAYMENTS_SECRET_KEY")
if not api_key:
    raise EnvironmentError("PAYMENTS_SECRET_KEY environment variable is not set")

payments = PaymentsClient(api_key=api_key)
3
Verify the connection with a ping

Run a lightweight credential check against the sandbox before building anything further. This confirms your key is valid and the SDK is configured correctly.

const { payments } = require('./lib/payments');

async function verify() {
  const result = await payments.ping();
  console.log(result);
  // Expected: { status: 'ok', environment: 'sandbox', account_id: 'acct_...' }
}

verify();
from src.lib.payments import payments

result = payments.ping()
print(result)
# Expected: {'status': 'ok', 'environment': 'sandbox', 'account_id': 'acct_...'}
curl https://api.paymentsapi.dev/v1/ping \
  -H "Authorization: Bearer $PAYMENTS_SECRET_KEY"

# Expected response:
# {
#   "status": "ok",
#   "environment": "sandbox",
#   "account_id": "acct_..."
# }
Expected output
If you see { "status": "ok", "environment": "sandbox" } โ€” your SDK is correctly installed and authenticated. Proceed to Step 3.
Step 2 Checklist
โ† Step 1