本站短剧资源分享API使用说明
API接口概述
本站提供了一系列API接口,方便开发者获取和使用短剧资源数据。通过这些接口,您可以获取短剧列表、详情、搜索等信息,为您的应用或网站提供丰富的短剧内容。
所有API接口均支持GET请求,返回JSON格式数据。接口调用无需API密钥,但请合理使用,避免过度请求影响服务稳定性。
接口列表
1. 获取短剧列表
GET /api/index.php?action=list 或 /api/index.php?action=getDramas
参数说明:
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| page | int | 否 | 页码,默认1 |
| limit | int | 否 | 每页数量,默认20 |
| keyword | string | 否 | 搜索关键词,不指定则获取全部 |
返回示例:
{
"success": true,
"data": [
{
"id": 1,
"title": "短剧标题",
"link": "网盘链接",
"description": "短剧描述",
"category_id": 1,
"is_announcement": 0,
"is_top": 1,
"view_count": 100,
"created_at": "2026-03-01 10:00:00",
"updated_at": "2026-03-01 10:00:00"
},
...
],
"total": 100,
"page": 1,
"limit": 20
}
2. 获取短剧详情
GET /api/index.php?action=detail 或 /api/index.php?action=getDrama
参数说明:
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| id | int | 是 | 短剧ID |
返回示例:
{
"success": true,
"data": {
"id": 1,
"title": "短剧标题",
"link": "网盘链接",
"description": "短剧描述",
"category_id": 1,
"is_announcement": 0,
"is_top": 1,
"view_count": 101,
"created_at": "2026-03-01 10:00:00",
"updated_at": "2026-03-01 10:00:00"
}
}
3. 搜索短剧
GET /api/index.php?action=search
参数说明:
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
| keyword | string | 是 | 搜索关键词 |
| page | int | 否 | 页码,默认1 |
| limit | int | 否 | 每页数量,默认20 |
返回示例:
{
"success": true,
"data": [
{
"id": 1,
"title": "短剧标题",
"link": "网盘链接",
"description": "短剧描述",
"category_id": 1,
"is_announcement": 0,
"is_top": 1,
"view_count": 100,
"created_at": "2026-03-01 10:00:00",
"updated_at": "2026-03-01 10:00:00"
},
...
],
"total": 10,
"page": 1,
"limit": 20
}
响应格式说明
所有API接口均返回JSON格式数据,包含以下字段:
| 字段名 | 类型 | 描述 |
|---|---|---|
| success | boolean | 操作是否成功,true表示成功,false表示失败 |
| message | string | 状态消息,仅在失败时返回错误信息 |
| data | array/object | 返回的数据,根据接口不同而不同 |
| total | int | 总数据量,仅在列表和搜索接口返回 |
| page | int | 当前页码,仅在列表和搜索接口返回 |
| limit | int | 每页数量,仅在列表和搜索接口返回 |
调用示例
JavaScript (Fetch API)
// 获取短剧列表
fetch('https://duanjucn.com/api/index.php?action=list&page=1&limit=20')
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('短剧列表:', data.data);
console.log('总数量:', data.total);
} else {
console.error('获取失败:', data.message);
}
})
.catch(error => console.error('请求错误:', error));
// 获取短剧详情
fetch('https://duanjucn.com/api/index.php?action=detail&id=1')
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('短剧详情:', data.data);
} else {
console.error('获取失败:', data.message);
}
})
.catch(error => console.error('请求错误:', error));
// 搜索短剧
fetch('https://duanjucn.com/api/index.php?action=search&keyword=爱情&page=1&limit=20')
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('搜索结果:', data.data);
console.log('总数量:', data.total);
} else {
console.error('搜索失败:', data.message);
}
})
.catch(error => console.error('请求错误:', error));
PHP (cURL)
// 获取短剧列表
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://duanjucn.com/api/index.php?action=list&page=1&limit=20');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
print_r($data['data']);
echo '总数量: ' . $data['total'];
} else {
echo '获取失败: ' . $data['message'];
}
// 获取短剧详情
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://duanjucn.com/api/index.php?action=detail&id=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
print_r($data['data']);
} else {
echo '获取失败: ' . $data['message'];
}
// 搜索短剧
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://duanjucn.com/api/index.php?action=search&keyword=爱情&page=1&limit=20');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
print_r($data['data']);
echo '总数量: ' . $data['total'];
} else {
echo '搜索失败: ' . $data['message'];
}
注意事项
- API调用限制:为保证服务稳定性,API设置了调用频率限制,建议每IP每分钟不超过60次请求
- 域名黑名单:系统会检查请求来源域名,被列入黑名单的域名将无法调用API
- 数据更新:API返回的数据可能会有延迟,实际数据以网站显示为准
- 合法使用:API接口仅供合法使用,请勿用于任何违法或滥用行为
- 接口变更:API接口可能会根据系统需要进行调整,请注意关注接口变更通知
- 服务稳定性:本API为免费服务,不保证100%的可用性和稳定性
- 反馈渠道:如有API使用问题或建议,请通过网站的"求资源"功能进行反馈
常见问题
Q: 为什么返回的数据与网站显示的不一致?
A: API返回的数据可能会有缓存延迟,建议在获取数据后进行适当的缓存处理。
Q: 如何提高API调用速度?
A: 建议合理设置page和limit参数,避免一次性请求过多数据,同时对获取的数据进行本地缓存。
Q: 搜索接口支持哪些搜索方式?
A: 搜索接口支持关键词模糊搜索,会匹配短剧标题和描述中的关键词。
Q: API调用失败怎么办?
A: 请检查参数是否正确,网络连接是否正常,如果问题持续存在,请通过网站的"求资源"功能进行反馈。
状态码说明
| 状态 | 描述 |
|---|---|
| success: true | 操作成功 |
| success: false | 操作失败 |
| message: "API调用过于频繁,请稍后再试" | API调用频率超过限制 |
| message: "该域名已被禁止调用API" | 域名被列入黑名单 |
| message: "资源不存在" | 请求的资源不存在 |
| message: "无效的API操作" | 请求的action参数无效 |