0% found this document useful (0 votes)
30 views

SMS- Activate API Script

The document provides Python code for interacting with the SMS Activate API to check account balances and request phone numbers. It includes functions to get the balance and balance with cashback, as well as to request a phone number with various parameters. Error handling is implemented for API responses to ensure proper feedback on the request status.

Uploaded by

jasirjabbar789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

SMS- Activate API Script

The document provides Python code for interacting with the SMS Activate API to check account balances and request phone numbers. It includes functions to get the balance and balance with cashback, as well as to request a phone number with various parameters. Error handling is implemented for API responses to ensure proper feedback on the request status.

Uploaded by

jasirjabbar789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SMS Activate

Balance Request

import requests

api_key = 'Entre Your API KEY'

def get_balance(api_key):
url = f"https://api.sms-activate.io/stubs/handler_api.php?
api_key={api_key}&action=getBalance"
response = requests.get(url)
if response.status_code == 200:
data = response.text
if 'ACCESS_BALANCE' in data:
print(f"Account balance: {data.split(':')[1].strip()}")
elif 'BAD_KEY' in data:
print("Invalid API key.")
elif 'ERROR_SQL' in data:
print("SQL server error.")
else:
print("Unknown error.")
else:
print(f"Failed to get response: {response.status_code}")

def get_balance_with_cashback(api_key):
url = f"https://api.sms-activate.io/stubs/handler_api.php?
api_key={api_key}&action=getBalanceAndCashBack"
response = requests.get(url)
if response.status_code == 200:
data = response.text
if 'ACCESS_BALANCE' in data:
print(f"Account balance with cashback: {data.split(':')[1].strip()}")
elif 'BAD_KEY' in data:
print("Invalid API key.")
elif 'ERROR_SQL' in data:
print("SQL server error.")
else:
print("Unknown error.")
else:
print(f"Failed to get response: {response.status_code}")

# Fetch balances
get_balance(api_key)
get_balance_with_cashback(api_key)

Request number

import requests

def request_number_v2(api_key, service, country, forward=0, maxPrice='',


phoneException='', operator='', verification='', userId=''):
url = "https://api.sms-activate.io/stubs/handler_api.php"
params = {
'api_key': api_key,
'action': 'getNumberV2',
'service': service,
'forward': forward,
'maxPrice': maxPrice,
'phoneException': phoneException,
'operator': operator,
'verification': verification,
'userId': userId,
'country': country
}

# Remove empty parameters


params = {k: v for k, v in params.items() if v not in ['', None]}

response = requests.get(url, params=params)

if response.status_code == 200:
data = response.json() # Parse response as JSON
print("Response:", data)
if 'activationId' in data:
print(f"Activation ID: {data['activationId']}")
print(f"Phone Number: {data['phoneNumber']}")
print(f"Activation Cost: {data['activationCost']}")
print(f"Country Code: {data['countryCode']}")
print(f"Can Get Another SMS: {data['canGetAnotherSms']}")
print(f"Activation Time: {data['activationTime']}")
print(f"Activation Operator: {data['activationOperator']}")
else:
print("Error or unexpected response:", data)
else:
print(f"Failed to get response: {response.status_code}")
print("Response content:", response.text)

# Example usage
api_key = 'API KEY'
request_number_v2(api_key, 'google', 'HK', forward=0, maxPrice='',
phoneException='', operator='', verification='', userId='')

You might also like