🔗 HTTPメソッドの意味
メソッド意味用途例
GETデータを取得記事一覧を取得する
POSTデータを作成新規ユーザーを登録する
PUTデータを更新(全体)ユーザー情報を全更新
PATCHデータを更新(一部)メールアドレスだけ変更
DELETEデータを削除記事を削除する
📊 よく使うHTTPステータスコード
コード意味
200 OK成功
201 Created作成成功
400 Bad Requestリクエストが不正
401 Unauthorized認証が必要
403 Forbiddenアクセス権限がない
404 Not Foundリソースが存在しない
500 Internal Server Errorサーバー内部エラー
🐍 PythonでAPIを叩く例
import requests

# GETリクエスト
response = requests.get("https://api.example.com/users")
print(response.status_code)  # 200
data = response.json()       # JSONをPythonの辞書に変換

# POSTリクエスト(認証付き)
headers = {"Authorization": "Bearer YOUR_API_KEY"}
payload = {"name": "たろう", "email": "taro@example.com"}
res = requests.post("https://api.example.com/users",
                    json=payload, headers=headers)
print(res.status_code)  # 201