Is it ok use of query paramters for routing.

Hello everyone.

I'm in the process of creating proxies for a back-end server. And I'm trying to avoid complex pathing And I have three questions:

Let's suppose that the api has three entities: University, students and teachers. In students there are services for junior students only and services for senior students only and common services between the two.

  • Is it ok to use query parameters to route to a certain back-end service? Or should services be called using a path such as /seniorstudent. for example:
    • proxy side /students?studentType="seniorstudent" => in backend side /students/seniorstudents
  • Is it ok for the route to a backend service be different that the route of apigee. for example:
    • Apigee proxy end point is /university-students/avg-grades.
    • Backend service is /students/averageGrades.
  • How would you devid if it should be, the services of senoir students, junior students and common services

I'm trying to follow RFC3986 design and this best practices:

https://blog.restcase.com/5-basic-rest-api-design-guidelines/

Thank you very much.

Solved Solved
0 2 385
1 ACCEPTED SOLUTION

Is it ok to use query parameters to route to a certain back-end service?

>>>> There is no rule saying it's not OK to use query parameters. It really is up to you.

But, if you go by the book (read:REST best practices) then using query parameter in your case is not recommended. Instead, use different end points:

/students/<< common services
/students/seniorstudents/<< services only for seniors
/students/juniorstudents/<< services only for juniors

Is it ok for the route to a backend service be different that the route of Apigee.

>>>> Yes.

If you want to go down the query parameters route, or to rewrite the URL to target endpoint, in article [1], Siddharth provided a pretty neat sample code to achieve what you want.

[1] https://community.apigee.com/questions/59426/proxy-with-query-parameter-calling-target-with-pat.html

View solution in original post

2 REPLIES 2

Is it ok to use query parameters to route to a certain back-end service?

>>>> There is no rule saying it's not OK to use query parameters. It really is up to you.

But, if you go by the book (read:REST best practices) then using query parameter in your case is not recommended. Instead, use different end points:

/students/<< common services
/students/seniorstudents/<< services only for seniors
/students/juniorstudents/<< services only for juniors

Is it ok for the route to a backend service be different that the route of Apigee.

>>>> Yes.

If you want to go down the query parameters route, or to rewrite the URL to target endpoint, in article [1], Siddharth provided a pretty neat sample code to achieve what you want.

[1] https://community.apigee.com/questions/59426/proxy-with-query-parameter-calling-target-with-pat.html

Thanks a lot Brendan.