Skip to content

bsgworld/python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

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_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

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

Watchers

Forks

Packages

No packages published

Languages