返回 | 接口 / 实用工具 / 随机颜色
GET 实用工具

随机颜色

生成随机颜色,同时给出 hex 与 rgb。

累计调用 9 今日调用 0

更新于 2026-10-16

调用地址

GET
https://itapi.top/api/randcolor

请求参数

参数名类型必填说明示例
n int 可选 生成个数,默认 1 1

返回字段

字段名类型说明
code int 状态码
data.hex string 十六进制色值
data.rgb string rgb 形式
data.colors array 颜色列表

响应示例

200 OK
{"code":200,"msg":"success","data":{"count":1,"colors":[{"hex":"#b3437b","rgb":"rgb(179, 67, 123)","r":179,"g":67,"b":123}],"hex":"#b3437b","rgb":"rgb(179, 67, 123)"}}

在线测试

代码示例

cURL · GET
curl "https://itapi.top/api/randcolor?n=1"
PHP
<?php
$res  = file_get_contents("https://itapi.top/api/randcolor?n=1");
$json = json_decode($res, true);
print_r($json);
JavaScript
const res  = await fetch("https://itapi.top/api/randcolor?n=1");
const json = await res.json();
console.log(json);
Python
import requests

r = requests.get("https://itapi.top/api/randcolor?n=1", timeout=10)
print(r.json())
返回接口列表