Skip to content

Repository files navigation

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:

importbsg_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:

importbsg_api

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

importbsg_apifrombsg_api.restimportApiExceptionfrompprintimportpprint# Configure APIconfiguration=bsg_api.Configuration(
host="https://one-api.bsg.world"
)
withbsg_api.ApiClient(configuration) asapi_client:
# Step 1: Authenticateauth_api=bsg_api.AuthApi(api_client)
login_request= {"api_key": "live_XXXXXXXXXXXXXXXXXXXX"}
try:
token_response=auth_api.login(login_request)
token=token_response.bearerprint(f"Authenticated! Token: {token[:20]}...")
exceptApiExceptionase:
print(f"Authentication failed: {e}")
exit(1)
# Step 2: Send SMS with obtained tokenconfiguration.access_token=tokenwithbsg_api.ApiClient(configuration) asapi_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)
exceptApiExceptionase:
print(f"Failed to send SMS: {e}")

Documentation for API Endpoints

All URIs are relative to https://one-api.bsg.world

ClassMethodHTTP requestDescription
AccountSettingsApiget_settings_address_book_fields_by_idGET /api/settings/address-book-fields/{id}Get settings value
AuthApiloginPOST /api/auth/loginReceive JWT token
AuthApirefresh_tokenPOST /api/auth/refreshRefresh JWT token
BalanceApiaccount_balanceGET /api/accounts/balanceGet balance
BalanceApiaccount_tariffsGET /api/accounts/tariffGet tariffs
CampaignApicampaignGET /api/campaigns/{id}Get campaign info
CampaignApicampaign_detailsGET /api/campaigns/{id}/detailGet campaign details
CampaignApicampaign_pricePOST /api/campaigns/priceCalculate campaign price
CampaignApicampaign_sendPOST /api/campaigns/sendSend campaign
CampaignApicampaign_stopPATCH /api/campaigns/{id}/stopCancel campaign
CampaignApicampaignsGET /api/campaignsList of campaigns
CampaignRCSApircs_sendPOST /api/campaigns/rcs/sendSend RCS message
CampaignRCSApircs_send_groupsPOST /api/campaigns/rcs/send-groupsSend RCS message to contact list
CampaignSMSApisms_sendPOST /api/campaigns/sms/sendSend SMS campaign
CampaignSMSApisms_send_groupsPOST /api/campaigns/sms/send-groupsSend SMS to contact list
CampaignSMSApisms_send_individualPOST /api/campaigns/sms/send-individualSend SMS with different text
CampaignViberApiviber_sendPOST /api/campaigns/viber/sendSend Viber campaign
CampaignWhatsAppApipost_campaigns_whatsapp_sendPOST /api/campaigns/whatsapp/sendSend WhatsApp campaign
ContactApicontactGET /api/contacts/{id}Get contact by ID
ContactApicontact_createPOST /api/contactsCreate a contact
ContactApicontact_deleteDELETE /api/contacts/{id}Delete contact
ContactApicontact_updatePUT /api/contacts/{id}Update contact
ContactApicontactsGET /api/contactsList of contacts
ContactApicontacts_deletePOST /api/contacts/deleteDelete multiple contacts
ContactApicontacts_searchGET /api/contacts/searchSearch contacts
ContactFieldApicontact_field_createPOST /api/contacts/fieldsCreate contact field
ContactFieldApicontact_field_updatePATCH /api/contacts/fields/{id}Update contact field
ContactFieldApicontact_fieldsGET /api/contacts/fieldsList of contact fields
ContactFieldApipost_contacts_fields_deletePOST /api/contacts/fields/deleteDelete contact fields by ids
ContactListApicontact_listGET /api/groups/{id}Get list by id
ContactListApicontact_list_attachPOST /api/groups/attachAdd contacts to the list
ContactListApicontact_list_createPOST /api/groupsCreate list
ContactListApicontact_list_deleteDELETE /api/groups/{id}Delete list
ContactListApicontact_list_detachPOST /api/groups/detachRemove contacts from the list
ContactListApicontact_list_searchGET /api/groups/searchSearch list
ContactListApicontact_list_updatePUT /api/groups/{id}Update list
ContactListApicontact_listsGET /api/groupsList of contact lists
EmailApiemail_sendPOST /api/email/send-emailsSend Email
EmailApiemail_template_sendPOST /api/email/send-template-emailsSend Email template
MessageRCSApircs_singlePOST /api/messages/rcs/sendSend single RCS message
MessagesApisend_messagePOST /api/messages/sendSend single message
MessagesSMSApiget_messagesGET /api/messagesFind messages
MessagesWhatsAppApiwhatsapp_singlePOST /api/messages/whatsapp/sendSend single WhatsApp message
SendersApisender_request_legalPOST /api/senders/requests/legalSender registration by a legal entity
SendersApisender_request_naturalPOST /api/senders/requests/naturalSender registration by an individual
SendersApisender_requestsGET /api/senders/requests/smsList of Sender Requests
SendersApisendersGET /api/sendersList of Senders
ShortDomainsApishort_urls_domainGET /api/short-url/domains/{uuid}Get domain by uuid
ShortDomainsApishort_urls_domain_createPOST /api/short-url/domainsAdd domain
ShortDomainsApishort_urls_domain_removeDELETE /api/short-url/domains/{uuid}Remove domain
ShortDomainsApishort_urls_domain_updatePUT /api/short-url/domains/{uuid}Update domain
ShortDomainsApishort_urls_domainsGET /api/short-url/domainsList of domains
ShortLinksApishort_urls_clicksGET /api/short-url/clicksList of clicks
ShortLinksApishort_urls_linkGET /api/short-url/links/{uuid}/statisticsGet short link statistic
ShortLinksApishort_urls_link_createPOST /api/short-url/linksCreate short link
ShortLinksApishort_urls_link_deleteDELETE /api/short-url/links/{uuid}Remove short link
ShortLinksApishort_urls_link_updatePUT /api/short-url/links/{uuid}Update short link
ShortLinksApishort_urls_linksGET /api/short-url/linksList of short links
StatisticApistat_jobs_createPOST /api/stat/jobsCreate new job
StatisticApistat_jobs_deleteDELETE /api/stat/jobs/{id}Delete job result
StatisticApistat_jobs_listGET /api/stat/jobsList statistic jobs
StatisticApistat_jobs_showGET /api/stat/jobs/{id}Load job result
StopListApistoplist_addPOST /api/stoplist/attachAdd contacts to stop list
StopListApistoplist_itemsGET /api/stoplistList the contacts of stop lists
StopListApistoplist_removePOST /api/stoplist/detachRemove contacts from stop list
StopListApistoplist_searchGET /api/stoplist/searchSearch contacts in Stop lists
TwoFAOTPApicancel_otpPOST /api/2fa/authentications/{id}/cancelCancel the authentication session
TwoFAOTPApiotp_listGET /api/2fa/authenticationsList of authentication sessions
TwoFAOTPApiresend_otpPOST /api/2fa/authentications/otp/{id}/resendResend the one-time code
TwoFAOTPApisend_otpPOST /api/2fa/authentications/otpSend One-time password
TwoFAOTPApistatus_otpGET /api/2fa/authentications/{id}Check authentication status
TwoFAOTPApiverify_otpPOST /api/2fa/authentications/otp/{id}/verifyCheck one-time Code
TwoFATemplatesApiotp_templateGET /api/2fa/authentications/templates/{templateId}Get message template
TwoFATemplatesApiotp_template_createPOST /api/2fa/authentications/templatesCreate a message template
TwoFATemplatesApiotp_template_deleteDELETE /api/2fa/authentications/templates/{templateId}Delete a message template
TwoFATemplatesApiotp_template_listGET /api/2fa/authentications/templatesList of message templates

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

ExternalAuth

  • Type: Bearer authentication (JWT)

InternalAuth

  • Type: Bearer authentication (JWT)

Author

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages