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

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.0.tar.gz (133.8 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.0-py3-none-any.whl (428.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bsg_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3cecf5263bfeb44f1f0796f51de4310600fff78e24771fe6a0593bcdda9722af
MD5 01d1101779741453ea6bf8523cbe2d2b
BLAKE2b-256 06db6ef4120bf2e2115d5604f017f5e1c10fcc6a7e04f6f46aa4b138853e6da2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bsg_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aab20115b26e9886666f3a84382e8c0eb7186ecc6d60d64a2e2d9d637d347884
MD5 87e315c33a2afb5ba75dbb93560e6158
BLAKE2b-256 57733e86e310ebcc33d7bdabe5148e78443ced94c71eb9fd5d3e8d70871471a2

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