BSG Python SDK for One-API
Project description
BSG Python SDK
Official Python SDK for BSG One-API. Send SMS, Viber, RCS, WhatsApp messages and more.
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 2.0
- Package version: 1.0.0
- Generator version: 7.12.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Requirements.
Python 3.8+
Installation & Usage
pip install
Install from PyPI:
pip install bsg-sdk
Or install from repository:
pip install git+https://github.com/bsgworld/python-sdk.git
(you may need to run pip with root permission: sudo pip install git+https://github.com/bsgworld/python-sdk.git)
Then import the package:
import bsg_api
Setuptools
Install via Setuptools.
python setup.py install --user
(or sudo python setup.py install to install the package for all users)
Then import the package:
import bsg_api
Tests
Execute pytest to run the tests.
Getting Started
Please follow the installation procedure and then run the following:
import bsg_api
from bsg_api.rest import ApiException
from pprint import pprint
# Configure API
configuration = bsg_api.Configuration(
host="https://one-api.bsg.world"
)
with bsg_api.ApiClient(configuration) as api_client:
# Step 1: Authenticate
auth_api = bsg_api.AuthApi(api_client)
login_request = {"api_key": "live_XXXXXXXXXXXXXXXXXXXX"}
try:
token_response = auth_api.login(login_request)
token = token_response.bearer
print(f"Authenticated! Token: {token[:20]}...")
except ApiException as e:
print(f"Authentication failed: {e}")
exit(1)
# Step 2: Send SMS with obtained token
configuration.access_token = token
with bsg_api.ApiClient(configuration) as api_client:
sms_api = bsg_api.CampaignSMSApi(api_client)
sms_request = {
"phones": [{"number": 380661234567}],
"sender": "BSG",
"text": "Hello from BSG SDK!"
}
try:
response = sms_api.sms_send(sms_request)
print(f"SMS sent! Campaign ID: {response.id}")
pprint(response)
except ApiException as e:
print(f"Failed to send SMS: {e}")
Documentation for API Endpoints
All URIs are relative to https://one-api.bsg.world
| Class | Method | HTTP request | Description |
|---|---|---|---|
| AccountSettingsApi | get_settings_address_book_fields_by_id | GET /api/settings/address-book-fields/{id} | Get settings value |
| AuthApi | login | POST /api/auth/login | Receive JWT token |
| AuthApi | refresh_token | POST /api/auth/refresh | Refresh JWT token |
| BalanceApi | account_balance | GET /api/accounts/balance | Get balance |
| BalanceApi | account_tariffs | GET /api/accounts/tariff | Get tariffs |
| CampaignApi | campaign | GET /api/campaigns/{id} | Get campaign info |
| CampaignApi | campaign_details | GET /api/campaigns/{id}/detail | Get campaign details |
| CampaignApi | campaign_price | POST /api/campaigns/price | Calculate campaign price |
| CampaignApi | campaign_send | POST /api/campaigns/send | Send campaign |
| CampaignApi | campaign_stop | PATCH /api/campaigns/{id}/stop | Cancel campaign |
| CampaignApi | campaigns | GET /api/campaigns | List of campaigns |
| CampaignRCSApi | rcs_send | POST /api/campaigns/rcs/send | Send RCS message |
| CampaignRCSApi | rcs_send_groups | POST /api/campaigns/rcs/send-groups | Send RCS message to contact list |
| CampaignSMSApi | sms_send | POST /api/campaigns/sms/send | Send SMS campaign |
| CampaignSMSApi | sms_send_groups | POST /api/campaigns/sms/send-groups | Send SMS to contact list |
| CampaignSMSApi | sms_send_individual | POST /api/campaigns/sms/send-individual | Send SMS with different text |
| CampaignViberApi | viber_send | POST /api/campaigns/viber/send | Send Viber campaign |
| CampaignWhatsAppApi | post_campaigns_whatsapp_send | POST /api/campaigns/whatsapp/send | Send WhatsApp campaign |
| ContactApi | contact | GET /api/contacts/{id} | Get contact by ID |
| ContactApi | contact_create | POST /api/contacts | Create a contact |
| ContactApi | contact_delete | DELETE /api/contacts/{id} | Delete contact |
| ContactApi | contact_update | PUT /api/contacts/{id} | Update contact |
| ContactApi | contacts | GET /api/contacts | List of contacts |
| ContactApi | contacts_delete | POST /api/contacts/delete | Delete multiple contacts |
| ContactApi | contacts_search | GET /api/contacts/search | Search contacts |
| ContactFieldApi | contact_field_create | POST /api/contacts/fields | Create contact field |
| ContactFieldApi | contact_field_update | PATCH /api/contacts/fields/{id} | Update contact field |
| ContactFieldApi | contact_fields | GET /api/contacts/fields | List of contact fields |
| ContactFieldApi | post_contacts_fields_delete | POST /api/contacts/fields/delete | Delete contact fields by ids |
| ContactListApi | contact_list | GET /api/groups/{id} | Get list by id |
| ContactListApi | contact_list_attach | POST /api/groups/attach | Add contacts to the list |
| ContactListApi | contact_list_create | POST /api/groups | Create list |
| ContactListApi | contact_list_delete | DELETE /api/groups/{id} | Delete list |
| ContactListApi | contact_list_detach | POST /api/groups/detach | Remove contacts from the list |
| ContactListApi | contact_list_search | GET /api/groups/search | Search list |
| ContactListApi | contact_list_update | PUT /api/groups/{id} | Update list |
| ContactListApi | contact_lists | GET /api/groups | List of contact lists |
| EmailApi | email_send | POST /api/email/send-emails | Send Email |
| EmailApi | email_template_send | POST /api/email/send-template-emails | Send Email template |
| MessageRCSApi | rcs_single | POST /api/messages/rcs/send | Send single RCS message |
| MessagesApi | send_message | POST /api/messages/send | Send single message |
| MessagesSMSApi | get_messages | GET /api/messages | Find messages |
| MessagesWhatsAppApi | whatsapp_single | POST /api/messages/whatsapp/send | Send single WhatsApp message |
| SendersApi | sender_request_legal | POST /api/senders/requests/legal | Sender registration by a legal entity |
| SendersApi | sender_request_natural | POST /api/senders/requests/natural | Sender registration by an individual |
| SendersApi | sender_requests | GET /api/senders/requests/sms | List of Sender Requests |
| SendersApi | senders | GET /api/senders | List of Senders |
| ShortDomainsApi | short_urls_domain | GET /api/short-url/domains/{uuid} | Get domain by uuid |
| ShortDomainsApi | short_urls_domain_create | POST /api/short-url/domains | Add domain |
| ShortDomainsApi | short_urls_domain_remove | DELETE /api/short-url/domains/{uuid} | Remove domain |
| ShortDomainsApi | short_urls_domain_update | PUT /api/short-url/domains/{uuid} | Update domain |
| ShortDomainsApi | short_urls_domains | GET /api/short-url/domains | List of domains |
| ShortLinksApi | short_urls_clicks | GET /api/short-url/clicks | List of clicks |
| ShortLinksApi | short_urls_link | GET /api/short-url/links/{uuid}/statistics | Get short link statistic |
| ShortLinksApi | short_urls_link_create | POST /api/short-url/links | Create short link |
| ShortLinksApi | short_urls_link_delete | DELETE /api/short-url/links/{uuid} | Remove short link |
| ShortLinksApi | short_urls_link_update | PUT /api/short-url/links/{uuid} | Update short link |
| ShortLinksApi | short_urls_links | GET /api/short-url/links | List of short links |
| StatisticApi | stat_jobs_create | POST /api/stat/jobs | Create new job |
| StatisticApi | stat_jobs_delete | DELETE /api/stat/jobs/{id} | Delete job result |
| StatisticApi | stat_jobs_list | GET /api/stat/jobs | List statistic jobs |
| StatisticApi | stat_jobs_show | GET /api/stat/jobs/{id} | Load job result |
| StopListApi | stoplist_add | POST /api/stoplist/attach | Add contacts to stop list |
| StopListApi | stoplist_items | GET /api/stoplist | List the contacts of stop lists |
| StopListApi | stoplist_remove | POST /api/stoplist/detach | Remove contacts from stop list |
| StopListApi | stoplist_search | GET /api/stoplist/search | Search contacts in Stop lists |
| TwoFAOTPApi | cancel_otp | POST /api/2fa/authentications/{id}/cancel | Cancel the authentication session |
| TwoFAOTPApi | otp_list | GET /api/2fa/authentications | List of authentication sessions |
| TwoFAOTPApi | resend_otp | POST /api/2fa/authentications/otp/{id}/resend | Resend the one-time code |
| TwoFAOTPApi | send_otp | POST /api/2fa/authentications/otp | Send One-time password |
| TwoFAOTPApi | status_otp | GET /api/2fa/authentications/{id} | Check authentication status |
| TwoFAOTPApi | verify_otp | POST /api/2fa/authentications/otp/{id}/verify | Check one-time Code |
| TwoFATemplatesApi | otp_template | GET /api/2fa/authentications/templates/{templateId} | Get message template |
| TwoFATemplatesApi | otp_template_create | POST /api/2fa/authentications/templates | Create a message template |
| TwoFATemplatesApi | otp_template_delete | DELETE /api/2fa/authentications/templates/{templateId} | Delete a message template |
| TwoFATemplatesApi | otp_template_list | GET /api/2fa/authentications/templates | List of message templates |
Documentation For Models
- AccountBalance200Response
- AccountTariffs200Response
- AlternativeChannel
- BalanceSchema
- Campaign
- CampaignDetails200Response
- CampaignPrice200Response
- CampaignPrice422Response
- CampaignPriceRequest
- CampaignPriceRequestMessagesItem
- CampaignResponse
- CampaignSchema
- CampaignStatus
- CampaignStop200Response
- CampaignStop422Response
- CancelOtp200Response
- CancelOtp404Response
- CancelOtp422Response
- Card
- Cards
- ClickResource
- Components
- Contact200Response
- Contact422Response
- ContactCreate201Response
- ContactCreate422Response
- ContactFieldCollectionSchema
- ContactFieldCreate201Response
- ContactFieldCreateRequest
- ContactFieldSchema
- ContactFieldType
- ContactFieldUpdate200Response
- ContactFieldUpdateRequest
- ContactFieldUpdateRequestOptionDescription
- ContactFieldUpdateRequestOptionIsVisible
- ContactFieldUpdateRequestOptionName
- ContactFieldValuePair
- ContactGroupSchema
- ContactGroupSearchField
- ContactGroupSearchSchema
- ContactList200Response
- ContactListAttachRequest
- ContactListCreate201Response
- ContactListCreate422Response
- ContactListCreateRequest
- ContactListDetachRequest
- ContactListSearch200Response
- ContactListSearchCriteria
- ContactListSearchMeta
- ContactListUpdate200Response
- ContactListUpdate422Response
- ContactListUpdateRequest
- ContactLists200Response
- ContactSchema
- ContactUpdate200Response
- ContactUpdate422Response
- ContactUpdateRequest
- Contacts200Response
- ContactsSearch200Response
- ContactsSearchCriteria
- ContactsSearchMeta
- CorePriceSchema
- CountryItem
- CreateJobMessage
- CreateJobParams
- CurrencyItem
- DetailCampaignSchema
- DetailCampaignSchemaAlternativeChannels
- DetailCampaignSchemaAlternativeChannelsSms
- DetailCampaignSchemaAlternativeChannelsStatistics
- DomainStoreRequest
- DomainUpdateRequest
- EmailResponse
- GetInternal2faAuthenticationsFullPrice200Response
- GetInternalCorePrices200Response
- GetInternalCorePricesByCountryCode200Response
- GetInternalCountries200Response
- GetInternalCurrencies200Response
- GetInternalWstPrices200Response
- GetInternalWstPricesByCountryCode200Response
- GetMessages200Response
- GroupsTrait
- IndividualMessageData
- Inline
- Language
- LinkStoreRequest
- LinkUpdateRequest
- LoginRequest
- Media
- MessageApiSchema
- MessageApiSchemaAlternativeChannels
- MessageApiSchemaAlternativeChannelsSms
- MessageApiSchemaAlternativeChannelsSmsDetails
- MessageApiSchemaAlternativeChannelsViber
- MessageApiSchemaAlternativeChannelsViberDetails
- MessageInfo
- MessagePriceObject
- MessageResponse
- MessageSource
- MessageStatus
- MessageType
- MessageUniversal
- Meta
- MetaPage
- OperatorSchema
- Options
- OtpChannel
- OtpList200Response
- OtpListResponseData
- OtpMessageStatus
- OtpStatus
- OtpTemplate200Response
- OtpTemplate404Response
- OtpTemplateCreate200Response
- OtpTemplateCreate422Response
- OtpTemplateCreateRequest
- OtpTemplateDelete200Response
- OtpTemplateDelete404Response
- OtpTemplateDelete422Response
- OtpTemplateDeleteResponseData
- OtpTemplateList200Response
- OtpTemplateListResponseData
- OtpTemplateStatus
- Parameter
- Phone
- PhonesTrait
- PostContactsFieldsDeleteRequest
- Rcs
- RcsClickCallback
- RcsMessage
- RcsSend200Response
- RcsSendGroups200Response
- RcsStatusCallback
- Recipients
- ResendOtp200Response
- ResendOtp404Response
- ResendOtp422Response
- SearchCampaignResource
- SearchOperator
- SendEmail
- SendOtp201Response
- SendOtp422Response
- SendOtpRequest
- SendRcsCampaign
- SendRcsCampaignGroups
- SendRcsCampaignGroupsAlternativeChannel
- SendTemplateEmail
- SendViberCampaign
- SendWhatsAppCampaign
- SendWhatsAppCampaignAlternativeChannel
- SenderRequestLegal201Response
- SenderRequestLegalRequest
- SenderRequestLegalSchema
- SenderRequestNatural201Response
- SenderRequestNaturalRequest
- SenderRequestNaturalSchema
- SenderRequestSchema
- SenderRequestStatus
- SenderRequestType
- SenderRequests200Response
- SenderSchema
- Senders200Response
- ShortDomainNotFound
- ShortDomainSlugType
- ShortLink
- ShortLinkStatus
- ShortUrlDomainListSchema
- ShortUrlDomainSchema
- ShortUrlLinkSchema
- ShortUrlsClicks200Response
- ShortUrlsDomain200Response
- ShortUrlsDomainCreate201Response
- ShortUrlsDomainCreate422Response
- ShortUrlsDomainUpdate200Response
- ShortUrlsDomains200Response
- ShortUrlsLink200Response
- ShortUrlsLink404Response
- ShortUrlsLinkCreate201Response
- ShortUrlsLinkDelete422Response
- ShortUrlsLinkStatisticData
- ShortUrlsLinkUpdate200Response
- ShortUrlsLinkUpdate422Response
- ShortUrlsLinks200Response
- Sms
- SmsAltChannel
- SmsCampaignResponse
- SmsSendGroupsRequest
- SmsSendIndividualRequest
- SmsSendRequest
- SmsSendRequestPhonesItem
- SortWay
- StatJobsCreate200Response
- StatJobsCreateRequest
- StatJobsDelete200Response
- StatisticsData
- StatisticsShort
- StatusOtp200Response
- StatusOtp404Response
- StopListCollection
- StopListPaginateSchema
- StoplistAdd200Response
- StoplistAddRequest
- StoplistItems200Response
- StoplistRemoveRequest
- StoplistSearch200Response
- StoplistSearchCriteria
- StoplistSearchField
- StoplistSearchMeta
- StoreContact
- Suggestion
- SuggestionCall
- SuggestionLink
- TariffSchema
- Telegram
- Template
- Text
- TokenSchema
- TooManyRequestsResponse
- TwoFaTemplateResource
- TwoFactorAuthenticationMessagesResource
- TwoFactorAuthenticationSchema
- TwoFactorMessageResource
- VerifyOtp200Response
- VerifyOtp404Response
- VerifyOtp422Response
- VerifyOtpRequest
- Viber
- ViberCampaignResponse
- Voice
- WhatsAppMessage
- WhatsAppMessageAlternativeChannel
- WhatsAppMessageTemplate
- WstPriceSchema
Documentation For Authorization
Authentication schemes defined for the API:
ExternalAuth
- Type: Bearer authentication (JWT)
InternalAuth
- Type: Bearer authentication (JWT)
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bsg_sdk-0.1.8.tar.gz.
File metadata
- Download URL: bsg_sdk-0.1.8.tar.gz
- Upload date:
- Size: 138.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f826c592eec591a3d437e24d8d503675ba653daa241d96bacb8f767f72691cef
|
|
| MD5 |
de31ac10163e3e25b9bd9c927dab1ced
|
|
| BLAKE2b-256 |
fc8eeeeacb7c21453faf754b1861b9bdb528084bb908d8e310446447ae6da64c
|
File details
Details for the file bsg_sdk-0.1.8-py3-none-any.whl.
File metadata
- Download URL: bsg_sdk-0.1.8-py3-none-any.whl
- Upload date:
- Size: 437.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca4cdb5035411b9690d35b3e04d0bde2b19ac2e92df18e229bfa76d366e2c56b
|
|
| MD5 |
26e92ccc8757b904c381438457808ff2
|
|
| BLAKE2b-256 |
eda3d3ee8171c385e3b5d2379c2d273ec4dd64d949932d9f70377ac859c92038
|