C.W.K.
Stream
Lesson 04 of 13 · published

curl 고급 — API & 인증

~15 min · curl, post, json, api, auth

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

커맨드라인에서 API 와 대화

curl 이 코드 안 쓰고 REST/JSON API 테스트 표준. 모든 메서드, 모든 header, 모든 파일 업로드 — 한 도구, 한 머릿속 모델. 끊임없이 사용.

흔한 API 패턴

POST JSON, Authorization header 첨부, PUT/DELETE 의미 따르기, multipart form 으로 파일 업로드. Flag 가 깔끔히 합성 — -X METHOD HTTP 동사, -H header 추가, -d body 첨부, -F form/multipart 필드 업로드.

Code

API 요청 패턴·bash
# Bearer-auth GET with custom Accept
curl -H 'Authorization: Bearer ${TOKEN}' \
     -H 'Accept: application/json' \
     https://api.example.com/users

# POST JSON
curl -X POST \
     -H 'Content-Type: application/json' \
     -d '{"name":"you_username","role":"admin"}' \
     https://api.example.com/users

# POST form-encoded
curl -X POST \
     -d 'username=you_username&password=secret' \
     https://example.com/login

# PUT update
curl -X PUT -H 'Content-Type: application/json' \
     -d '{"role":"superadmin"}' \
     https://api.example.com/users/1

# DELETE
curl -X DELETE -H 'Authorization: Bearer ${TOKEN}' \
     https://api.example.com/users/1

# Multipart file upload
curl -F 'file=@/path/to/document.pdf' \
     https://api.example.com/upload

# Skip TLS verification (TESTING ONLY — never in production)
curl -k https://self-signed.example.com

External links

Exercise

Public API 골라 (httpbin.org 테스트 좋음). GET, /post 에 JSON body POST, /put 에 PUT 시도. 각 응답 읽어. 파일에 body 저장 (-o), --data-binary @file 로 다시 POST. 끝나면 문서 복붙 없이 터미널에서 어떤 HTTP API 든 대화 가능해야.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.