Bitel
2.0.0
2.0.0
  • Introduction
  • Authorization
  • API Structure
  • General API Errors
  • SMS
    • Introduction
    • Template SMS
    • OTP SMS
    • Single SMS
    • Batch SMS
    • Batch P2P SMS
    • SMS Status
  • Call
    • Introduction
    • OTP Call
    • Single Call
    • Single TTS Call
    • Batch Call
    • Batch TTS Call
    • Call Status
  • Webhook
    • Sms Webhook Events
    • Voice Webhook Events
  • Files
    • Introduction
    • Upload Voice
    • Text To Speech
    • Download Voice
  • Code Samples
    • C#
    • PHP
    • Python
Powered by GitBook
On this page
  • Requirements
  • Send Single SMS
  • Sending P2P SMS
  • Sending OTP Code
  • Making Single Call

Was this helpful?

  1. Code Samples

Python

Requirements

Make sure you have imported the following packages:

import requests
import json

Send Single SMS

import requests
import json

jwt_token = 'YOUR JWT TOKEN'
phone = '0912*******'
message = 'Hi, there'

payload = {
    'phoneNumber': phone,
    'message': message
}

headers = {
    'Authorization': 'Bearer ' + jwt_token,
    'content-type': 'application/json'
}

response = requests.post('https://api.bitel.rest/api/v1/sms/single',
                         json=payload, headers=headers)

if response.status_code != 200:
    print(response.content, response.status_code)
else:
    result = json.loads(response.content)
    rquest_id = result['result']['requestId']
    print(f'requestId is {rquest_id}')

Sending P2P SMS

import requests
import json

jwt_token = 'YOUR JWT TOKEN'
phones = ['0912*******', '0936******']
messages = ['Hi, there', 'Hello, there']

payload = {
    'phoneNumbers': phones,
    'messages': messages
}

headers = {
    'Authorization': 'Bearer ' + jwt_token,
    'content-type': 'application/json'
}

response = requests.post('https://api.bitel.rest/api/v1/sms/p2p',
                         json=payload, headers=headers)

if (response.status_code != 200):
    print(response.content, response.status_code)
else:
    result = json.loads(response.content)
    batch_id = result["result"]
    print(f'batchId is {batch_id}')

Sending OTP Code

import requests
import json

jwt_token = 'YOUR JWT TOKEN'
phone = '0912*******'
text = '1234'

payload = {
    'phoneNumber': phone,
    'text': text
}

headers = {
    'Authorization': 'Bearer ' + jwt_token,
    'content-type': 'application/json'
}

response = requests.post('https://api.bitel.rest/api/v1/voice/otp',
                         json=payload, headers=headers)

if (response.status_code != 200):
    print(response.content, response.status_code)
else:
    result = json.loads(response.content)
    request_id = result["result"]
    print(f'requestId is {request_id}')

Making Single Call

import requests
import json

jwt_token = 'YOUR JWT TOKEN'
phone = '0912*******'
voice_id = 'VOICE ID'

payload = {
    'phoneNumber': phone,
    'voiceId': voice_id
}

headers = {
    'Authorization': 'Bearer ' + jwt_token,
    'content-type': 'application/json'
}

response = requests.post('https://api.bitel.rest/api/v1/voice/play',
                         json=payload, headers=headers)

if (response.status_code != 200):
    print(response.content, response.status_code)
else:
    result = json.loads(response.content)
    request_id = result["result"]
    print(f'requestId is {request_id}')
PreviousPHP

Last updated 6 years ago

Was this helpful?