Configuration

Set up the client with your API key, retries and timeouts.

The client reads its settings once, when you make it. Make one and share it across your app.

Options

import os
from goomzo import Goomzo

goomzo = Goomzo(
    api_key=os.environ['GOOMZO_API_KEY'],
    max_retries=2,
    timeout=60.0,
)
OptionDescriptionDefault
api_keystr. Your API key's secret.GOOMZO_API_KEY
max_retriesint. How many times a failed request is tried again.2
timeoutfloat. Seconds to wait for each try.60.0
base_urlstr. Where the API is.https://api.goomzo.africa
http_clienthttpx.Client. Your own client, such as for a proxy or tests. httpx.AsyncClient for AsyncGoomzo.A new one

Important: Keep the API key on your server. Never put it in code that runs in a browser or an app.

Close the client

The client keeps connections open to reuse them. Close it when you're done, or use it as a context manager:

with Goomzo() as goomzo:
    goomzo.messages.send_one({'to': '+255712345678', 'channel': 'sms', 'content': {'text': 'Hi'}})

async with AsyncGoomzo() as goomzo:
    ...

Idempotency keys

Every method that creates something takes idempotency_key, so a retry from your side isn't done twice. Left out, one is made for each call.

goomzo.messages.send_one(
    {'to': '+255712345678', 'channel': 'sms', 'content': {'text': 'Your order is ready.'}},
    idempotency_key='order-1042-ready',
)

API version

The SDK sends the Goomzo-Version it was written for, as API_VERSION:

from goomzo import API_VERSION

Next steps

Last updated