cURL
curl "https://api.ruseo.cn/api/storage_convert?from_unit=GB&to_unit=MiB&value=1"
存储单位互转,支持B/KB/MB/GB/TB/PB/EB及IEC二进制单位和比特单位。
https://api.ruseo.cn/api/storage_convert
接口调用前需要确认的核心配置。
/api/storage_convertstorage_convert必填参数必须传入,示例值可直接用于联调。
免费API不强制要求API Key,但如果您希望统计个人调用次数,请在请求时附加参数 key=您的API_KEY。
注册账号后即可获得API Key。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
否 | string | 可选参数:携带此参数可统计您的个人调用次数。请注册账号获取API Key。 | YOUR_API_KEY |
from_unit |
是 | string | 源单位,如 B/KB/MB/GB/TB/KiB/MiB/GiB/bit/Kbit/Mbit 等 | GB |
to_unit |
是 | string | 目标单位,同上 | MiB |
value |
是 | number | 待转换的数值 | 1 |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/storage_convert?from_unit=GB&to_unit=MiB&value=1
curl "https://api.ruseo.cn/api/storage_convert?from_unit=GB&to_unit=MiB&value=1"
$url = 'https://api.ruseo.cn/api/storage_convert?from_unit=GB&to_unit=MiB&value=1';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/storage_convert?from_unit=GB&to_unit=MiB&value=1')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "storage_convert",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
input.from_unit |
string | 源单位代码 | gb |
input.to_unit |
string | 目标单位代码 | mb |
input.value |
number | 输入数值 | 1 |
result.value |
number | 转换结果 | 1024 |
点击左侧“发送请求”查看结果...