LoginSignup
2
3

More than 1 year has passed since last update.

[メモ]twitch api 使い始めまで

Last updated at Posted at 2021-07-04

#twitch API利用開始の流れ

公式ドキュメント

これが最初で https://dev.twitch.tv/docs/api
こっちが認証周り https://dev.twitch.tv/docs/authentication

手順

1.https://dev.twitch.tv/console/apps でクライアントIDとシークレットを取得(※1)
2.アクセストークン取得

curl  -X POST 'https://id.twitch.tv/oauth2/token
?client_id=【クライアントID】
&client_secret=【シークレット】
&grant_type=client_credentials (これは固定)
&scope=user:edit' (https://dev.twitch.tv/docs/authentication/#scopes ここ参照)

{"access_token":"アクセストークン","expires_in":XXXXXX,"scope":["user:edit"],"token_type":"bearer"}

3.お試しリクエスト
Fortniteの配信者情報を取得

% curl -H 'Client-ID: 【クライアントID】' \
-H 'Authorization: Bearer 【アクセストークン】' \
-X GET 'https://api.twitch.tv/helix/streams?game_id=33214'

{"data":・・・なんかめっちゃ長いのズラズラ}%
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3