์ธ์ฆ
๋ชจ๋ API ์์ฒญ์๋ ์ธ์ฆ์ ์ํ Bearer ํ ํฐ (API ํค)์ด ํ์ํฉ๋๋ค.
API ํค ์์ฑ
- app.ironflock.com์์ IronFlock์ ๋ก๊ทธ์ธํฉ๋๋ค.
- User Settings์ผ๋ก ์ด๋ํฉ๋๋ค.
- API Keys ์น์ ์ผ๋ก ์ด๋ํฉ๋๋ค.
- Create API Key๋ฅผ ํด๋ฆญํฉ๋๋ค.
- ์์ฑ๋ ํค๋ฅผ ๋ณต์ฌํฉ๋๋ค โ ํ ๋ฒ๋ง ํ์๋ฉ๋๋ค.
API ํค ์ฌ์ฉ
๋ชจ๋ ์์ฒญ์ Authorization ํค๋์ ํค๋ฅผ ํฌํจํฉ๋๋ค:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.ironflock.com/v1/ironflock/devicesPython ์์
import requests
API_KEY = "your-api-key"
BASE_URL = "https://api.ironflock.com/v1/ironflock"
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.get(f"{BASE_URL}/devices", headers=headers)
devices = response.json()JavaScript ์์
const API_KEY = "your-api-key";
const BASE_URL = "https://api.ironflock.com/v1/ironflock";
const response = await fetch(`${BASE_URL}/devices`, {
headers: { Authorization: `Bearer ${API_KEY}` }
});
const devices = await response.json();์ค๋ฅ ์๋ต
| ์ํ ์ฝ๋ | ์๋ฏธ |
|---|---|
401 | API ํค๊ฐ ์๊ฑฐ๋ ์ ํจํ์ง ์์ |
403 | ์ด ์์ ์ ๋ํ ๊ถํ ๋ถ์กฑ |
404 | ๋ฆฌ์์ค๋ฅผ ์ฐพ์ ์ ์์ |
422 | ์ ํจ์ฑ ๊ฒ์ฌ ์ค๋ฅ (์์ฒญ ํ๋ผ๋ฏธํฐ ํ์ธ) |
500 | ๋ด๋ถ ์๋ฒ ์ค๋ฅ |
๋ชจ๋ ์ค๋ฅ ์๋ต์ JSON ๊ฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค:
{
"error": "์ค๋ฅ ์ค๋ช
"
}Last updated on