requests Method to Retrieve
Coddy'nin Python ile API kursunda ders 5 / 10.
Bir API'den bazı bilgileri almak istiyorsanız, .get() adında bir yöntem kullanmamız gerekir.
Bu get() yöntemi, URL ve API anahtarı parametrelerini alır.
Not: Bazen API Anahtarı gerekli olmayabilir. Bu, API Sunucusuna bağlıdır.
Yani, kod şu şekilde görünecektir:
import requests
response = requests.get("https://www.API_URL.com", "API_KEY_IF_NECESSARY")
print(response)Burada, yanıta erişmeyi kolaylaştırmak için yöntemi bir response değişkeninde saklıyoruz.
Görev
Kolay"https://reqres.in" adresine bir get isteği gönderin ve bunu bir response değişkenine kaydedin.
Kendin dene
import requests
# Write code here
# Don't change below this line
print(response.status_code)
print(response.url)Python ile API bölümündeki tüm dersler
2API in Python
requests Library for APIrequests Method to Retrieverequests Method to Send DataManipulating requests Response3Weather Fetch API Program
API Connection to ServerGET Request to ServerDisplaying Appropriate Results