cURL
curl "https://api.ruseo.cn/api/random_dog?breed=husky&sub_breed=shepherd&count=1&list=1"
获取随机狗狗图片,支持指定品种和数量,自动解析品种信息
https://api.ruseo.cn/api/random_dog
接口调用前需要确认的核心配置。
/api/random_dograndom_dog必填参数必须传入,示例值可直接用于联调。
免费API不强制要求API Key,但如果您希望统计个人调用次数,请在请求时附加参数 key=您的API_KEY。
注册账号后即可获得API Key。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
否 | string | 可选参数:携带此参数可统计您的个人调用次数。请注册账号获取API Key。 | YOUR_API_KEY |
breed |
否 | string | 指定品种,如husky/beagle,留空随机 | husky |
sub_breed |
否 | string | 指定子品种,如shepherd(需配合breed使用) | shepherd |
count |
否 | integer | 获取数量,1-50,默认1 | 1 |
list |
否 | string | 传1返回所有犬种列表,不再返回图片 | 1 |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/random_dog?breed=husky&sub_breed=shepherd&count=1&list=1
curl "https://api.ruseo.cn/api/random_dog?breed=husky&sub_breed=shepherd&count=1&list=1"
$url = 'https://api.ruseo.cn/api/random_dog?breed=husky&sub_breed=shepherd&count=1&list=1';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/random_dog?breed=husky&sub_breed=shepherd&count=1&list=1')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "random_dog",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
code |
integer | 状态码,0=成功 | |
data.count |
integer | 返回图片数量 | |
data.breed |
string | 品种名称 | |
data.sub_breed |
string | 子品种 | |
data.url |
string | 图片URL(单张时) | |
data.images |
array | 图片列表(含url/breed/sub_breed) | |
data.total_breeds |
integer | 犬种总数(list=1时) | |
data.breeds |
array | 犬种列表(list=1时,含breed/sub_breeds/sub_count) | |
点击左侧“发送请求”查看结果...