Skip to main content

Expo Server SDK for Python Asyncio

Project description


If you have problems with the code in this repository, please file an issue or a pull-request. Thanks!


pip install aioexponent


Use to send push notifications to Exponent Experiences from a Python server.

Full documentation on the API is available if you want to dive into the details.

Here's an example on how to use this with retries and reporting via pyrollbar.

from aioexponent import DeviceNotRegisteredError
from aioexponent import PushClient
from aioexponent import PushMessage
from aioexponent import PushResponseError
from aioexponent import PushServerError
from aiohttp import ClientError

# Basic arguments. You should extend this function with the push features you
# want to use, or simply pass in a `PushMessage` object.
async def send_push_message(tokens, message, extra=None):
    client = PushClient()
        response = await client.publish_multiple([
                        data=extra) for token in tokens])
    except PushServerError as exc:
        # Encountered some likely formatting/validation error.
                'tokens': tokens, 'message': message, 'extra': extra
                'errors': exc.errors,
                'response_data': exc.response_data,
    except (ClientError) as exc:
        # Encountered some Connection or HTTP error - retry a few times in
        # case it is transient.
            extra_data={'tokens': tokens, 'message': message, 'extra': extra})
        raise retry(exc=exc)

        # We got a response back, but we don't know whether it's an error yet.
        # This call raises errors so we can handle them with normal exception
        # flows.
    except DeviceNotRegisteredError:
        # Mark the push token as inactive
        from notifications.models import PushToken
    except PushResponseError as exc:
        # Encountered some other per-notification error.
                'tokens': tokens,
                'message': message,
                'extra': extra,
                'push_response': exc.push_response._asdict(),
        raise retry(exc=exc)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
aioexponent-0.5.2-py3-none-any.whl (7.5 kB) Copy SHA256 hash SHA256 Wheel py3
aioexponent-0.5.2.tar.gz (5.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page