Most modern web applications exchange data as JSON, and many talk to each other through APIs. Learning how requests and JSON work is one of the first steps toward a full stack role.
What JSON looks like
JSON is text that holds data as keys and values, such as {“name”: “Asha”, “marks”: 82}. Python reads it into a dictionary, and turns a dictionary back into JSON.
What an API does
An API is a set of addresses your program can send requests to. A GET request asks for data, a POST request sends new data, and the response usually comes back as JSON.
Try it
- Use Python’s requests library to call a public test API.
- Print the JSON response, then read one value from it.
- Save the response to a file and open it again.
Common mistakes
- Forgetting that the response is text until it is parsed.
- Missing a key that is not always present.
- Ignoring error codes such as 404 or 500.
Next step: see our Python Full Stack course at ScholarLogic, or book a free demo class. A counsellor will share the fee and the next batch dates.
