サーバーからのレスポンスの内容を確認するのに使用されるツールとしてPostmanがあります。
Postmanのインストールや使用方法をご説明します。
目次
Postmanとは?
Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com/
公式ページに記載された内容の通り、APIの構築、使用するためのプラットフォームです。
API開発の全般にわたる作業を支援するツールであり、以下の主な機能を提供しています。
- APIリクエストの作成と送信
- リクエストのテストとデバッグ
- テストスイートの作成と実行
- APIドキュメントの作成と共有
- ワークスペースの共有とチームコラボレーション
Postmanのインストール
以下からはMacの画面での説明になります。
アカウント作成
HPにアクセスしSign Up for Freeを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.27.17-1-1024x552.png)
必要事項を入力し無料アカウントの作成を選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.27.37-1-1024x549.png)
アカウントが作成できたことが確認できます。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.28.15-1-1024x553.png)
デスクトップ版Postmanのインストール
Postmanはデスクトップ版もありますのでインストールします。
ダウンロードページにアクセスしPCのOSにあったインストーラをダウンロードしインストールします。
![](https://it-tech-hack.com/wp-content/uploads/cocoon-resources/blog-card-cache/04f6de390e784f0be408f538b4aa4f3e.jpeg)
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.28.58-1-1024x549.png)
インストールが完了しますと先ほど作成したアカウント情報が要求されるので入力します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.35.55-1-1024x671.png)
作成したアカウントを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.36.08-2-1024x549.png)
デスクトップ版のPostmanが起動します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-8.36.48-1-1024x671.png)
Postmanを使ったAPIの呼び出し方
今回はYoutube Data APIから動画のリストを取得します。
Youtube Data APIを利用するための準備
Youtube Data APIの有効化
Googleアカウントを使用してGoogle Cloud Platformにアクセスします。
※Googleアカウントが必要です。
プロジェクトを作成を選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.22.08-1024x517.png)
プロジェクト名に任意の名前を指定し、場所には組織なしを選択します。
作成ボタンを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.22.44-1024x514.png)
ENABLE APIS AND SERVICESを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.24.02-1024x512.png)
YouTube Data API v3を選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.25.25-1024x515.png)
有効にするボタンを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.26.17-1024x512.png)
有効化されたされたことが確認できます。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.28.20-1024x512.png)
APIキーの作成
認証情報タブを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.32.28-1024x515.png)
認証情報を作成のAPIキーを選択します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.33.06-1024x515.png)
APIキーが作成されます。
実際にAPIにアクセスする際にkey=API_KEYの形でクエリパラメータとして使用します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.33.36-1024x666.png)
APIキーが作成されていることが確認できます。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.35.26-1024x513.png)
作成したAPIキーを選択しAPI Keyの値をコピーします。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-20-20.47.15-1-1024x514.png)
PostmanからYoutube Data APIへのアクセス
デスクトップ版Postmanを起動します。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-9.43.47-1024x671.png)
Request URLにhttps://www.googleapis.com/youtube/v3/search を貼り付けます。
![](https://www.gstatic.com/devrel-devsite/prod/v5ba20c1e081870fd30b7c8ebfa8711369a575956c1f44323664285c05468c6a4/developers/images/opengraph/youtube-theme.png)
ParamsタブのQuery ParamsのKey, Valueに以下の組み合わせを入力します。
(Key, Value) = (key, 作成したAPIキーの値), (part, snippet), (q, 検索文字列)
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-9.46.15-1-1024x650.png)
SENDボタンを選択するとレスポンスが画面下部に表示されます。
![](https://it-tech-hack.com/wp-content/uploads/2024/02/スクリーンショット-2024-02-23-9.46.31-1024x650.png)
![](https://www10.a8.net/0.gif?a8mat=3Z2JSQ+AV5TZU+5GWC+5ZU29)
未経験からのエンジニア転職+キャリアアップなら【ラクスパートナーズ】
![](https://www16.a8.net/0.gif?a8mat=3Z2KL0+4LIJQ2+2JK4+3B3ZA9)
新卒でITエンジニアとして活躍するなら【レバテックルーキー】
![](https://www18.a8.net/0.gif?a8mat=3T01CK+1AFTYQ+529E+5ZMCH)