search

SDK Documentation

Integrate Strongmb into your app in minutes. Official SDKs for PHP, Node.js, and Python — authentication and error handling included.

PHP
PHP SDK PHP 8.1+
Composer package built on Symfony HTTP Client. PSR-4 autoloading, typed exceptions, and full response helpers.
composer require strongmb/strongmb-php
Node.js
Node.js SDK Node 18+
Zero dependencies. Uses the built-in fetch API. CommonJS module with full async/await support and typed error classes.
npm install @strongmb/node
Python
Python SDK Python 3.8+
Lightweight wrapper built on the requests library. Snake_case API, keyword-only arguments, and clean exception hierarchy.
pip install strongmb

Quick Start — Buy 1 GB Data

All three SDKs share the same resource/method structure. Pick your language and start in under 5 minutes.

PHP
<?php
require 'vendor/autoload.php';

use Strongmb\Strongmb;
use Strongmb\Exceptions\ApiException;
use Strongmb\Exceptions\AuthException;

$strongmb = new Strongmb('YOUR_API_KEY');

try {
    $response = $strongmb->data->purchase(
        phone:       '08012345678',
        productCode: 'smb_mtn_sme_1gb_30days',
        reference:   'MYAPP' . strtoupper(uniqid()),
    );

    if ($response->successful()) {
        $data = $response->data();
        echo "✓ 1GB sent to {$data['recipient']}\n";
        echo "  Balance: ₦{$data['balance_after']}\n";
    } elseif ($response->processing()) {
        echo '⏳ Processing… reference: ' . $response->data()['reference'];
    } elseif ($response->failed()) {
        echo '✗ Failed. Trace ID: ' . $response->traceId();
    }

} catch (AuthException $e) {
    echo 'Invalid API key.';
} catch (ApiException $e) {
    echo "Error [{$e->getApiCode()}]: {$e->getMessage()}";
}
Node.js
const { Strongmb, ApiError, AuthError } = require('@strongmb/node');

const strongmb = new Strongmb('YOUR_API_KEY');

(async () => {
  try {
    const response = await strongmb.data.purchase({
      phone:       '08012345678',
      productCode: 'smb_mtn_sme_1gb_30days',
      reference:   'MYAPP' + Date.now(),
    });

    if (response.successful()) {
      const data = response.data();
      console.log(`✓ 1GB sent to ${data.recipient}`);
      console.log(`  Balance: ₦${data.balance_after}`);
    } else if (response.processing()) {
      console.log('⏳ Processing…', response.data().reference);
    } else if (response.failed()) {
      console.log('✗ Failed. Trace ID:', response.traceId());
    }

  } catch (e) {
    if (e instanceof AuthError)  console.log('Invalid API key.');
    else if (e instanceof ApiError)  console.log(`Error [${e.getApiCode()}]: ${e.message}`);
    else console.log('Network error:', e.message);
  }
})();
Python
from strongmb import Strongmb, ApiError, AuthError, StrongmbError

client = Strongmb("YOUR_API_KEY")

try:
    response = client.data.purchase(
        phone="08012345678",
        product_code="smb_mtn_sme_1gb_30days",
        reference="MYAPP123456",
    )

    if response.successful():
        data = response.data()
        print(f"✓ 1GB sent to {data['recipient']}")
        print(f"  Balance: ₦{data['balance_after']:,}")
    elif response.processing():
        print("⏳ Processing… reference:", response.data()["reference"])
    elif response.failed():
        print("✗ Failed. Trace ID:", response.trace_id())

except AuthError:
    print("Invalid API key.")
except ApiError as e:
    print(f"Error [{e.get_api_code()}]: {e}")
except StrongmbError as e:
    print(f"Network error: {e}")
check_circle All three SDKs expose the same successful(), processing(), and failed() helpers so your transaction-state logic is identical across languages.
Exception Hierarchy
All SDKs
StrongmbError          // Network / JSON parse failure
  └── ApiError         // HTTP 4xx / 5xx from the API
        └── AuthError  // HTTP 401 — invalid or missing API key
mail Questions about the SDKs or the API? Email us at [email protected] — include your trace_id for faster triage.