liveBook · Manning

HTTP GET

As explained in Build Python Web Apps with Streamlit

A GET request is an HTTP request that retrieves a resource or result, with request parameters commonly encoded in the URL.

An HTTP GET request asks a web server or API for a resource or result. A browser uses GET to retrieve a web page, while an application can use it to request data. The request usually identifies a URL and may include key-value parameters in the URL. section 5.3.1

https://<base address>/<endpoint>

A common API URL combines a base address with an endpoint. section 5.3.1

Query parameters follow a question mark and use ampersands to separate multiple values. For example, a weather request can pass a date to a forecast endpoint. The server returns a response, often JSON, which code can parse into usable data. section 5.3.1

Requesting movie information with Python

The requests library sends a GET request to TMDB with an API key and a movie search term. Calling response.json() produces a dictionary whose results list contains movie records such as titles, identifiers, overviews, release dates, and ratings. section 11.1.1

>>> import requests
>>> params = {'api_key': 'Replace with your API key', 'query': 'ferris bueller'}
>>> response = requests.get('https://api.themoviedb.org/3/search/movie', params=params)
>>> response.json()

This minimal Python request supplies query parameters separately from the URL and parses the returned JSON. section 11.1.1

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains URLs, parameters, headers, bodies, responses, and JSON parsing, but does not detail HTTP implementation internals.
Examples
Uses a dated weather forecast URL and a Python TMDB search for Ferris Bueller's Day Off.
What it assumes
Assumes basic URLs and Python, while introducing HTTP request parts, API endpoints, query parameters, and JSON responses.
What you can do after
Apply it via Python requests to query an API, pass parameters, provide an API key, and parse JSON results.
How it connects
Connects GET requests with HTTP, APIs, URL parameters, HTTP headers, POST requests, JSON, and Python requests.

Also explained in

Compare how 14 books explain HTTP GET →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.