Parameters are empty places in memory to store variables or arguments. When building web applications, parameters are a fundamental part of the API design and function. For example, when designing your e-commerce shop, you know you'll need an `itemCost` parameter, a `shippingCost` parameter, and a `location` parameter to calculate the `salesTax` parameter. Any resource that is potentially variable requires a parameter.
According to the [Open API 3 specification](https://swagger.io/specification/), to describe a parameter, you specify its name, location, data type (defined by either schema or content), and other attributes, such as description or required. Here is an example of a path parameter:
There are multiple types of parameters:
Parameters house variables, so think of building parameters into your API as similar to declaring a function in C, then passing values to that function. Remember, there are different kinds of parameters for different uses, and all have their own definitions. Let's try a quick example below.
Let's say we want a list of random words. We can call the Random Words API in our terminal via cURL using `curl https://random-word-api.herokuapp.com/word?number=10` to get a list of ten random words. `/word` is a path parameter, which tells us where the information can be found. The `?` tells us where the query parameter begins. The number `10` is a variable, housed in the query parameter `number=`. You can change this number to list as many words as you want, even using `/all` to list all the random words the API contains. (If you're wondering, that list is 2115215 words long!) Another query parameter, `/?swear=0`, turns off swear words, in case you're using the Random Words API to teach young people computer science.
Parameters are a fundamental part of computer science, and understanding how users interact with your system will make you a better programmer and a better system designer.