Products (products)
Returns all enabled products (APIs). No extra parameters besides the common ones. Sales/admin only.
API info
| Item | Value |
|---|---|
| Endpoint | POST /api.php |
| action | products |
| Authentication | Global APP ID / APP KEY |
| Role restriction | Sales / admin only |
Request parameters
No extra parameters besides the common ones (action / app_id / app_key).
Request example
{
"action": "products",
"app_id": "68B0FA47FEC9E7EBC4BF80F8",
"app_key": "2b901515a427b6c0b68f866eece70e0d2ecf687146022412"
}
PHP
<?php
$app_id = '68B0FA47FEC9E7EBC4BF80F8';
$app_key = '2b901515a427b6c0b68f866eece70e0d2ecf687146022412';
$url = 'https://yunsapi.com/api.php';
$params = [
'action' => 'products',
'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\":\"products\",\"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": [
{
"id": "1",
"cat_id": "1",
"name": "SMS Verification",
"code": "dxyzm",
"price": "0.0000",
"is_buyout": "0",
"intro": "Send SMS verification code via Alibaba Cloud",
"doc_url": "https://yunsapi.com/doc/?page=dxyzm",
"status": "1",
"require_realname": "1"
}
]
}
Response parameters
| Parameter | Type | Description |
|---|---|---|
data[].id | string | API ID |
data[].name | string | API name |
data[].code | string | API code |
data[].price | string | Original price |
data[].is_buyout | string | Whether buyout (1 buyout / 0 package) |
data[].intro | string | Intro |
data[].doc_url | string | Doc URL |
data[].require_realname | string | Whether real-name is required (1 yes / 0 no) |