The entire contents of my program:
import requests
# Make an API call and store the response.
url = 'https://api.github.com/search/repositories?=language:python&sort=stars'
# headers = {'Accept': 'application/vnd.github.v3+json'}
r = requests.get(url)
print(f"Status code: {r.status_code}")
# Store API response as a variable.
response_dict = r.json()
# Process results.
print(response_dict.keys())
Using python3 to run the program in terminal yields:
Status code: 422
dict_keys(['message', 'errors', 'documentation_url'])
The expected status code is 200. Can anyone tell me what I'm doing wrong, or if there is a good place to test this API call out?
What I have tried:
I've tried testing my API call at
Online API Testing Tool | Test Your API Online[
^]
and at
postman, where the response was:
"message": "Validation Failed",
"errors": [
{
"resource": "Search",
"field": "q",
"code": "missing"
}
],
"documentation_url": "https://docs.github.com/v3/search"
}
Not sure what I'm doing wrong, or really if I'm using the API testing tools correctly. Any help is appreciated, thank you!