SwitchBot API v1.1のリクエスト用curlを生成する
下記の入力欄に値を入力すると、動的にcurlのコードが生成されます。
GitHub SwitchBotAPI
デバイス一覧を取得する
curl --request GET 'https://api.switch-bot.com/v1.1/devices' \
--header 'Authorization: 認証用トークン' \
--header 't: UNIXタイム' \
--header 'sign: 署名' \
--header 'nonce: ランダム値' \
--header 'Content-Type: application/json; charset=utf8'
デバイスの状態を取得する
curl --request GET 'https://api.switch-bot.com/v1.1/devices/デバイスID/status' \
--header 'Authorization: 認証用トークン' \
--header 't: UNIXタイム' \
--header 'sign: 署名' \
--header 'nonce: ランダム値' \
--header 'Content-Type: application/json; charset=utf8'
コマンドを実行する
curl --request POST 'https://api.switch-bot.com/v1.1/devices/デバイスID/commands' \
--header 'Authorization: 認証用トークン' \
--header 't: UNIXタイム' \
--header 'sign: 署名' \
--header 'nonce: ランダム値' \
--header 'Content-Type: application/json; charset=utf8' \
--data-raw '{
"commandType": "command",
"command": "コマンド",
"parameter": "パラメータ"
}'
関連記事