API Quickstart

1. Get a Key

An admin of your organisation makes an API key on the organisation page. Its text is shown once, so keep it where your program reads its secrets. A viewer's key only reads. A buyer's key also unlocks and releases businesses.

Accounts are by invitation. If your organisation has none yet, ask for one.

Open Your OrganisationRequest Access

Put the key where the calls below read it:

export MANAA_KEY='mna_live_<key id>_<secret>'

2. Make Three Calls

  1. Who the key calls for: your organisation, its plan and its free slots.

    curl -H "Authorization: Bearer $MANAA_KEY" \
      https://app.manaarisk.com/api/v1/account
  2. The businesses your organisation has unlocked, each with its id.

    curl -H "Authorization: Bearer $MANAA_KEY" \
      https://app.manaarisk.com/api/v1/entitlements
  3. The flood score of one of them and the features behind it. Put its id in place of ⁨BUSINESS_ID⁩, and ⁨heat⁩ in place of ⁨flood⁩ for the Heat Risk Score.

    curl -H "Authorization: Bearer $MANAA_KEY" \
      https://app.manaarisk.com/api/v1/businesses/BUSINESS_ID/flood

3. The Same in Python

import os

import requests

API = "https://app.manaarisk.com/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['MANAA_KEY']}"


def read(path):
    response = session.get(API + path, timeout=30)
    response.raise_for_status()
    return response.json()


account = read("/account")
print(account["organisation"]["name"])

held = read("/entitlements")["results"]
for business in held:
    print(business["business_id"], business["business_name"])

if held:
    flood = read(f"/businesses/{held[0]['business_id']}/flood")
    print(flood["score"], flood["band"])

What Comes Back

Every answer is JSON. A refusal has two fields: ⁨detail⁩, a sentence in English, and ⁨code⁩, which stays the same. A key that does not work is answered 401 ⁨invalid_key⁩, and a business your organisation has not unlocked 403 ⁨business_not_unlocked⁩.

A key may make 10 requests a second. Past that it is answered 429 ⁨rate_limited⁩, and ⁨Retry-After⁩ gives the seconds to wait.

Reference