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
Python 3.8+
Install from PyPI:
pip install bsg-sdkOr 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_apiInstall 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_apiExecute pytest to run the tests.
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}")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_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 |
| CampaignRCSApi | rcs_single | POST /api/messages/rcs/send | Send single RCS message |
| 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 |
| 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 |
| InternalCorePriceApi | get_internal_core_prices | GET /api/internal/core/prices | Get price list for each country |
| InternalCorePriceApi | get_internal_core_prices_by_country_code | GET /api/internal/core/prices/{countryCode} | Get prices for country |
| InternalCountryApi | get_internal_countries | GET /api/internal/countries | Get countries list |
| InternalCurrencyApi | get_internal_currencies | GET /api/internal/currencies | Get currencies list |
| InternalTwoFAApi | get_internal2fa_authentications_full_price | GET /api/internal/2fa/authentications/full-price | Show TwoFA authentication full price |
| InternalWstPriceApi | get_internal_wst_prices | GET /api/internal/wst/prices | Get price list for each country |
| InternalWstPriceApi | get_internal_wst_prices_by_country_code | GET /api/internal/wst/prices/{countryCode} | Get prices for country |
| 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 |
| 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 |
- AccountBalance200Response
- AccountTariffs200Response
- AlternativeChannel
- BalanceSchema
- Campaign200Response
- CampaignDetails200Response
- CampaignPrice200Response
- CampaignPrice422Response
- CampaignPriceRequest
- CampaignPriceRequestMessagesItem
- CampaignSchema
- CampaignStatus
- CampaignStop200Response
- CampaignStop422Response
- CancelOtp200Response
- CancelOtp404Response
- CancelOtp422Response
- Card
- Cards
- ClickResource
- Components
- Contact200Response
- Contact422Response
- ContactCreate201Response
- ContactCreate422Response
- ContactFieldCollectionSchema
- ContactFieldCreate201Response
- ContactFieldCreateRequest
- ContactFieldSchema
- ContactFieldType
- ContactFieldUpdate200Response
- ContactFieldUpdateRequest
- ContactFieldUpdateRequestOption1
- ContactFieldUpdateRequestOption2
- ContactFieldUpdateRequestOption3
- ContactFieldValuePair
- ContactGroupSchema
- ContactGroupSearchField
- ContactGroupSearchSchema
- ContactList200Response
- ContactListAttachRequest
- ContactListCreate201Response
- ContactListCreate422Response
- ContactListCreateRequest
- ContactListDetachRequest
- ContactListSearch200Response
- ContactListSearch200ResponseMeta
- ContactListSearch200ResponseMetaPage
- ContactListSearch200ResponseMetaSearch
- ContactListUpdate200Response
- ContactListUpdate422Response
- ContactListUpdateRequest
- ContactLists200Response
- ContactSchema
- ContactUpdate200Response
- ContactUpdate422Response
- ContactUpdateRequest
- Contacts200Response
- ContactsSearch200Response
- ContactsSearch200ResponseMeta
- ContactsSearch200ResponseMetaPage
- ContactsSearch200ResponseMetaSearch
- CorePriceSchema
- CurrencyObj
- DateTimeParameter
- DetailCampaignSchema
- DetailCampaignSchemaAlternativeChannels
- DetailCampaignSchemaAlternativeChannelsOneOf0Sms
- DetailCampaignSchemaAlternativeChannelsOption1
- DomainStoreRequest
- DomainUpdateRequest
- EmailResponse
- GetInternal2faAuthenticationsFullPrice200Response
- GetInternalCorePrices200Response
- GetInternalCorePricesByCountryCode200Response
- GetInternalCountries200Response
- GetInternalCountries200ResponseDataItem
- GetInternalCurrencies200Response
- GetInternalCurrencies200ResponseDataItem
- GetInternalWstPrices200Response
- GetInternalWstPricesByCountryCode200Response
- GetMessages200Response
- GetMessages200ResponseMeta
- GetMessages200ResponseMetaPage
- IndividualMessageData
- Inline
- Language
- LinkStoreRequest
- LinkUpdateRequest
- LoginRequest
- Media
- MediaObject
- MessageApiSchema
- MessageApiSchemaAlternativeChannels
- MessageApiSchemaAlternativeChannelsOneOf0Sms
- MessageApiSchemaAlternativeChannelsOneOf1Viber
- MessageApiSchemaAlternativeChannelsOption1
- MessageApiSchemaAlternativeChannelsOption2
- MessageInfo
- MessagePriceObject
- MessageSource
- MessageStatus
- MessageType
- OperatorSchema
- Options
- OtpChannel
- OtpList200Response
- OtpList200ResponseData
- OtpMessageStatus
- OtpStatus
- OtpTemplate200Response
- OtpTemplate404Response
- OtpTemplateCreate200Response
- OtpTemplateCreate422Response
- OtpTemplateCreateRequest
- OtpTemplateDelete200Response
- OtpTemplateDelete200ResponseData
- OtpTemplateDelete404Response
- OtpTemplateDelete422Response
- OtpTemplateList200Response
- OtpTemplateList200ResponseData
- OtpTemplateStatus
- Parameter
- Phone
- PostContactsFieldsDeleteRequest
- RcsClickCallback
- RcsMessage
- RcsSend200Response
- RcsSendGroups200Response
- RcsSingle200Response
- RcsStatusCallback
- ResendOtp200Response
- ResendOtp404Response
- ResendOtp422Response
- SearchCampaignResource
- SearchCampaignResourceMeta
- SearchCampaignResourceMetaPage
- SearchOperator
- SendEmail
- SendOtp201Response
- SendOtp422Response
- SendOtpRequest
- SendRcsCampaign
- SendRcsCampaignGroups
- SendRcsCampaignGroupsAlternativeChannel
- SendTemplateEmail
- SendWhatsAppCampaign
- SendWhatsAppCampaignAlternativeChannel
- SenderRequestLegal201Response
- SenderRequestLegalRequest
- SenderRequestLegalSchema
- SenderRequestNatural201Response
- SenderRequestNaturalRequest
- SenderRequestNaturalSchema
- SenderRequestSchema
- SenderRequestStatus
- SenderRequestType
- SenderRequests200Response
- SenderRequests200ResponseMeta
- SenderRequests200ResponseMetaPage
- SenderSchema
- Senders200Response
- ShortDomainNotFound
- ShortDomainSlugType
- ShortLink
- ShortLinkStatus
- ShortUrlDomainListSchema
- ShortUrlDomainSchema
- ShortUrlLinkSchema
- ShortUrlsClicks200Response
- ShortUrlsDomain200Response
- ShortUrlsDomainCreate201Response
- ShortUrlsDomainCreate422Response
- ShortUrlsDomainUpdate200Response
- ShortUrlsDomains200Response
- ShortUrlsLink200Response
- ShortUrlsLink200ResponseData
- ShortUrlsLink404Response
- ShortUrlsLinkCreate201Response
- ShortUrlsLinkDelete422Response
- ShortUrlsLinkUpdate200Response
- ShortUrlsLinkUpdate422Response
- ShortUrlsLinks200Response
- Sms
- SmsCampaignResponse
- SmsSendGroupsRequest
- SmsSendIndividualRequest
- SmsSendRequest
- SmsSendRequestPhonesItem
- SortWay
- StatisticsData
- StatisticsShort
- StatusOtp200Response
- StatusOtp404Response
- StopListCollection
- StopListPaginateSchema
- StoplistAdd200Response
- StoplistAddRequest
- StoplistItems200Response
- StoplistRemoveRequest
- StoplistSearch200Response
- StoplistSearch200ResponseMeta
- StoplistSearch200ResponseMetaPage
- StoplistSearch200ResponseMetaSearch
- StoplistSearchField
- StoreContact
- Suggestion
- SuggestionCall
- SuggestionLink
- TariffSchema
- Template
- Text
- TokenSchema
- TooManyRequestsResponse
- TwoFaTemplateResource
- TwoFactorAuthenticationMessagesResource
- TwoFactorAuthenticationSchema
- TwoFactorMessageResource
- VerifyOtp200Response
- VerifyOtp404Response
- VerifyOtp422Response
- VerifyOtpRequest
- Viber
- ViberOptions
- WhatsAppMessage
- WhatsAppMessageAlternativeChannel
- WhatsAppMessageTemplate
- WhatsappSingle200Response
- WstPriceSchema
Authentication schemes defined for the API:
- Type: Bearer authentication (JWT)
- Type: Bearer authentication (JWT)