HomeContact
Concepts
Query parameters in a API call.
Karthikeya
February 27, 2021
1 min

WHAT ARE QUERY PARAMETERS

You must have seen filter results feature in e-commerce platform like amazon. We can filter through multiple different parameters like price, ratings etc to get just the products we are interested in.

Query parameters are very similar to the filter results feature that we see so regularly. Extending the same analogy, let us say there is an API which gives search results for a product like camera. Now, if have to filter the search results, it is generally considered good design to use query parameters.

HOW TO PASS QUERY PARAMETERS

Let us now try to understand how query parameters are passed to an API by taking the example of searching for a camera at fictional online store amazin.

If we are searching for just camera, the API call would look something like this

    https://amazin.com/search/camera

The search result will contain all cameras in the store.

Now, we are interested in cameras which are of a particular brand called nakon. The Api call would look something like this

    https://amazin.com/search/camera?brand=nakon

Notice that we start query parameters with ? mark followed by query parameter name and query value.

We want to further refine our search and see only cameras with review rating greater than 3. The Api call to achieve this would look something like this.

    https://amazin.com/search/camera?brand=nakon&minRating=3

Notice that the second and subsequent query parameters are using &. ? is used only at the beginning of the query parameters.

Read here, to understand how to pass query parameter in python.


Related Posts

Understanding Cache
April 06, 2021
1 min
© 2021, All Rights Reserved.

Quick Links

About UsContact UsSite Map

Social Media