Skip to main content

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
AccountBalanceApi account_balance GET /api/accounts/balance Get balance
AccountTariffsApi account_tariffs GET /api/accounts/tariff Get tariffs
CampaignDetailsApi campaign_details GET /api/campaigns/{id}/detail Get campaign details
CampaignPriceApi campaign_price POST /api/campaigns/price Calculate campaign price
CampaignStopApi campaign_stop PATCH /api/campaigns/{id}/stop Cancel campaign
CampaignTagApi campaign GET /api/campaigns/{id} Get campaign info
CampaignsApi campaigns GET /api/campaigns List of campaigns
CancelOtpApi cancel_otp POST /api/2fa/authentications/{id}/cancel Cancel the authentication session
ContactCreateApi contact_create POST /api/contacts Create a contact
ContactDeleteApi contact_delete DELETE /api/contacts/{id} Delete contact
ContactFieldCreateApi contact_field_create POST /api/contacts/fields Create contact field
ContactFieldUpdateApi contact_field_update PATCH /api/contacts/fields/{id} Update contact field
ContactFieldsApi contact_fields GET /api/contacts/fields List of contact fields
ContactListAttachApi contact_list_attach POST /api/groups/attach Add contacts to the list
ContactListCreateApi contact_list_create POST /api/groups Create list
ContactListDeleteApi contact_list_delete DELETE /api/groups/{id} Delete list
ContactListDetachApi contact_list_detach POST /api/groups/detach Remove contacts from the list
ContactListSearchApi contact_list_search GET /api/groups/search Search list
ContactListTagApi contact_list GET /api/groups/{id} Get list by id
ContactListUpdateApi contact_list_update PUT /api/groups/{id} Update list
ContactListsApi contact_lists GET /api/groups List of contact lists
ContactTagApi contact GET /api/contacts/{id} Get contact by ID
ContactUpdateApi contact_update PUT /api/contacts/{id} Update contact
ContactsApi contacts GET /api/contacts List of contacts
ContactsDeleteApi contacts_delete POST /api/contacts/delete Delete multiple contacts
ContactsSearchApi contacts_search GET /api/contacts/search Search contacts
EmailSendApi email_send POST /api/email/send-emails Send Email
EmailTemplateSendApi email_template_send POST /api/email/send-template-emails Send Email template
GetMessagesApi get_messages GET /api/messages Find messages
GetSettingsAddressBookFieldsByIdApi get_settings_address_book_fields_by_id GET /api/settings/address-book-fields/{id} Get settings value
LoginApi login POST /api/auth/login Receive JWT token
OtpListApi otp_list GET /api/2fa/authentications List of authentication sessions
OtpTemplateApi otp_template GET /api/2fa/authentications/templates/{templateId} Get message template
OtpTemplateCreateApi otp_template_create POST /api/2fa/authentications/templates Create a message template
OtpTemplateDeleteApi otp_template_delete DELETE /api/2fa/authentications/templates/{templateId} Delete a message template
OtpTemplateListApi otp_template_list GET /api/2fa/authentications/templates List of message templates
PostCampaignsWhatsappSendApi post_campaigns_whatsapp_send POST /api/campaigns/whatsapp/send Send WhatsApp campaign
PostContactsFieldsDeleteApi post_contacts_fields_delete POST /api/contacts/fields/delete Delete contact fields by ids
RcsSendGroupsApi rcs_send POST /api/campaigns/rcs/send Send RCS message
RcsSingleApi rcs_single POST /api/messages/rcs/send Send single RCS message
RefreshTokenApi refresh_token POST /api/auth/refresh Refresh JWT token
ResendOtpApi resend_otp POST /api/2fa/authentications/otp/{id}/resend Resend the one-time code
SendOtpApi send_otp POST /api/2fa/authentications/otp Send One-time password
SenderRequestLegalApi sender_request_legal POST /api/senders/requests/legal Sender registration by a legal entity
SenderRequestNaturalApi sender_request_natural POST /api/senders/requests/natural Sender registration by an individual
SenderRequestsApi sender_requests GET /api/senders/requests/sms List of Sender Requests
SendersTagApi senders GET /api/senders List of Senders
ShortUrlsClicksApi short_urls_clicks GET /api/short-url/clicks List of clicks
ShortUrlsDomainApi short_urls_domain GET /api/short-url/domains/{uuid} Get domain by uuid
ShortUrlsDomainCreateApi short_urls_domain_create POST /api/short-url/domains Add domain
ShortUrlsDomainRemoveApi short_urls_domain_remove DELETE /api/short-url/domains/{uuid} Remove domain
ShortUrlsDomainUpdateApi short_urls_domain_update PUT /api/short-url/domains/{uuid} Update domain
ShortUrlsDomainsApi short_urls_domains GET /api/short-url/domains List of domains
ShortUrlsLinkApi short_urls_link GET /api/short-url/links/{uuid}/statistics Get short link statistic
ShortUrlsLinkCreateApi short_urls_link_create POST /api/short-url/links Create short link
ShortUrlsLinkDeleteApi short_urls_link_delete DELETE /api/short-url/links/{uuid} Remove short link
ShortUrlsLinkUpdateApi short_urls_link_update PUT /api/short-url/links/{uuid} Update short link
ShortUrlsLinksApi short_urls_links GET /api/short-url/links List of short links
SmsSendApi sms_send POST /api/campaigns/sms/send Send SMS campaign
SmsSendGroupsApi sms_send_groups POST /api/campaigns/sms/send-groups Send SMS to contact list
SmsSendIndividualApi sms_send_individual POST /api/campaigns/sms/send-individual Send SMS with different text
StatusOtpApi status_otp GET /api/2fa/authentications/{id} Check authentication status
StoplistAddApi stoplist_add POST /api/stoplist/attach Add contacts to stop list
StoplistItemsApi stoplist_items GET /api/stoplist List the contacts of stop lists
StoplistRemoveApi stoplist_remove POST /api/stoplist/detach Remove contacts from stop list
StoplistSearchApi stoplist_search GET /api/stoplist/search Search contacts in Stop lists
VerifyOtpApi verify_otp POST /api/2fa/authentications/otp/{id}/verify Check one-time Code

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

ExternalAuth

  • Type: Bearer authentication (JWT)

InternalAuth

  • Type: Bearer authentication (JWT)

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bsg_sdk-0.1.7.tar.gz (174.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bsg_sdk-0.1.7-py3-none-any.whl (581.0 kB view details)

Uploaded Python 3

File details

Details for the file bsg_sdk-0.1.7.tar.gz.

File metadata

  • Download URL: bsg_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 174.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for bsg_sdk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 6555c337801d9145364639650299fb3a8cdfeaa31d6741e9b7f353d6a5c89030
MD5 ff644c0d81e5f18dcdb7755b5400b800
BLAKE2b-256 1aae904025d2d1d73f1b23766db3d529f9eb72f5252dd8388c931db693624a31

See more details on using hashes here.

File details

Details for the file bsg_sdk-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: bsg_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 581.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for bsg_sdk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 27c1f239c4db1ab4e7540be834bb2fa442cdca7918b454dce29c9990bff5abc1
MD5 246a767e62b8e78ecb112d038f0f0964
BLAKE2b-256 7fefed1e77b24d8f385a931be6260fc6eacce3c8a50b6e2dacc769a6f4697dc9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page