Should I include the input query parameter in the response?
Let's say that I have an endpoint which returns people's names. I am allowing my client to filter the result by country.
I wonder, should I include the country property in the response or not, even though it matches what the client requested.
For example when the user sends the below request
/people?country=UK
should I return
[{"name":"tom"},{"name"="tim"}]
or
[{"name":"tom","country":"UK"},{"name":"tim","country":"UK"}]
as the response?
Depends on what data the client needs.
If you just want a way to tell the client what they requested, you could have some convention in your API that there's a top-level node that shows what the parameters in the request were that generated this reponse.
{"requestParams":"country=UK&city=London", data: [{"name":"tom", "street":"Wallaby"}, {"name":"tim", "street":"West"}]
But you definitely don't want to risk returning sensitive information by returning the request params.