Noob Question: One API Endpoint or Multiple?
![Brandon Hassler](https://us.v-cdn.net/6037124/user_avatars/4585463.jpg)
Let's say I have a table called /products with 4,000 items. On the front of my site, all of the main searching & filtering will go directly through the /products API endpoint.
But let's say I have other uses of that table, such as:
- Finding the average price of products that meet certain criteria.
- Finding the top 5 products that meet a certain criteria.
- Etc.
Let's say 80% of the website activity is using the /products endpoint to search for products. When it comes to adding other uses of that table (that involve evaluating all of the products in the table based on a set of criteria) is there any wisdom in creating a separate API endpoint for those to "ease the pressure" of the main /products endpoint? Or is it best to use a single endpoint and, based on the inputs, the function stack uses IF/THEN statements to determine the response?
Does that question make sense?
Best Answer
-
Hi, @Brandon Hassler! I think in general we would recommend different endpoints. Building a "catch all" query with conditionals is a cool idea in theory, but could end up with a lot of unnecessary API compute used and execution time depending on the volume / complexity of the conditional logic.
Answers
-
Thanks Chris! Very good to know!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback