YunShang API

Balance (balance)

Returns the available balance of the current account. No extra parameters besides the common ones. Sales/admin only.

API info

ItemValue
EndpointPOST /api.php
actionbalance
AuthenticationGlobal APP ID / APP KEY
Role restrictionSales / admin only

Request parameters

No extra parameters besides the common ones (action / app_id / app_key).

Request example

{
    "action": "balance",
    "app_id": "68B0FA47FEC9E7EBC4BF80F8",
    "app_key": "2b901515a427b6c0b68f866eece70e0d2ecf687146022412"
}

PHP

<?php
$app_id = '68B0FA47FEC9E7EBC4BF80F8';
$app_key = '2b901515a427b6c0b68f866eece70e0d2ecf687146022412';
$url = 'https://yunsapi.com/api.php';

$params = [
    'action'  => 'balance',
    'app_id'  => $app_id,
    'app_key' => $app_key,
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($ch);
curl_close($ch);
echo $resp;

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class ApiDemo {
    static final String URL = "https://yunsapi.com/api.php";
    static final String APP_ID = "68B0FA47FEC9E7EBC4BF80F8";
    static final String APP_KEY = "2b901515a427b6c0b68f866eece70e0d2ecf687146022412";

    public static void main(String[] args) throws Exception {
        String body = "{\"action\":\"balance\",\"app_id\":\"" + APP_ID + "\",\"app_key\":\"" + APP_KEY + "\"}";
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest req = HttpRequest.newBuilder()
                .uri(URI.create(URL))
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(body))
                .build();
        HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println(resp.body());
    }
}

Response example

{
    "code": 0,
    "msg": "success",
    "data": {
        "balance": 10000.0000
    }
}

Response parameters

ParameterTypeDescription
data.balancefloatAccount balance (4-decimal)