Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 59 additions & 170 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,208 +1,97 @@
<h1 align="center">Welcome to @onesignal/python-onesignal 👋</h1>
<h1 align="center">Welcome to onesignal-python-api</h1>
<p>
<a href="https://pypi.org/project/onesignal-python-api/" target="_blank">
<img alt="Version" src="https://img.shields.io/pypi/v/onesignal-python-api">
</a>
<a href="https://github.com/OneSignal/python-onesignal#readme" target="_blank">
<a href="https://github.com/OneSignal/onesignal-python-api#readme" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
</a>
<a href="https://github.com/OneSignal/python-onesignal/graphs/commit-activity" target="_blank">
<a href="https://github.com/OneSignal/onesignal-python-api/graphs/commit-activity" target="_blank">
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
</a>
<a href="https://twitter.com/onesignal" target="_blank">
<img alt="Twitter: onesignal" src="https://img.shields.io/twitter/follow/onesignal.svg?style=social" />
</a>
</p>

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

- API version: 5.3.0
- Package version: 5.3.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen

## Requirements.
## Requirements

Python >=3.6

## Installation & Usage
### pip install
## Installation

```sh
pip install onesignal-python-api
```

You can also install directly from GitHub using:
## Configuration

```sh
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
Every SDK requires authentication via API keys. Two key types are available:

You may need to run `pip` with root permission:
```sh
sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
### Setuptools
- **REST API Key** — required for most endpoints (sending notifications, managing users, etc.). Found in your app's **Settings > Keys & IDs**.
- **Organization API Key** — only required for organization-level endpoints like creating or listing apps. Found in **Organization Settings**.

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
> **Warning:** Store your API keys in environment variables or a secrets manager. Never commit them to source control.

```sh
python setup.py install --user
```
```python
import onesignal
from onesignal.api import default_api

To install the package for all users:
```sh
sudo python setup.py install
```
configuration = onesignal.Configuration(
rest_api_key='YOUR_REST_API_KEY',
organization_api_key='YOUR_ORGANIZATION_API_KEY',
)

## Getting Started
with onesignal.ApiClient(configuration) as api_client:
client = default_api.DefaultApi(api_client)
```

