# Query strings

* A query string contains the value of the String data type entered by the user in a URL sent to the server.
* Each query string comprises a key name and a value joined together using an equals sign (=).
* There can be multiple query strings; two or more query strings are separated by ‘&.’
* The pattern of the query string is:\
  <https://BaseURL/dataapi/Group\\_Name/API\\_Name?querystring1=value1\\&querystring2=value2\\>
  \
  (See the green box in the image below)

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4qsinurl1.png>" %}

* The data values received in a request are retrieved through the Request variable. For example, to update the received value of the query string “Number1” into the variable “str,” select the source value as Variables>Request>querystrings>Number1.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4qs2example.png" alt=""><figcaption></figcaption></figure>

* Query strings are defined by:
  1. Query Name: A query string must have a unique query string name and conforms to the variable name rules. This name will be used when reading the query string value in Actions.
  2. URL Query Name: This field defines how the query string will be displayed in the URL. It can be the same as a query string name, or a different text can be assigned.
  3. Documentation Data Type: This field defines the data type in the query string. E.g., In an API created and configured for the calculation of values entered by a user, the data type for the query string will be an integer. This detail is displayed in the API documentation.
  4. Example for query string value: This field defines the sample value for this query string to be displayed in the documentation.
  5. Parameter Description: This field explains the purpose of the query string. This text is visible in the API documentation.
  6. Required: To define that the value for a query string must exist when the request is received, select the “Required” field.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4qs3labelledqs.png>" %}

If this value is missing, an error will be returned to the caller on calling the API. (In the image below, a value for the query string “Number2” is required.)

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_4/ch4qs4numberreq.png" alt=""><figcaption></figcaption></figure>
