Balance Query

GET

https://api.itniotech.com/sms/getBalance

The protocol is used to get account balance
 
Request Sample
Request URL:
    https://api.itniotech.com/sms/getBalance
Request Method:
    GET
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
 
Response Parameters
Parameters Description Type
status "0"means successful,others than 0 means failure, seeing Status Code description. String
reason Failure reason description String
balance Actual account balance String
gift Gifted account balance String
credit Credit account balance String
 
Response Status Code
status Description
0 success
-1 Authentication error
-2 Restricted IP access
-13 User locked
-16 Timestamp expires
-18 port program unusual
 

language

Java

PHP

Curl

Python

REQUEST

package com.itniotech.api.demo.sms;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;

import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

private void getBalance() {
    final String baseUrl = "https://api.itniotech.com/sms";
    final String apiKey = "your api key";
    final String apiPwd = "your api secret";

    final String url = baseUrl.concat("/getBalance");
    System.out.println(url);
    HttpRequest request = HttpRequest.get(url);
    // currentTime
    final String datetime = String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond());
    // generate md5 key
    final String sign = SecureUtil.md5(apiKey.concat(apiPwd).concat(datetime));
    request.header(Header.CONNECTION, "Keep-Alive")
            .header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
            .header("Sign", sign)
            .header("Timestamp", datetime)
            .header("Api-Key", apiKey);
    HttpResponse response = request.execute();
    if (response.isOk()) {
        String result = response.body();
        System.out.println(result);
    }
}        
                

REQUEST

$apiKey = "your api key";
$apiSecret = "your api secret";
$url = "https://api.itniotech.com/sms/getBalance";
$timeStamp = time();
$sign = md5($apiKey.$apiSecret.$timeStamp);
$headers = array('Content-Type:application/json;charset=UTF-8',"Sign:$sign","Timestamp:$timeStamp","Api-Key:$apiKey");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

$output = curl_exec($ch);
curl_close($ch);

var_dump($output);
echo $output;        
                

REQUEST

curl -X GET 'https://api.itniotech.com/sms/getBalance'
-H 'Timestamp: {datetime}'
-H 'Api-Key: {apiKey}'
-H 'Sign: {sign}'
-H 'Content-Type: application/json;charset=UTF-8'        
                

REQUEST

import hashlib
import time
import requests
import json

base_url = "https://api.itniotech.com/sms/"
api_key = "your api key"
api_pwd = "your api secret"

def create_headers():
  timestamp = int(time.time())
  s = "%s%s%s" % (api_key, api_pwd, str(timestamp))
  sign = hashlib.md5(s.encode(encoding='UTF-8')).hexdigest()
  headers = {
    'Content-Type': 'application/json;charset=utf-8',
    'Sign': sign,
    'Timestamp': str(timestamp),
    'Api-Key': api_key
  }
  return headers

headers = create_headers()

url = "%s/getBalance" % base_url
print(url)

rsp = requests.get(url, headers=headers)
if rsp.status_code == 200:
    res = json.loads(rsp.text)
  print(res)        
                
 

RESPONSEEXAMPLE

{
    "status": "0",
    "reason": "success",
    "balance": "99.990000",
    "gift": "50.00000",
    "credit": "0"
}