Please follow the [installation procedure](#installation--usage) and then run the following:
## Send a push notification

```python
import onesignal
from onesignal.api import default_api
notification = onesignal.Notification(
app_id='YOUR_APP_ID',
contents=onesignal.StringMap(en='Hello from OneSignal!'),
headings=onesignal.StringMap(en='Push Notification'),
included_segments=['Subscribed Users'],
)

# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.
# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.
configuration = onesignal.Configuration(
rest_api_key = "YOUR_REST_API_KEY", # App REST API key required for most endpoints
organization_api_key = "YOUR_ORGANIZATION_KEY" # Organization key is only required for creating new apps and other top-level endpoints
response = client.create_notification(notification)
print('Notification ID:', response.id)
```

## Send an email

```python
notification = onesignal.Notification(
app_id='YOUR_APP_ID',
email_subject='Important Update',
email_body='<h1>Hello!</h1><p>This is an HTML email.</p>',
included_segments=['Subscribed Users'],
channel_for_external_user_ids='email',
)

response = client.create_notification(notification)
```

## Send an SMS

# 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)
```python
notification = onesignal.Notification(
app_id='YOUR_APP_ID',
contents=onesignal.StringMap(en='Your SMS message content here'),
included_segments=['Subscribed Users'],
channel_for_external_user_ids='sms',
sms_from='+15551234567',
)

response = client.create_notification(notification)
```

## Documentation for API Endpoints

All URIs are relative to *https://api.onesignal.com*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**cancel_notification**](docs/DefaultApi.md#cancel_notification) | **DELETE** /notifications/{notification_id} | Stop a scheduled or currently outgoing notification
*DefaultApi* | [**copy_template_to_app**](docs/DefaultApi.md#copy_template_to_app) | **POST** /templates/{template_id}/copy_to_app | Copy template to another app
*DefaultApi* | [**create_alias**](docs/DefaultApi.md#create_alias) | **PATCH** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity |
*DefaultApi* | [**create_alias_by_subscription**](docs/DefaultApi.md#create_alias_by_subscription) | **PATCH** /apps/{app_id}/subscriptions/{subscription_id}/user/identity |
*DefaultApi* | [**create_api_key**](docs/DefaultApi.md#create_api_key) | **POST** /apps/{app_id}/auth/tokens | Create API key
*DefaultApi* | [**create_app**](docs/DefaultApi.md#create_app) | **POST** /apps | Create an app
*DefaultApi* | [**create_custom_events**](docs/DefaultApi.md#create_custom_events) | **POST** /apps/{app_id}/integrations/custom_events | Create custom events
*DefaultApi* | [**create_notification**](docs/DefaultApi.md#create_notification) | **POST** /notifications | Create notification
*DefaultApi* | [**create_segment**](docs/DefaultApi.md#create_segment) | **POST** /apps/{app_id}/segments | Create Segment
*DefaultApi* | [**create_subscription**](docs/DefaultApi.md#create_subscription) | **POST** /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions |
*DefaultApi* | [**create_template**](docs/DefaultApi.md#create_template) | **POST** /templates | Create template
*DefaultApi* | [**create_user**](docs/DefaultApi.md#create_user) | **POST** /apps/{app_id}/users |
*DefaultApi* | [**delete_alias**](docs/DefaultApi.md#delete_alias) | **DELETE** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete} |
*DefaultApi* | [**delete_api_key**](docs/DefaultApi.md#delete_api_key) | **DELETE** /apps/{app_id}/auth/tokens/{token_id} | Delete API key
*DefaultApi* | [**delete_segment**](docs/DefaultApi.md#delete_segment) | **DELETE** /apps/{app_id}/segments/{segment_id} | Delete Segment
*DefaultApi* | [**delete_subscription**](docs/DefaultApi.md#delete_subscription) | **DELETE** /apps/{app_id}/subscriptions/{subscription_id} |
*DefaultApi* | [**delete_template**](docs/DefaultApi.md#delete_template) | **DELETE** /templates/{template_id} | Delete template
*DefaultApi* | [**delete_user**](docs/DefaultApi.md#delete_user) | **DELETE** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*DefaultApi* | [**export_events**](docs/DefaultApi.md#export_events) | **POST** /notifications/{notification_id}/export_events?app_id&#x3D;{app_id} | Export CSV of Events
*DefaultApi* | [**export_subscriptions**](docs/DefaultApi.md#export_subscriptions) | **POST** /players/csv_export?app_id&#x3D;{app_id} | Export CSV of Subscriptions
*DefaultApi* | [**get_aliases**](docs/DefaultApi.md#get_aliases) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity |
*DefaultApi* | [**get_aliases_by_subscription**](docs/DefaultApi.md#get_aliases_by_subscription) | **GET** /apps/{app_id}/subscriptions/{subscription_id}/user/identity |
*DefaultApi* | [**get_app**](docs/DefaultApi.md#get_app) | **GET** /apps/{app_id} | View an app
*DefaultApi* | [**get_apps**](docs/DefaultApi.md#get_apps) | **GET** /apps | View apps
*DefaultApi* | [**get_notification**](docs/DefaultApi.md#get_notification) | **GET** /notifications/{notification_id} | View notification
*DefaultApi* | [**get_notification_history**](docs/DefaultApi.md#get_notification_history) | **POST** /notifications/{notification_id}/history | Notification History
*DefaultApi* | [**get_notifications**](docs/DefaultApi.md#get_notifications) | **GET** /notifications | View notifications
*DefaultApi* | [**get_outcomes**](docs/DefaultApi.md#get_outcomes) | **GET** /apps/{app_id}/outcomes | View Outcomes
*DefaultApi* | [**get_segments**](docs/DefaultApi.md#get_segments) | **GET** /apps/{app_id}/segments | Get Segments
*DefaultApi* | [**get_user**](docs/DefaultApi.md#get_user) | **GET** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*DefaultApi* | [**rotate_api_key**](docs/DefaultApi.md#rotate_api_key) | **POST** /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key
*DefaultApi* | [**start_live_activity**](docs/DefaultApi.md#start_live_activity) | **POST** /apps/{app_id}/activities/activity/{activity_type} | Start Live Activity
*DefaultApi* | [**transfer_subscription**](docs/DefaultApi.md#transfer_subscription) | **PATCH** /apps/{app_id}/subscriptions/{subscription_id}/owner |
*DefaultApi* | [**unsubscribe_email_with_token**](docs/DefaultApi.md#unsubscribe_email_with_token) | **POST** /apps/{app_id}/notifications/{notification_id}/unsubscribe | Unsubscribe with token
*DefaultApi* | [**update_api_key**](docs/DefaultApi.md#update_api_key) | **PATCH** /apps/{app_id}/auth/tokens/{token_id} | Update API key
*DefaultApi* | [**update_app**](docs/DefaultApi.md#update_app) | **PUT** /apps/{app_id} | Update an app
*DefaultApi* | [**update_live_activity**](docs/DefaultApi.md#update_live_activity) | **POST** /apps/{app_id}/live_activities/{activity_id}/notifications | Update a Live Activity via Push
*DefaultApi* | [**update_subscription**](docs/DefaultApi.md#update_subscription) | **PATCH** /apps/{app_id}/subscriptions/{subscription_id} |
*DefaultApi* | [**update_subscription_by_token**](docs/DefaultApi.md#update_subscription_by_token) | **PATCH** /apps/{app_id}/subscriptions_by_token/{token_type}/{token} | Update subscription by token
*DefaultApi* | [**update_template**](docs/DefaultApi.md#update_template) | **PATCH** /templates/{template_id} | Update template
*DefaultApi* | [**update_user**](docs/DefaultApi.md#update_user) | **PATCH** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*DefaultApi* | [**view_api_keys**](docs/DefaultApi.md#view_api_keys) | **GET** /apps/{app_id}/auth/tokens | View API keys
*DefaultApi* | [**view_template**](docs/DefaultApi.md#view_template) | **GET** /templates/{template_id} | View template
*DefaultApi* | [**view_templates**](docs/DefaultApi.md#view_templates) | **GET** /templates | View templates


## Documentation For Models

- [ApiKeyToken](docs/ApiKeyToken.md)
- [ApiKeyTokensListResponse](docs/ApiKeyTokensListResponse.md)
- [App](docs/App.md)
- [Apps](docs/Apps.md)
- [BasicNotification](docs/BasicNotification.md)
- [BasicNotificationAllOf](docs/BasicNotificationAllOf.md)
- [BasicNotificationAllOfAndroidBackgroundLayout](docs/BasicNotificationAllOfAndroidBackgroundLayout.md)
- [Button](docs/Button.md)
- [CopyTemplateRequest](docs/CopyTemplateRequest.md)
- [CreateApiKeyRequest](docs/CreateApiKeyRequest.md)
- [CreateApiKeyResponse](docs/CreateApiKeyResponse.md)
- [CreateNotificationSuccessResponse](docs/CreateNotificationSuccessResponse.md)
- [CreateSegmentConflictResponse](docs/CreateSegmentConflictResponse.md)
- [CreateSegmentSuccessResponse](docs/CreateSegmentSuccessResponse.md)
- [CreateTemplateRequest](docs/CreateTemplateRequest.md)
- [CreateUserConflictResponse](docs/CreateUserConflictResponse.md)
- [CreateUserConflictResponseErrorsInner](docs/CreateUserConflictResponseErrorsInner.md)
- [CreateUserConflictResponseErrorsItemsMeta](docs/CreateUserConflictResponseErrorsItemsMeta.md)
- [CustomEvent](docs/CustomEvent.md)
- [CustomEventsRequest](docs/CustomEventsRequest.md)
- [DeliveryData](docs/DeliveryData.md)
- [ExportEventsSuccessResponse](docs/ExportEventsSuccessResponse.md)
- [ExportSubscriptionsRequestBody](docs/ExportSubscriptionsRequestBody.md)
- [ExportSubscriptionsSuccessResponse](docs/ExportSubscriptionsSuccessResponse.md)
- [Filter](docs/Filter.md)
- [FilterExpression](docs/FilterExpression.md)
- [GenericError](docs/GenericError.md)
- [GenericSuccessBoolResponse](docs/GenericSuccessBoolResponse.md)
- [GetNotificationHistoryRequestBody](docs/GetNotificationHistoryRequestBody.md)
- [GetSegmentsSuccessResponse](docs/GetSegmentsSuccessResponse.md)
- [IdentityObject](docs/IdentityObject.md)
- [IncludeAliases](docs/IncludeAliases.md)
- [LanguageStringMap](docs/LanguageStringMap.md)
- [Notification](docs/Notification.md)
- [NotificationAllOf](docs/NotificationAllOf.md)
- [NotificationHistorySuccessResponse](docs/NotificationHistorySuccessResponse.md)
- [NotificationSlice](docs/NotificationSlice.md)
- [NotificationTarget](docs/NotificationTarget.md)
- [NotificationWithMeta](docs/NotificationWithMeta.md)
- [NotificationWithMetaAllOf](docs/NotificationWithMetaAllOf.md)
- [Operator](docs/Operator.md)
- [OutcomeData](docs/OutcomeData.md)
- [OutcomesData](docs/OutcomesData.md)
- [PlatformDeliveryData](docs/PlatformDeliveryData.md)
- [PlatformDeliveryDataEmailAllOf](docs/PlatformDeliveryDataEmailAllOf.md)
- [PlatformDeliveryDataSmsAllOf](docs/PlatformDeliveryDataSmsAllOf.md)
- [PropertiesBody](docs/PropertiesBody.md)
- [PropertiesDeltas](docs/PropertiesDeltas.md)
- [PropertiesObject](docs/PropertiesObject.md)
- [Purchase](docs/Purchase.md)
- [RateLimitError](docs/RateLimitError.md)
- [Segment](docs/Segment.md)
- [SegmentData](docs/SegmentData.md)
- [SegmentNotificationTarget](docs/SegmentNotificationTarget.md)
- [StartLiveActivityRequest](docs/StartLiveActivityRequest.md)
- [StartLiveActivitySuccessResponse](docs/StartLiveActivitySuccessResponse.md)
- [Subscription](docs/Subscription.md)
- [SubscriptionBody](docs/SubscriptionBody.md)
- [SubscriptionNotificationTarget](docs/SubscriptionNotificationTarget.md)
- [TemplateResource](docs/TemplateResource.md)
- [TemplatesListResponse](docs/TemplatesListResponse.md)
- [TransferSubscriptionRequestBody](docs/TransferSubscriptionRequestBody.md)
- [UpdateApiKeyRequest](docs/UpdateApiKeyRequest.md)
- [UpdateLiveActivityRequest](docs/UpdateLiveActivityRequest.md)
- [UpdateLiveActivitySuccessResponse](docs/UpdateLiveActivitySuccessResponse.md)
- [UpdateTemplateRequest](docs/UpdateTemplateRequest.md)
- [UpdateUserRequest](docs/UpdateUserRequest.md)
- [User](docs/User.md)
- [UserIdentityBody](docs/UserIdentityBody.md)
- [WebButton](docs/WebButton.md)


## Author

devrel@onesignal.com
## Full API reference

The complete list of API endpoints and their parameters is available in the [DefaultApi documentation](https://github.com/OneSignal/onesignal-python-api/blob/main/docs/DefaultApi.md).

For the underlying REST API, see the [OneSignal API reference](https://documentation.onesignal.com/reference).
2 changes: 1 addition & 1 deletion docs/ApiKeyToken.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Name | Type | Description | Notes
**ip_allowlist** | **[str]** | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


2 changes: 1 addition & 1 deletion docs/ApiKeyTokensListResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Name | Type | Description | Notes
**tokens** | [**[ApiKeyToken]**](ApiKeyToken.md) | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


2 changes: 1 addition & 1 deletion docs/App.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Name | Type | Description | Notes
**additional_data_is_root_payload** | **bool** | iOS: Notification data (additional data) values will be added to the root of the apns payload when sent to the device. Ignore if you're not using any other plugins, or not using OneSignal SDK methods to read the payload. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


2 changes: 1 addition & 1 deletion docs/Apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**value** | [**[App]**](App.md) | |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


2 changes: 1 addition & 1 deletion docs/BasicNotification.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ Name | Type | Description | Notes
**huawei_bi_tag** | **str, none_type** | Channel: Push Notifications Platform: Huawei A tag used for Huawei business intelligence and analytics. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


2 changes: 1 addition & 1 deletion docs/BasicNotificationAllOf.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ Name | Type | Description | Notes
**huawei_bi_tag** | **str, none_type** | Channel: Push Notifications Platform: Huawei A tag used for Huawei business intelligence and analytics. | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


2 changes: 1 addition & 1 deletion docs/BasicNotificationAllOfAndroidBackgroundLayout.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Name | Type | Description | Notes
**contents_color** | **str** | Body text color ARGB Hex format. Example(Red) \"FFFF0000\". | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
[[Back to API list]](https://github.com/OneSignal/onesignal-python-api#full-api-reference) [[Back to README]](https://github.com/OneSignal/onesignal-python-api)


Loading
Loading