Python으로 배우는 API 입문
Chris Ramakers
Engineering Manager


1XX: 정보 응답2XX: 성공 응답3XX: 리다이렉션 메시지4XX: 클라이언트 오류 응답5XX: 서버 오류 응답200: OK404: Not Found500: Internal Server Error
key1: Value 1
key2: Value 2

accept: application/json 헤더를 추가합니다content-type: application/json 헤더로 응답합니다# Adding headers to a request
response = requests.get(
'https://api.datacamp.com',
headers={'accept':'application/json'}
)
# Reading response headers
response.headers['content-type']
'application/json'
response.headers.get('content-type')
'application/json'
# Accessing the status code response = requests.get('https://api.datacamp.com/users/12')response.status_code == 200
True
# Looking up status codes using requests.codes response = requests.get('https://api.datacamp.com/this/is/the/wrong/path')response.status_code == requests.codes.not_found
True
Python으로 배우는 API 입문