Menu
Coddy logo textTech

requests Method to Retrieve

Coddy의 Python으로 배우는 API 코스 레슨 — 10개 중 5번째.

API에서 정보를 검색하려면 .get()이라는 메서드를 사용해야 합니다.

get() 메서드는 URLAPI 키를 매개변수로 받습니다.

참고: 때로는 API 키가 필요하지 않을 수도 있습니다. 이는 API 서버에 따라 다릅니다.

그래서 코드는 다음과 같습니다:

import requests

response = requests.get("https://www.API_URL.com", "API_KEY_IF_NECESSARY")
print(response)

여기서는 응답에 더 쉽게 접근할 수 있도록 메서드를 response 변수에 저장하고 있습니다.

challenge icon

챌린지

쉬움

"https://reqres.in"으로 get 요청을 보내고 이를 response 변수에 저장하세요.

직접 해보기

import requests
# Write code here

# Don't change below this line
print(response.status_code)
print(response.url)

Python으로 배우는 API의 모든 레슨