AmpliPython is a Python library which provides an easy method to log your events with Amplitude Analytics.
Built with Pydantic.
You can install this using pip.
$ pip install AmpliPython
Usage is pretty easy, just pass all the params you want to AmplipyEvent
and then log it with AmplipyClient
from amplipython import AmplipyClient, AmplipyEvent
client = AmplipyClient(api_key="YOUR_API_KEY")
# Single event example, no additional data provided
event = AmplipyEvent(user_id="sample", event_type="amplipy-sample")
client.log_event(event)
# Multiple events example with event and user data
event_list = []
for i in range(5):
event = AmplipyEvent(
user_id="sample",
event_type="amplipy-sample",
event_properties={"iteration": i},
user_properties={"sent_by": "amplipy"},
)
event_list.append(event)
# NOTE: Events order in dashboard is not specified!
client.log_events(event_list)
See all params you can pass to AmplipyEvent
instance
When trying to log event, following exceptions could be raised:
-
AmplipyInvalidRequestError
-
AmplipyPayloadTooLargeError
-
AmplipyTooManyRequestsForDeviceError
-
AmplipyAmplitudeServerError
-
AmplipyAmplitudeIsUnavaliable
All keys for AmplipyEvent initializer could be found in official Amplitude docs:
https://developers.amplitude.com/docs/http-api-v2
PRs are pretty much welcomed and highly appreciated! 👻