Python Client SDK
The OneSignal Python client is a server OneSignal SDK for Python. Integrate OneSignal with your backend events, data, and more.
Backend SDKs in User Model Beta
You still can try using new User Model endpoints, we advise customers to not use these SDKs in production.
Python API Client
- GitHub: https://github.com/OneSignal/onesignal-python-api
- Package version: 1.0.1
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Requirements.
Python >=3.6
Installation & Usage
pip install
pip install onesignal-python-api
You can also install directly from GitHub using:
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
You may need to run pip
with root permission:
sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
Setuptools
Install via Setuptools.
python setup.py install --user
To install the package for all users:
sudo python setup.py install
Getting Started
Please follow the installation procedure and then run the following:
import onesignal
from onesignal.api import default_api
# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require USER_KEY bearer token for authorization as long as others require APP_KEY
# (also knows as REST_API_KEY). We recommend adding both of them in the configuration page so that you will not need
# to figure it yourself.
configuration = onesignal.Configuration(
app_key = "YOUR_API_KEY",
user_key = "YOUR_USER_KEY"
)
# Enter a context with an instance of the API client
with onesignal.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
Authorization
All the OneSignal endpoints require either an app_key or user_key tokens for authorization. It is recommended to set up both of those keys during the initial config initialization so that you don't need to worry about which endpoint requires app_key and which user_key. You can get the value of these keys from your app dashboard and user settings pages.
Documentation for API Endpoints
All URIs are relative to https://onesignal.com/api/v1
Class | Method | HTTP request | Description |
---|---|---|---|
DefaultApi | begin_live_activity | POST /apps/{app_id}/live_activities/{activity_id}/token | Start Live Activity |
DefaultApi | cancel_notification | DELETE /notifications/{notification_id} | Stop a scheduled or currently outgoing notification |
DefaultApi | create_app | POST /apps | Create an app |
DefaultApi | create_notification | POST /notifications | Create notification |
DefaultApi | create_player | POST /players | Add a device |
DefaultApi | create_segments | POST /apps/{app_id}/segments | Create Segments |
DefaultApi | create_subscription | POST /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions | |
DefaultApi | create_user | POST /apps/{app_id}/users | |
DefaultApi | delete_alias | DELETE /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete} | |
DefaultApi | delete_player | DELETE /players/{player_id} | Delete a user record |
DefaultApi | delete_segments | DELETE /apps/{app_id}/segments/{segment_id} | Delete Segments |
DefaultApi | delete_subscription | DELETE /apps/{app_id}/subscriptions/{subscription_id} | |
DefaultApi | delete_user | DELETE /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
DefaultApi | end_live_activity | DELETE /apps/{app_id}/live_activities/{activity_id}/token/{subscription_id} | Stop Live Activity |
DefaultApi | export_players | POST /players/csv_export?app_id={app_id} | CSV export |
DefaultApi | fetch_aliases | GET /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
DefaultApi | fetch_user | GET /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
DefaultApi | fetch_user_identity | GET /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
DefaultApi | get_app | GET /apps/{app_id} | View an app |
DefaultApi | get_apps | GET /apps | View apps |
DefaultApi | get_eligible_iams | GET /apps/{app_id}/subscriptions/{subscription_id}/iams | |
DefaultApi | get_notification | GET /notifications/{notification_id} | View notification |
DefaultApi | get_notification_history | POST /notifications/{notification_id}/history | Notification History |
DefaultApi | get_notifications | GET /notifications | View notifications |
DefaultApi | get_outcomes | GET /apps/{app_id}/outcomes | View Outcomes |
DefaultApi | get_player | GET /players/{player_id} | View device |
DefaultApi | get_players | GET /players | View devices |
DefaultApi | identify_user_by_alias | PATCH /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
DefaultApi | identify_user_by_subscription_id | PATCH /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
DefaultApi | transfer_subscription | PATCH /apps/{app_id}/subscriptions/{subscription_id}/owner | |
DefaultApi | update_app | PUT /apps/{app_id} | Update an app |
DefaultApi | update_live_activity | POST /apps/{app_id}/live_activities/{activity_id}/notifications | Update a Live Activity via Push |
DefaultApi | update_player | PUT /players/{player_id} | Edit device |
DefaultApi | update_player_tags | PUT /apps/{app_id}/users/{external_user_id} | Edit tags with external user id |
DefaultApi | update_subscription | PATCH /apps/{app_id}/subscriptions/{subscription_id} | |
DefaultApi | update_user | PATCH /apps/{app_id}/users/by/{alias_label}/{alias_id} |
Documentation For Models
- App
- Apps
- BadRequestError
- BasicNotification
- BasicNotificationAllOf
- BasicNotificationAllOfAndroidBackgroundLayout
- BeginLiveActivityRequest
- Button
- Buttons
- CancelNotificationSuccessResponse
- CreateNotificationSuccessResponse
- CreatePlayerSuccessResponse
- CreateSegmentConflictResponse
- CreateSegmentSuccessResponse
- CreateSubscriptionRequestBody
- CreateUserConflictResponse
- CreateUserConflictResponseErrorsInner
- CreateUserConflictResponseErrorsItemsMeta
- DeletePlayerNotFoundResponse
- DeletePlayerSuccessResponse
- DeleteSegmentNotFoundResponse
- DeleteSegmentSuccessResponse
- DeliveryData
- ExportPlayersRequestBody
- ExportPlayersSuccessResponse
- Filter
- FilterExpressions
- GetNotificationRequestBody
- IdentifyUserConflictResponse
- IdentifyUserConflictResponseErrorsInner
- IdentityObject
- InlineResponse200
- InlineResponse2003
- InlineResponse201
- InlineResponse202
- InvalidIdentifierError
- NoSubscribersError
- Notification
- Notification200Errors
- NotificationAllOf
- NotificationHistorySuccessResponse
- NotificationSlice
- NotificationTarget
- NotificationWithMeta
- NotificationWithMetaAllOf
- Operator
- OutcomeData
- OutcomesData
- PlatformDeliveryData
- PlatformDeliveryDataEmailAllOf
- PlatformDeliveryDataSmsAllOf
- Player
- PlayerNotificationTarget
- PlayerNotificationTargetIncludeAliases
- PlayerSlice
- Players
- PropertiesDeltas
- PropertiesObject
- Purchase
- Segment
- SegmentNotificationTarget
- StringMap
- SubscriptionObject
- TransferSubscriptionRequestBody
- UpdateLiveActivityRequest
- UpdateLiveActivitySuccessResponse
- UpdatePlayerSuccessResponse
- UpdatePlayerTagsRequestBody
- UpdatePlayerTagsSuccessResponse
- UpdateSubscriptionRequestBody
- UpdateUserRequest
- User
- UserIdentityRequestBody
- UserIdentityResponse
- UserSubscriptionOptions
Updated 3 months ago