JSON - API Response
Lesson 3 of 10 in Coddy's API in Python course.
API Responses are often in the format called JSON.
JSON stands for JavaScript Object Notation. JSON is similar to Python's native dictionary data types.
Those API responses look like this:
{
"errors": [
{
"status": "422",
"source": {
"pointer": "/data/attributes/firstName"
},
"title": "Invalid Attribute",
"detail": "First name must contain at least two characters."
}
]
}You can manipulate JSON just like a dictionary in Python.
Challenge
EasyGiven the JSON Code below, try to print the "errors" key's value.
For this, you must have a better understanding of how dictionaries work.
This is covered in the dictionaries section of the Python Fundamentals course.
Try it yourself
json = {
"errors": [
{
"status": "422",
"source": {
"pointer": "/data/attributes/firstName"
},
"title": "Invalid Attribute",
"detail": "First name must contain at least two characters."
}
]
}
### Write Your Code Below This LineAll lessons in API in Python
3Weather Fetch API Program
API Connection to ServerGET Request to ServerDisplaying Appropriate Results