API 문서 읽기
어떤 API 문서 항목이든 실행 가능한 curl 명령으로 변환해요
⏱ 예상 ~7분
01 · 읽기
기술은 API 를 외우는 게 아니에요. 어떤 API 문서든 읽고 2 분 안에 실행 가능한 요청으로 변환하는 거예요.
모든 API 에 문서가 있어요. 형식은 다르지만 구조는 일관돼요: - Method + path — 어떤 요청을 보낼지 - Path parameter — URL 경로에 내장된 값 - 쿼리 파라미터 — 선택적 필터와 옵션 - 요청 본문 — POST/PUT 으로 보낼 JSON - 응답 — 받을 내용
핵심 정리
- {owner} 같은 path parameter 는 URL 경로에 직접 대입돼요
- 쿼리 파라미터는 ? 뒤에 와요, required 표시가 없으면 선택적이에요
- POST/PUT 요청 본문 필드는 -d '{...}' 로 보내요
- 문서의 'Authentication' (인증) 섹션을 항상 먼저 봐요
02 · 코드 예제
실제 GitHub API 문서 항목을 함께 읽어봐요.
API 문서 항목
GET /repos/{owner}/{repo}/issues
Path parameters:
owner (string, required) — account owner of the repository
repo (string, required) — name of the repository
Query parameters:
state (string) — "open", "closed", or "all" — default: "open"
labels (string) — comma-separated label names
per_page (integer) — results per page, max 100, default 30
page (integer) — page number of results
Response: Array of issue objects
curl 명령으로 변환
# Get all CLOSED issues for facebook/react, 10 per page
curl "https://api.github.com/repos/facebook/react/issues?state=closed&per_page=10"
변환 과정: 1. Method = GET → -X 플래그 불필요 2. Base URL = https://api.github.com 3. Path = /repos/{owner}/{repo}/issues → {owner} 를 facebook 으로, {repo} 를 react 로 바꿔요 4. 쿼리 파라미터 = ?state=closed&per_page=10 5. 공개 repo 는 인증 불필요
03 · 실기 실습
직접 해봐요. 이 명령을 실행해서 facebook/react 의 닫힌 issue 를 가져와요.
curl "https://api.github.com/repos/facebook/react/issues?state=closed&per_page=5"
04 · 빈칸 채우기
API 문서에 GET /repos/{owner}/{repo}/commits 라고 돼 있어요. torvalds/linux repo 의 commit 을 가져오려면 URL path 는: /repos/___/linux/commits
05 · 실기 실습
이제 전체를 합쳐봐요. 이 문서 항목을 완전한 curl 명령으로 변환해요: GET /repos/{owner}/{repo}/commits Query: author (GitHub 사용자명), per_page (최대 100) 과제: torvalds/linux 의 최근 5 개 commit 을 가져와요, 작성자 제한 없이요.
curl "https://api.github.com/repos/torvalds/linux/commits?per_page=5"
06 · 퀴즈
API 문서: GET /users/{userId}/orders?status=pending&limit=50. 사용자 ID 42 의 pending 상태 주문을 10 개로 제한해서 가져오려고 해요. 정확한 path 는?
- /users?userId=42/orders?status=pending&limit=10
- /users/{42}/orders?status=pending&limit=10
- /users/42/orders?status=pending&limit=10
- /users/42/orders&status=pending&limit=10
07 · 빈칸 채우기
API 문서가 GET /repos/{owner}/{repo}/commits 라고 할 때, {owner} 같은 중괄호 부분을 _____ parameter 라고 해요.
⚠ 전체 인터랙티브 경험에는 JavaScript가 필요해요. JavaScript를 켜고 새로 고침해 주세요.
※ 이 사이트는 독립 운영되는 교육 프로젝트로, Anthropic의 공식 제품이 아니에요. Claude™ 는 Anthropic, PBC 의 상표예요.