Official mansaapi-php SDK for Mansa API — African market, macro, identity & location data
# Mansa API — PHP SDK
Official PHP SDK for Mansa API — African data infrastructure for developers and AI agents. Live market data across 16+ African exchanges, macro indicators with provenance, company fundamentals, financial identity reference data, and location data. Built in Lagos by Mansa Labs.
- Zero dependencies — just PHP >= 8.1 with `ext-curl` and `ext-json`
- Full API docs: **
mansaapi.com
## Installation
```bash
composer require mansaapi/mansaapi
```
## Get a free API key
Every request needs a Bearer key. Free keys (100 requests/day, no credit card) are issued instantly at
mansaapi.com.
## Quickstart
```php
markets->getMovers('NGX', ['limit' => 5, 'type' => 'gainers']);
foreach ($movers as $mover) {
printf("%s %+.2f%%\n", $mover['ticker'], $mover['change_pct']);
}
// Central bank policy rates + inflation across 18 African economies
$rates = $mansa->macro->getPolicyRates();
foreach ($rates as $row) {
printf("%s: policy rate %.2f%%, inflation %.2f%%\n",
$row['country_name'], $row['policy_rate'], $row['inflation_yoy']);
}
// Look up a Nigerian bank by code (058 = GTBank)
$bank = $mansa->identity->getBank('058');
echo $bank['name'], PHP_EOL;
} catch (MansaAPIException $e) {
echo "[{$e->getErrorCode()}] {$e->getMessage()} (HTTP {$e->getStatus()})", PHP_EOL;
if ($e->getHint() !== null) {
echo 'Hint: ', $e->getHint(), PHP_EOL;
}
}
```
### Return values
Methods return the decoded `data` payload of the response as an associative array. A few endpoints whose payload lives at the top level (`getDividends`, `getInsiderTrades`, `getRecommendations`, `resolveETF`) return the full body so you keep fields like `count`, `stats`, and `meta`. For raw access to any endpoint — including `meta` and `pagination` envelopes — use the escape hatch:
```php
$raw = $mansa->get('/markets/exchanges/NGX/stocks', ['limit' => 50, 'offset' => 50]);
// $raw['data'], $raw['pagination'], $raw['meta'] ...
```
### Errors
Every failure throws `MansaAP …