SDKs & Libraries

Tsara provides simple RESTful APIs that can be accessed from any programming language that supports HTTP requests.
To make integration faster, you can use prebuilt snippets or your preferred HTTP client (like axios, requests, or cURL).

This section provides code examples in cURL, JavaScript, and PHP — the most common stacks for Tsara integrations.


🚀 Base Setup

Base URLs

EnvironmentBase URLDescription
Productionhttps://api.tsara.ng/v1Live environment for real payments and transfers.
Sandboxhttps://sandbox.tsara.ng/v1Safe environment for testing and development.

🔑 Authentication

All requests must include your API key as a Bearer token in the Authorization header.

Header Example

Authorization: Bearer YOUR_SECRET_KEY
Content-Type: application/json

💡 You can create and manage API keys from the Tsara Dashboard → Developers → API Keys.


⚡ Example — cURL

curl -X GET "https://sandbox.tsara.ng/v1/wallets" \
  -H "Authorization: Bearer sk_test_xxxxxxx" \
  -H "Content-Type: application/json"

⚙️ Example — JavaScript (Node.js)

Using Axios:

import axios from "axios";

const TSARA_API_KEY = "sk_test_xxxxxxx";

const client = axios.create({
  baseURL: "https://sandbox.tsara.ng/v1",
  headers: {
    "Authorization": `Bearer ${TSARA_API_KEY}`,
    "Content-Type": "application/json"
  }
});

// Example: Fetch all wallets
async function getWallets() {
  try {
    const res = await client.get("/wallets");
    console.log(res.data);
  } catch (err) {
    console.error(err.response?.data || err.message);
  }
}

getWallets();

🧩 Example — PHP

Using the built-in cURL functions or any modern HTTP library.

<?php
$apiKey = "sk_test_xxxxxxx";
$url = "https://sandbox.tsara.ng/v1/wallets";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer $apiKey",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data);
?>

🧠 Pro Tips

  1. Use the Sandbox — Always test with https://sandbox.tsara.ng/v1 before going live.
  2. Store API Keys Securely — Never expose your keys in frontend or client code.
  3. Use Environment Variables — Load keys from .env or system variables.
  4. Handle Webhooks Properly — Always verify X-Tsara-Signature for all incoming events.
  5. Retry on 5xx Errors — Implement exponential backoff for server errors.

🔗 Official Repositories

LanguageRepoStatus
PHP SDKComing soon🚧 In development
JavaScript SDKComing soon🚧 In development
Python SDKComing soon🚧 In development

Until SDKs are published, you can use the Postman Collection or the examples provided here.


🧾 Postman Collection

You can import the official Tsara Postman Collection to explore and test all endpoints quickly.

File: tsara-postman-collection.json
How to use:

  1. Open Postman → Import → Upload File.
  2. Select the JSON file generated for Tsara.
  3. Configure your API Key under Authorization → Bearer Token.

🧩 Related Pages

  • Authentication — Learn how to authorize every request.
  • Errors — Understand and handle API errors gracefully.
  • Webhooks — Securely process real-time events.