Skip to content

Query Strings

A query string is the part of the URL that comes after a ? character, it is usually formatted as key=value&otherkey=othervalue.

Crow supports query strings through crow::request::url_params. The object is of type crow::query_string and can has the following functions:


Returns the value (as char*) based on the given key (or name). Returns nullptr if the key is not found.



Works the same as get, but removes the returned value.


crow::request::url_params is a const value, therefore for pop (also pop_list and pop_dict) to work, a copy needs to be made.


A URL can be[]=value1&key[]=value2&key[]=value3. Using get_list("key") on such a URL returns an std::vector<std::string> containing [value1, value2, value3].

get_list("key", false) can be used to parse



Works the same as get_list but removes all instances of values having the given key (use_brackets is also available here).


Returns an std::unordered_map<std::string, std::string> from a query string such as ?key[sub_key1]=value1&key[sub_key2]=value2&key[sub_key3]=value3.
The key in the map is what's in the brackets (sub_key1 for example), and the value being what's after the = sign (value1). The name passed to the function is not part of the returned value.



Works the same as get_dict but removing the values from the query string.


if your query string contains both a list and dictionary with the same key, it is best to use pop_list before either get_dict or pop_dict, since a map cannot contain more than one value per key, each item in the list will override the previous and only the last will remain with an empty key.

For more information take a look here.