In this blog we are going to learn about Query parameter in RAML(Restfull api modelling language).
A query parameter is used to query, filter, or sort data based on a particular condition. You can think of the query parameter as the WHERE clause used in SQL.
It is passed at the end of the URL, followed by ? and separated by &, if there is more than one query parameter. For example, we can use this to implement pagination and fetch a limited amount of songs per page that were released in a particular year.
So, here, year and limit are the query parameters: /videos?year=<year>&limit=<pageLimit>.
This is what an actual request would look like: http://<host>/songs?year=2020&limit=20:
/videos:
get:
queryParameters:
limit:
required: true
type: integer
description: Enter the number of videos to be
displayed per page
year:
required: true
type: date-only
description: Enter the year for which you want the
video
displayName: Get all video
responses:
200:
body:
application/json:
example: {
"1": "Chalo chle", "2": "See You Again (feat. Charlie
Puth) Wiz Khalifa",
"3": "Maan Mere jaan",
"4": "King- Tu Aake dekhle"
}
You can add more parameters, such as required, type, display name, and description, to further describe your query parameter.
Now that we have learned about the URI and query parameters, let’s progress with our API design.
Getting back to our API design, we’ve added a new endpoint, /videos/{artistCode}, with the POST method. This is responsible for creating a new record in the backend system.
Comments
Post a Comment
Please Write your comment here.