SDKs
Thin wrappers, a few hundred lines each. A local file path uploads automatically, a URL
passes through, a med_ id passes through. You should not have to know which
is happening.
composer require njiwa/njiwa will not work today.
Download njiwa-php.zip and require the two files instead, as
shown below. Python and Node are published and install normally.All three are tested against the live API before each release: send a text, upload a file and send it, read a message back, list numbers, and fail correctly on a bad key.
PHP
Download njiwa-php.zip and unzip it into your project. There is nothing to install and nothing to compile.
require 'njiwa-php/src/NjiwaException.php';
require 'njiwa-php/src/Njiwa.php';
use Njiwa\Njiwa;
$njiwa = new Njiwa('sk_live_...');
$njiwa->send('254712345678', document: 'invoice.pdf', caption: 'Your invoice');
PHP 8.1 or newer. Two files, no dependencies beyond curl and json. Drop them in and
require them, or autoload the Njiwa\ namespace. For WooCommerce, WHMCS and
Laravel.
Errors come back as NjiwaException. Branch on
getErrorCode(), which is stable; getStatus() is the HTTP
status and getDocs() is a page explaining the fix for exactly that error.
Python
pip install njiwa
from njiwa import Njiwa
njiwa = Njiwa("sk_live_...")
njiwa.send("254712345678", document="invoice.pdf", caption="Your invoice")
njiwa on PyPI. Python 3.9 or newer; httpx
is the one dependency and pip installs it for you. For ERPNext server scripts, FastAPI and
Django. Errors raise NjiwaError, which carries .status,
.code and .docs.
Node
npm install @njiwa/sdk
import { Njiwa } from '@njiwa/sdk'
const njiwa = new Njiwa('sk_live_...')
await njiwa.send('254712345678', { document: 'invoice.pdf', caption: 'Your invoice' })
@njiwa/sdk on npm. Node 20 or
newer, ESM, no dependencies. Errors throw NjiwaError, which carries
status, code and docs.
Or no SDK at all
The API is plain HTTP and JSON. Every example in these docs is a curl you can paste, and nothing in the product needs an SDK to reach it.