API 对接文档
所有接口通过 HTTP POST 调用,请求与响应均为 JSON 格式。
简介
接口地址(所有 action 共用):
https://www.youlema.net.cn/api/v1/index.php
| 项目 | 值 |
|---|---|
| 协议 | HTTP / HTTPS |
| 方法 | POST(GET 也兼容,不推荐) |
| 编码 | UTF-8 |
| 响应格式 | application/json |
| 时间精度 | 秒级时间戳,5 分钟内有效 |
💡 建议:正式使用前先阅读「认证」→「签名算法」,然后用「在线测试」验证通过后,再接入生产代码。
认证
每次请求必须携带以下 4 个公共参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
api_key | string | 是 | 用户端「API 信息」页获取 |
timestamp | int | 是 | 秒级时间戳,与服务器时间偏差不超过 300 秒 |
sign | string | 是 | 签名:md5(api_key + timestamp + api_secret) |
action | string | 是 | 接口名,见「接口列表」 |
⚠️ 你未登录。请先登录用户端「API 信息」页获取自己的 Key / Secret。
签名算法
将 api_key、timestamp、api_secret 三个值按顺序拼接成字符串,
再对整体做 MD5,得到的 32 位小写十六进制字符串即为 sign。
sign = md5(api_key + timestamp + api_secret)
= md5("your_api_key" + "1700000000" + "your_api_secret")
PHP 示例
$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$timestamp = time();
$sign = md5($apiKey . $timestamp . $apiSecret);
Python 示例
import hashlib, time
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
timestamp = int(time.time())
sign = hashlib.md5((api_key + str(timestamp) + api_secret).encode()).hexdigest()
⚠️ 不要泄露 API Secret。
sign 是每次请求现算的,Secret 本身不参与网络传输。
查询余额
POSTaction=balance
返回当前账户余额(单位:元)。
额外参数
无。只需 4 个公共参数。
返回示例
{
"code": 0,
"msg": "success",
"data": { "balance": 1288.50 }
}
查询手机号
POSTaction=list_phones
列出池子中已审核通过且未被调用的手机号。
额外参数(均可选)
| 参数 | 类型 | 说明 |
|---|---|---|
operator | string | 运营商筛选:移动 / 联通 / 电信 / 其他 |
amount_min | float | 最低充值金额(元),如 50 只返回 ≥ 50 元的手机号 |
返回示例
{
"code": 0,
"msg": "success",
"data": [
{
"id": 123,
"phone": "13800138000",
"amount": 100.00,
"operator": "移动",
"game_account": "game_abc"
}
]
}
创建订单
POSTaction=create_order
从池子中选一个手机号下单。订单创建后会立即从余额扣除对应金额,并返回手机号信息。
选号方式(二选一)
- 指定 ID:传
phone_id,直接用指定的手机号 - 自动挑选:不传
phone_id,系统按operator/amount_min条件自动选一个
额外参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone_id | int | 否 | 指定手机号 ID(从 list_phones 获取) |
operator | string | 否 | 仅自动挑选时生效:运营商筛选 |
amount_min | float | 否 | 仅自动挑选时生效:最低金额筛选 |
⚠️ 以下情况会创建失败并返回错误码:
•
•
• 系统会自动加行锁,避免并发下单重复核销
•
200 池子里没有符合条件的手机号•
201 账户余额不足• 系统会自动加行锁,避免并发下单重复核销
返回示例
{
"code": 0,
"msg": "success",
"data": {
"order_no": "OD202611150000001234",
"phone": "13800138000",
"amount": 100.00,
"game_account": "game_abc",
"card_pwd": "CARD-XXXX-YYYY"
}
}
查询订单
POSTaction=query_order
额外参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
order_no | string | 是 | 创建订单时返回的订单号 |
返回示例
{
"code": 0,
"msg": "success",
"data": {
"id": 5678,
"order_no": "OD202611150000001234",
"user_id": 42,
"phone": "13800138000",
"amount": 100.00,
"game_account": "game_abc",
"card_pwd": "CARD-XXXX-YYYY",
"status": 1,
"created_at": "2026-11-15 10:30:00"
}
}
错误码
| code | 说明 | 建议处理 |
|---|---|---|
| 0 | 成功 | 正常处理数据 |
| 100 | 参数缺失(api_key/timestamp/sign/action 任一为空) | 检查请求参数 |
| 101 | timestamp 已过期(与服务器时间偏差 > 300s) | 校准客户端时间后重试 |
| 102 | API Key 无效或账号已被禁用 | 检查 Key 或联系管理员 |
| 103 | 签名错误 | 检查 sign 计算顺序(key+ts+secret) |
| 104 | 未知 action | 检查 action 拼写 |
| 200 | 池子无可用手机号 | 稍后重试或放宽筛选条件 |
| 201 | 余额不足 | 联系管理员充值 |
| 404 | 订单不存在 | 检查 order_no |
| 500 | 系统错误 | 重试或联系管理员 |
示例代码
以下为「创建订单」的完整示例(余额查询等只要把 action 换掉即可)。
API_URL="https://www.youlema.net.cn/api/v1/index.php"
API_KEY="YOUR_API_KEY"
API_SECRET="YOUR_API_SECRET"
TS=$(date +%s)
SIGN=$(echo -n "${API_KEY}${TS}${API_SECRET}" | md5sum | cut -d' ' -f1)
curl -X POST "$API_URL" \
-d "api_key=${API_KEY}" \
-d "timestamp=${TS}" \
-d "sign=${SIGN}" \
-d "action=create_order" \
-d "operator=移动" \
-d "amount_min=50"
<?php
$apiUrl = 'https://www.youlema.net.cn/api/v1/index.php';
$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$timestamp = time();
$sign = md5($apiKey . $timestamp . $apiSecret);
$params = [
'api_key' => $apiKey,
'timestamp' => $timestamp,
'sign' => $sign,
'action' => 'create_order',
'operator' => '移动',
'amount_min' => 50,
];
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
]);
$resp = curl_exec($ch);
curl_close($ch);
$data = json_decode($resp, true);
if ($data['code'] === 0) {
echo "订单号: " . $data['data']['order_no'] . PHP_EOL;
echo "手机号: " . $data['data']['phone'] . PHP_EOL;
echo "游戏号: " . $data['data']['game_account'] . PHP_EOL;
} else {
echo "失败: [" . $data['code'] . "] " . $data['msg'] . PHP_EOL;
}
import time, hashlib, requests
API_URL = "https://www.youlema.net.cn/api/v1/index.php"
API_KEY = "YOUR_API_KEY"
API_SECRET = "YOUR_API_SECRET"
ts = int(time.time())
sign = hashlib.md5(f"{API_KEY}{ts}{API_SECRET}".encode()).hexdigest()
payload = {
"api_key": API_KEY,
"timestamp": ts,
"sign": sign,
"action": "create_order",
"operator": "移动",
"amount_min": 50,
}
resp = requests.post(API_URL, data=payload, timeout=15).json()
if resp["code"] == 0:
d = resp["data"]
print(f"订单号: {d['order_no']}")
print(f"手机号: {d['phone']}")
print(f"游戏号: {d['game_account']}")
else:
print(f"失败: [{resp['code']}] {resp['msg']}")
const crypto = require('crypto');
const axios = require('axios');
const API_URL = 'https://www.youlema.net.cn/api/v1/index.php';
const API_KEY = 'YOUR_API_KEY';
const API_SECRET = 'YOUR_API_SECRET';
const ts = Math.floor(Date.now() / 1000);
const sign = crypto.createHash('md5')
.update(`${API_KEY}${ts}${API_SECRET}`)
.digest('hex');
const form = new URLSearchParams({
api_key: API_KEY,
timestamp: ts,
sign,
action: 'create_order',
operator: '移动',
amount_min: 50,
});
(async () => {
const { data } = await axios.post(API_URL, form, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
timeout: 15000,
});
if (data.code === 0) {
console.log('订单号:', data.data.order_no);
console.log('手机号:', data.data.phone);
console.log('游戏号:', data.data.game_account);
} else {
console.log(`失败: [${data.code}] ${data.msg}`);
}
})();
import java.net.URI;
import java.net.http.*;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.net.URLEncoder;
import java.time.Instant;
import java.util.*;
public class ApiDemo {
public static void main(String[] args) throws Exception {
String apiUrl = "https://www.youlema.net.cn/api/v1/index.php";
String apiKey = "YOUR_API_KEY";
String apiSecret = "YOUR_API_SECRET";
long ts = Instant.now().getEpochSecond();
String sign = md5(apiKey + ts + apiSecret);
Map<String, String> params = new LinkedHashMap<>();
params.put("api_key", apiKey);
params.put("timestamp", String.valueOf(ts));
params.put("sign", sign);
params.put("action", "create_order");
params.put("operator", "移动");
params.put("amount_min", "50");
StringBuilder body = new StringBuilder();
for (Map.Entry<String, String> e : params.entrySet()) {
if (body.length() > 0) body.append("&");
body.append(URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8))
.append("=")
.append(URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8));
}
HttpClient client = HttpClient.newHttpClient();
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(apiUrl))
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(body.toString()))
.build();
System.out.println(client.send(req, HttpResponse.BodyHandlers.ofString()).body());
}
static String md5(String s) throws Exception {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] bytes = md.digest(s.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for (byte b : bytes) sb.append(String.format("%02x", b));
return sb.toString();
}
}
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
func main() {
apiURL := "https://www.youlema.net.cn/api/v1/index.php"
apiKey := "YOUR_API_KEY"
apiSecret := "YOUR_API_SECRET"
ts := time.Now().Unix()
hash := md5.Sum([]byte(apiKey + strconv.FormatInt(ts, 10) + apiSecret))
sign := hex.EncodeToString(hash[:])
form := url.Values{
"api_key": {apiKey},
"timestamp": {strconv.FormatInt(ts, 10)},
"sign": {sign},
"action": {"create_order"},
"operator": {"移动"},
"amount_min": {"50"},
}
resp, err := http.Post(apiURL, "application/x-www-form-urlencoded",
strings.NewReader(form.Encode()))
if err != nil { panic(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
在线测试
填写 Key/Secret 和参数,点击「发送请求」,直接在浏览器里调用本系统 API。
响应结果
// 填写参数后点击「发送请求」
💡 在线测试的
sign 是在浏览器里实时计算的。生产环境请务必在后端计算,
不要把 Secret 放到前端代码里。