<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 APIs
There are a few cases when a data set isn't a good enough solution.
An Application Program Interface API is an alternative, it allows you to dinamically query andretrive data
Step1:  Status Codes
200 -- everything went okay, and the result has been returned (if any)
301 -- the server is redirecting you to a different endpoint. This can happen when a company switches domain names, or an endpoint name is changed.
401 -- the server thinks you're not authenticated. This happens when you don't send the right credentials to access an API (we'll talk about this in a later mission).
400 -- the server thinks you made a bad request. This can happen when you don't send along the right data, among other things.
403 -- the resource you're trying to access is forbidden -- you don't have the right permissions to see it.
404 -- the resource you tried to access wasn't found on the server.
Step2:  Query Parameters
A 400 status code indicates a bad request, in this case it means that we need to add some parameters to the request.
<ASSISTANT_TASK:>
Python Code:
import csv
import requests
Explanation: APIs
There are a few cases when a data set isn't a good enough solution.
An Application Program Interface API is an alternative, it allows you to dinamically query andretrive data
End of explanation
response = requests.get("http://api.open-notify.org/iss-now.json")
response.status_code
Explanation: Status Codes
200 -- everything went okay, and the result has been returned (if any)
301 -- the server is redirecting you to a different endpoint. This can happen when a company switches domain names, or an endpoint name is changed.
401 -- the server thinks you're not authenticated. This happens when you don't send the right credentials to access an API (we'll talk about this in a later mission).
400 -- the server thinks you made a bad request. This can happen when you don't send along the right data, among other things.
403 -- the resource you're trying to access is forbidden -- you don't have the right permissions to see it.
404 -- the resource you tried to access wasn't found on the server.
End of explanation
# Set up the parameters we want to pass to the API.
# This is the latitude and longitude of New York City.
parameters = {"lat": 40.71, "lon": -74}
# Make a get request with the parameters.
response = requests.get("http://api.open-notify.org/iss-pass.json", params=parameters)
# Print the content of the response (the data the server returned)
print(response.content)
# This gets the same data as the command above
response = requests.get("http://api.open-notify.org/iss-pass.json?lat=40.71&lon=-74")
print(response.content)
Explanation: Query Parameters
A 400 status code indicates a bad request, in this case it means that we need to add some parameters to the request.
End of explanation
<END_TASK>