liveBook · Manning

Parameter

As explained in Build Python Web Apps with Streamlit

A query parameter is a named key-value item in a URL query string that conveys request information or application state.

A query parameter is a named key-value item in the query string, the part of a URL after ?. Parameters are separated by ampersands and carry request information or application state. In Streamlit, st.query_params provides a dictionary-like way to read and update them. section 7.6.1

A query string

In https://duckduckgo.com/?t=h_&q=streamlit&ia=web, the query parameters are t=h_, q=streamlit, and ia=web. A dashboard might instead encode selections such as start_date, end_date, and product_name. section 7.6.1

Use query parameters to make an app state visible, shareable, and restorable:

  • Read a value with st.query_params.get(key, None), or assign a value such as st.query_params["pie_chart_dimension"] = "Gender". section 7.6.1
  • Populate widget defaults from URL values when the app first loads, then update the URL whenever users change widget selections. section 7.6.1 section 7.6.3
  • Prefix widget keys with w: so only selected widget state enters the URL, while other session-state values remain internal. section 7.6.3
Figure 7.15 Approach to implementing deeplinking

Follow the deeplinking flow from URL values to widget defaults and back to updated URL state. section 7.6.1

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines URL structure and implements reading, writing, initialization, filtering, serialization, and type conversion.
Examples
Uses search URLs, dashboard date ranges, product filters, chart dimensions, and serialized lists and dates.
What it assumes
Assumes basic URL and dictionary familiarity while explaining query strings, key-value pairs, and widget-state synchronization.
What you can do after
Build it from scratch with st.query_params to create shareable Streamlit dashboard links that restore widget selections.
How it connects
Connects URL query strings with Streamlit, session state, widgets, and deeplinking.

Also explained in

Compare how 31 books explain parameter →

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.