+(923) 111 88 4444
TecniForge, 79/5-L, Sahiwal 57000

USSD – Send USSD Request

USSD – Send USSD Request

Send USSD Request. Requires “ussd” API permission.POST https://androidapi.net/api/send/ussd

Parameter #

FieldTypeDescription
secretStringThe API secret you copied from (Tools -> API Keys) page
codeStringMMI request code. Please make sure that you are using a valid MMI code, if not, it will fail.
simNumberSim slot number you want to use.
deviceStringLinked device unique ID. You can get linked device unique ID from /get/devices (Your devices).

Success Response Format #

FieldTypeDescription
statusNumberList of Codes
200 = Success
messageStringResponse message
dataArrayArray of data

Error Response Format #

NameTypeDescription
statusNumberList of Codes
400 = Invalid parameters
401 = Invalid API secret
403 = Access denied
404 = Device doesn’t exist
500 = Something went wrong
messageStringResponse message
dataArrayArray of data

PHP Sample #

<?php

  $ussd = [
      "secret" => "API_SECRET", // your API secret from (Tools -> API Keys) page
      "code" => "*121#",
      "sim" => 1,
      "device" => "00000000-0000-0000-d57d-f30cb6a89289"
  ];

  $cURL = curl_init("https://androidapi.net/api/send/ussd");
  curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($cURL, CURLOPT_POSTFIELDS, $ussd);
  $response = curl_exec($cURL);
  curl_close($cURL);

  $result = json_decode($response, true);

  // do something with response
  print_r($result);

Python Sample #

import requests

# your API secret from (Tools -> API Keys) page
apiSecret = "API_SECRET"

ussd = {
    "secret": apiSecret,
    "code": "*121#",
    "sim": 1,
    "device": "00000000-0000-0000-d57d-f30cb6a89289"
}

r = requests.post(url = "https://androidapi.net/api/send/ussd", params = ussd)
  
# do something with response object
result = r.json()

Successful Response #

{
  "status": 200,
  "message": "WhatsApp message has been queued for sending!",
  "data": false
}

Error Response #

{
  "status": 400,
  "message": "Invalid Parameters!",
  "data": false
}

Leave A Comment