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}')
Last updated