短网址
把长网址生成本站短链,默认 30 天有效。用户点开自动跳转并统计点击,点击不扣次数。
调用地址:https://api.ynlskj.com.cn/gateway/shorturl
复制
请求方法:POST
在其他地方怎么调用
请求地址用上面的调用地址,把 JSON 放在请求体里
方法用 POST
API Key 只能放在请求头 X-API-Key,不要写进网址,也不要写进 Query 框
Key 在「个人中心 → API Key」里复制,登录后会自动填入你自己的 Key
参数说明
参数 位置 必填 说明
urlBody JSON 是 要缩短的长网址,须为 http 或 https。也可用 long_url。可省略 https://
expire_daysBody JSON 否 有效天数,默认 30,范围 1–365
fromBody JSON 否 投放来源,生成时传入。如 taobao、dy。这条短链的所有点击都记到该来源。也可用 source
X-API-KeyHeader 是 你的 API Key
请求示例
场景 Body 示例
默认 30 天 {"url":"https://www.example.com"}
淘宝投放 {"url":"https://www.example.com","from":"taobao"}
抖音投放 {"url":"https://www.example.com","from":"dy"}
点击次数和来源在哪里看
生成时把 from 传进去,会扣 1 次套餐次数,得到干净短链(形如 https://api.ynlskj.com.cn/s.php/短码),不用再拼参数
同一个长链要投多个渠道,就生成多条短链,每条换一个 from
用户点开这条短链会跳转并记到对应来源,点击不扣次数
登录后打开「个人中心 → 我的短链」,可以看到每条短链绑定的来源和点击次数
程序里也可以访问 短链?info=1 拿 JSON,不消耗套餐次数,也不会算一次点击
常用来源码
from 渠道
taobao淘宝
dy抖音
wx微信
xhs小红书
ks快手
jd京东
也可以自己定义,如 live01,字母数字下划线即可。不传 from 则记为「未区分」。
返回说明
字段 说明
retok 成功,err 失败
data.short_url可直接发给用户的短链,干净地址,不用再拼参数
data.code短码
data.url规范化后的原网址
data.from生成时绑定的来源码,如 taobao。未传则为 direct
data.from_name来源中文名,如淘宝
data.expire_days本次有效天数
data.expire_at到期时间
data.hits当前点击次数,刚生成时为 0
data.stats_url查询点击的 JSON 地址,访问它不扣次数、不加点击
msg本站提示,如「次数充足,剩余 99 次」或「次数不足,剩余 0 次」
remain_quota本次调用后的剩余次数
可直接复制的代码
未登录时示例只显示「你的密钥」。登录后会自动填入你自己的 Key,不会展示别人的。
PHP
Python
Go
JavaScript
Java
C#
cURL
复制
<?php
$ch = curl_init('https://api.ynlskj.com.cn/gateway/shorturl');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['X-API-Key: 你的密钥', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{
"url": "https://www.example.com",
"from": "taobao"
}',
]);
echo curl_exec($ch);
复制
import requests
url = 'https://api.ynlskj.com.cn/gateway/shorturl'
headers = {'X-API-Key': '你的密钥'}
resp = requests.post(url, headers=headers, json={
"url": "https://www.example.com",
"from": "taobao"
}, timeout=15)
print(resp.text)
复制
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"url": "https://www.example.com",
"from": "taobao"
}`)
req, _ := http.NewRequest("POST", "https://api.ynlskj.com.cn/gateway/shorturl", body)
req.Header.Set("X-API-Key", "你的密钥")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}
复制
fetch('https://api.ynlskj.com.cn/gateway/shorturl', {
method: 'POST',
headers: {
'X-API-Key': '你的密钥',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"url": "https://www.example.com",
"from": "taobao"
})
})
.then(res => res.json())
.then(data => console.log(data));
复制
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.ynlskj.com.cn/gateway/shorturl"))
.header("X-API-Key", "你的密钥")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\n \"url\": \"https://www.example.com\",\n \"from\": \"taobao\"\n}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
复制
using System.Net.Http;
using System.Text;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "你的密钥");
var content = new StringContent("{\n \"url\": \"https://www.example.com\",\n \"from\": \"taobao\"\n}", Encoding.UTF8, "application/json");
var result = await client.PostAsync("https://api.ynlskj.com.cn/gateway/shorturl", content);
Console.WriteLine(await result.Content.ReadAsStringAsync());
复制
curl -X POST "https://api.ynlskj.com.cn/gateway/shorturl" \
-H "X-API-Key: 你的密钥" \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.example.com",
"from": "taobao"
}'
请求参数演示
{"url":"https://www.example.com"}
响应演示
{"ret":"ok","data":{"code":"a8Kx2pQ","short_url":"https://api.ynlskj.com.cn/s/a8Kx2pQ","url":"https://www.example.com","expire_days":30,"expire_at":"2026-09-17 13:00:00","hits":0,"stats_url":"https://api.ynlskj.com.cn/s/a8Kx2pQ?info=1","expired":false}}