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-curlandext-json - Full API docs: https://mansaapi.com/docs
composer require mansaapi/mansaapiEvery request needs a Bearer key. Free keys (100 requests/day, no credit card) are issued instantly at mansaapi.com/docs#get-api-key.
<?php
require 'vendor/autoload.php';
use MansaAPI\MansaAPI;
use MansaAPI\MansaAPIException;
$mansa = new MansaAPI('mansa_live_sk_your_key_here');
try {
// Top movers on the Nigerian Exchange
$movers = $mansa->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;
}
}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:
$raw = $mansa->get('/markets/exchanges/NGX/stocks', ['limit' => 50, 'offset' => 50]);
// $raw['data'], $raw['pagination'], $raw['meta'] ...Every failure throws MansaAPI\MansaAPIException carrying:
| Accessor | Description |
|---|---|
getErrorCode() |
Machine-readable code, e.g. INVALID_API_KEY, PAYMENT_REQUIRED, RATE_LIMIT_EXCEEDED |
getMessage() |
Human-readable message |
getStatus() |
HTTP status (0 for network-level failures) |
getHint() |
Optional resolution hint from the API, when present |
getRaw() |
Full decoded error response body |
| Method | Endpoint |
|---|---|
getExchanges() |
GET /markets/exchanges |
getExchange($exchange) |
GET /markets/exchanges/{exchange} |
getStocks($exchange, $params) |
GET /markets/exchanges/{exchange}/stocks |
getStock($exchange, $ticker) |
GET /markets/exchanges/{exchange}/stocks/{ticker} |
getStockHistory($exchange, $ticker, $range) |
GET /markets/exchanges/{exchange}/stocks/{ticker}/history |
getStockFundamentals($exchange, $ticker) |
GET /markets/exchanges/{exchange}/stocks/{ticker}/fundamentals |
getMovers($exchange, $params) |
GET /markets/exchanges/{exchange}/movers |
getPanAfricanMovers($limit) |
GET /markets/movers/pan-african |
search($query, $params) |
GET /markets/search |
getTrending($limit) |
GET /markets/trending |
getAfricanIndices() |
GET /markets/indices |
getIndexHistory($indexCode, $params) |
GET /markets/indices/{code}/history |
getIndices($exchange) |
GET /markets/exchanges/{exchange}/indices |
getIndex($exchange, $code) |
GET /markets/exchanges/{exchange}/indices/{code} |
getExchangeIndexHistory($exchange, $code, $range) |
GET /markets/exchanges/{exchange}/indices/{code}/history |
getETFs($exchange) |
GET /markets/exchanges/{exchange}/etfs |
getETF($exchange, $symbol) |
GET /markets/exchanges/{exchange}/etfs/{symbol} |
resolveETF($exchange, $symbol) |
GET /markets/exchanges/{exchange}/etfs/resolve/{symbol} |
getForex() |
GET /markets/forex |
getCommodities() |
GET /markets/commodities |
getCalendar($exchange, $year) |
GET /markets/calendar/{exchange} |
isOpen($exchange) |
GET /markets/calendar/{exchange}/is-open |
getDividends($exchange, $ticker, $limit) |
GET /markets/exchanges/{exchange}/dividends/{ticker} |
getDividendsCalendar($exchange, $params) |
GET /markets/exchanges/{exchange}/dividends-calendar |
getDisclosures($exchange, $params) |
GET /markets/exchanges/{exchange}/disclosures |
getInsiderTrades($exchange, $params) |
GET /markets/exchanges/{exchange}/insider-trades |
getRecommendations($exchange, $params) |
GET /markets/exchanges/{exchange}/recommendations |
getBonds($country, $params) |
GET /markets/bonds/{country} |
getYieldCurve($country) |
GET /markets/yields/{country}/curve |
getTreasuryBills($country, $limit) |
GET /markets/yields/{country}/tbills |
getAuctions($country, $params) |
GET /markets/yields/{country}/auctions |
| Method | Endpoint |
|---|---|
getPolicyRates() |
GET /macro/policy-rates |
getIndicators($country) |
GET /macro/indicators |
getHistory($country, $indicator, $params) |
GET /macro/{country}/{indicator}/history |
| Method | Endpoint |
|---|---|
getFundamentals($exchange, $ticker) |
GET /fundamentals/{exchange}/{ticker} |
getMetrics($exchange, $ticker) |
GET /metrics/{exchange}/{ticker} |
screener($filters) |
GET /screener |
| Method | Endpoint |
|---|---|
getBanks($params) |
GET /identity/banks |
getBank($bankCode) |
GET /identity/banks/{code} |
getMobileNetworks($country) |
GET /identity/mobile-networks |
lookupMobileNetwork($phone) |
GET /identity/mobile-networks/lookup |
getCurrencies() |
GET /identity/currencies |
getCurrency($currencyCode) |
GET /identity/currencies/{code} |
validateNuban($account, $bankCode) |
GET /identity/nuban/validate |
| Method | Endpoint |
|---|---|
getCountries($region) |
GET /location/countries |
getCountry($countryCode) |
GET /location/countries/{code} |
getStates($countryCode) |
GET /location/countries/{code}/states |
getLGAs($countryCode, $stateCode) |
GET /location/countries/{code}/states/{state}/lgas |
getPostalCodes($countryCode, $stateCode, $params) |
GET /location/countries/{code}/states/{state}/postal-codes |
getHolidays($countryCode, $year) |
GET /location/countries/{code}/holidays/{year} |
// Is the NGX open right now?
$status = $mansa->markets->isOpen('NGX');
echo $status['is_open'] ? 'Open' : 'Closed';
// NGX All-Share Index history back to 2020
$asi = $mansa->markets->getIndexHistory('ngx-asi', ['from' => '2020-01-01']);
// Screen the whole continent for cheap, high-yield stocks
$results = $mansa->fundamentals->screener([
'exchange' => 'ALL',
'pe_max' => 6,
'dividend_yield_min' => 5,
'market_cap_usd_min' => 100_000_000,
]);
// Nigeria's monthly policy-rate history from CBN (back to 2006)
$history = $mansa->macro->getHistory('NG', 'policy_rate', ['from' => '2020-01']);
// Validate a NUBAN account number
$check = $mansa->identity->validateNuban('0123456789', '058');
// Public holidays in Kenya for 2026
$holidays = $mansa->location->getHolidays('KE', 2026);No separate package needed — bind the client in a service provider and inject it anywhere:
// app/Providers/AppServiceProvider.php
use MansaAPI\MansaAPI;
public function register(): void
{
$this->app->singleton(MansaAPI::class, function () {
return new MansaAPI(config('services.mansa.key'));
});
}// config/services.php
'mansa' => [
'key' => env('MANSA_API_KEY'),
],// Anywhere in your app
use MansaAPI\MansaAPI;
class MarketController extends Controller
{
public function movers(MansaAPI $mansa)
{
return $mansa->markets->getMovers('NGX', ['limit' => 10]);
}
}MIT © 2026 Mansa Labs