0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

APIパラメーターを整理した

Posted at

普段何気なく使ってますが、改めて整理してみました、備忘録です。

パラメーターとは

処理結果に影響を与える外部から投入される変動要素のこと
数学の世界でも使われますが、プログラムの世界では引数(仮引数)のこと。

APIのリクエストパラメータ

API引数とも呼ばれる。
APIはアプリケーション同士が通信するためのインターフェースであり、リクエストパラメーターはその通信を具体的に指示する役割を果たします。

主に以下の3種類がある
・パスパラメーター
・クエリパラメーター
・ボディパラメーター(リクエストボディ)

パスパラメーター

パスパラメータは、URLパスの一部を利用するパラメータ
URLでリソースを特定するのに使われる。

https://hoge.com/api/employees/15

クエリパラメーター

クエリパラメータはURLの最後に「?」から始まる形式で付け加える。
クエリ文字列は、KEY=VALUE形式
複数のパラメータを記載したい場合には、&で区切る

https://hoge.com/api/employees?role=sales&gender=male

ボディパラメーター(リクエストボディ)

リクエストの本文に含まれるパラメーターで、POST、PUTなど大量のデータを送信する場合に使用されます。JSON形式で渡す。

例:POST /employees
{ "name": "Taro Yamada", "age": 30, "role": "engineer", "gender": "male" }
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?