Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PUTとPOSTどっち使う?
Search
Hank Ehly
June 23, 2022
Technology
0
1k
PUTとPOSTどっち使う?
https://qiita.com/hankehly/items/ed7e699ebe89f14b2ff7
Hank Ehly
June 23, 2022
Tweet
Share
More Decks by Hank Ehly
See All by Hank Ehly
Fivetranでデータ移動を自動化する
hankehly
0
580
Celeryの紹介と本番運用のTips
hankehly
0
830
ChatGPTを活用した 便利ツールの紹介
hankehly
1
1.3k
Efficient Energy Analytics with Airflow, Spark, and MLFlow
hankehly
0
320
Deferrable Operators入門
hankehly
0
630
【初心者/ハンズオン】Dockerコンテナの基礎知識
hankehly
0
510
Compositeパターン: オブジェクトの階層関係をエレガントに表現する方法
hankehly
0
310
10/29 Airflowの基礎を学ぶハンズオンワークショップ
hankehly
0
250
システム/データ品質保証のための Airflow 活用法
hankehly
0
590
Other Decks in Technology
See All in Technology
動画データのポテンシャルを引き出す! Databricks と AI活用への奮闘記(現在進行形)
databricksjapan
0
140
組織観点からIAM Identity CenterとIAMの設計を考える
nrinetcom
PRO
1
160
Modern_Data_Stack最新動向クイズ_買収_AI_激動の2025年_.pdf
sagara
0
190
GA technologiesでのAI-Readyの取り組み@DataOps Night
yuto16
0
260
PythonとLLMで挑む、 4コマ漫画の構造化データ化
esuji5
1
130
OCI Network Firewall 概要
oracle4engineer
PRO
1
7.8k
リーダーになったら未来を語れるようになろう/Speak the Future
sanogemaru
0
270
後進育成のしくじり〜任せるスキルとリーダーシップの両立〜
matsu0228
6
2k
FastAPIの魔法をgRPC/Connect RPCへ
monotaro
PRO
1
700
ユニットテストに対する考え方の変遷 / Everyone should watch his live coding
mdstoy
0
120
タスクって今どうなってるの?3.14の新機能 asyncio ps と pstree でasyncioのデバッグを (PyCon JP 2025)
jrfk
1
250
pprof vs runtime/trace (FlightRecorder)
task4233
0
150
Featured
See All Featured
Fireside Chat
paigeccino
40
3.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How to Ace a Technical Interview
jacobian
280
23k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
54
3k
The Cult of Friendly URLs
andyhume
79
6.6k
We Have a Design System, Now What?
morganepeng
53
7.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
570
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Music & Morning Musume
bryan
46
6.8k
Building Applications with DynamoDB
mza
96
6.6k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Transcript
PUTとPOSTどっち使う? qiita.com/hankehly > PUTとPOSTどっち使う?
自己紹介 • Hank Ehly (ハンク イーリー) • ENECHANGE株式会社 • qiita.com/hankehly
• connpass.com/user/hankehly • github.com/hankehly • speakerdeck.com/hankehly qiita.com/hankehly > PUTとPOSTどっち使う?
アジェンダ 1. PUTとPOSTの違い 2. POST 3. PUT qiita.com/hankehly > PUTとPOSTどっち使う?
百億%忘れてい るぜ
1 0 意識している あまり意識しない チャットに投稿してください Web APIを開発する上で PUTとPOSTの違いを…
PUTとPOSTの違い qiita.com/hankehly > PUTとPOSTどっち使う?
• リクエストに同封されているデータの意図 The fundamental difference between the POST and PUT
methods is highlighted by the different intent for the enclosed representation (RFC7231) • 使い分けることで、表現力の高い、理解しやすい Web API が作れる PUTとPOSTの違い qiita.com/hankehly > PUTとPOSTどっち使う?
PUTとPOSTの違い リソース 新規作成 バッチ処理開始 データ削除 POST PUT リソース 置き換え ファイル
アップロード qiita.com/hankehly > PUTとPOSTどっち使う?
POST
POST • 受け取ったデータで何してもおかしくない • 汎用的 リクエスト レスポンス DBレコードを INSERT する
201 (Created) ファイルを削除する 204 (No Content) 非同期処理を開始する 202 (Accepted) キャッシュされたリソースにリダイレクトする 303 (See Other) qiita.com/hankehly > PUTとPOSTどっち使う? • 一般的に冪等性がないため、キャッシュの対象にならない
POST /articles HTTP/1.1 { "name": "foo", "author": "tanaka", "content": "hello
world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 POST • リソースの新規作成に使うことが多い qiita.com/hankehly > PUTとPOSTどっち使う?
POST • リソースの新規作成に使うことが多い POST /articles HTTP/1.1 { "name": "foo", "author":
"tanaka", "content": "hello world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 qiita.com/hankehly > PUTとPOSTどっち使う?
POST • リソースの新規作成に使うことが多い POST /articles HTTP/1.1 { "name": "foo", "author":
"tanaka", "content": "hello world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 qiita.com/hankehly > PUTとPOSTどっち使う?
PUT
PUT • 対象リソースの置き換え(丸ごと) • どのリソースを置き換えるか知っている必要がある ◦ PUT /articles/12 • 冪等性
qiita.com/hankehly > PUTとPOSTどっち使う?
PUT INSERT INTO articles (id, name, author) VALUES (12, "foo",
"tanaka") ON CONFLICT (id) DO UPDATE SET name = "foo", author = "tanaka" PUTリクエストをSQLに例えたら qiita.com/hankehly > PUTとPOSTどっち使う?
PUT INSERT INTO articles (id, name, author) VALUES (12, "foo",
"tanaka") ON CONFLICT (id) DO UPDATE SET name = "foo", author = "tanaka" PUT /articles/12 HTTP/1.1 { "name": "foo", "author": "tanaka" } PUTリクエストをSQLに例えたら qiita.com/hankehly > PUTとPOSTどっち使う?
• PUTとPOSTの違いはリクエストデータ意図です • POSTは、1つの決まった使い方がなく、汎用的に活用できる ◦ 何かを「新規作成」するためによく使われる • PUTは、リソースの状態を丸ごと置き換える • 違いを意識することで、より表現力の高い
API 開発ができる まとめ qiita.com/hankehly > PUTとPOSTどっち使う? POST /articles/12 意図が曖昧(何するの?) PUT /articles/12 意図が明確になる
ご清聴ありがとうございます qiita.com/hankehly > PUTとPOSTどっち使う?