开发文档

快速上手,轻松集成API接口

🚀 快速开始

使用 八楼易API(api.8l2.cn) API 只需3步:

1 注册账号
2 登录获取API密钥
3 携带apikey参数调用接口

🔑 API密钥

所有API接口都需要携带 apikey 参数:

https://api.8l2.cn/api/weather/?city=北京&apikey=你的密钥

⚠️ 请妥善保管您的API密钥,不要泄露

⚠️ 错误码说明

200请求成功
400参数错误
401API密钥无效
404接口不存在
500服务器错误

💻 代码示例

PHP

<?php
$url = 'https://api.8l2.cn/api/weather/?city=北京&apikey=你的密钥';
$result = file_get_contents($url);
$data = json_decode($result, true);
print_r($data);
?>

JavaScript

fetch('https://api.8l2.cn/api/weather/?city=北京&apikey=你的密钥')
  .then(res => res.json())
  .then(data => console.log(data));

Python

import requests
url = 'https://api.8l2.cn/api/weather/?city=北京&apikey=你的密钥'
response = requests.get(url)
data = response.json()
print(data)

❓ 常见问题

Q: 返回401错误?

A: 请检查apikey是否正确

Q: 如何获取API密钥?

A: 注册后登录用户中心查看

Q: 免费用户每天调用多少次?

A: 免费用户每天1000次