vendredi 14 octobre 2022

REST Api Routes format with filter

I am relatively new to the environment of professional use of API Routes, so a basic question.

Im working with VueJS asFrontend and node Express as Backend. How the GET Request against the api have to look like? I wonder how to deliver filter requests with a REST API?

Example:

GET https://example.com/api/v1/cities -> get all cities.

GET https://example.com/api/v1/cities?country={countrId} -> get all cities from this country with the id = {countrId}.

Question: Is this an API antipattern? If so, what would the route look like?

Note: A colleague told me it should look like this:

GET https://example.com/api/v1/cities?country.id={countrId}

Aucun commentaire:

Enregistrer un commentaire