0

Suppose I have a server with the following two jobs:

  1. Handle a payment using Stripe
  2. Connect to a DB with a list of posts/products/items

What would be the best approach:
Have all the calls go to /api/ eg. /api/payment and /api/posts

Or since the payment is not as extensive and is a smaller function have it separate:
/payment and the posts goes to /api/posts and you can GET, POST on that

Just trying to understand the best practices, please let me know if I'm way off base.

1

In general, you could prefix everything with some prefix, such as /api

This makes sense for example when there are different kinds of APIs. if this is not intended, why should you choose such an approach?

We are in a similar discussion, we go for:

  • /portal
  • /mobile
  • /...

as acces paths for different accesses and devices. Then, under this, we have the resources used by the access paths.

As your request is not very detailed, I would rather go for

  • /posts

  • /payments

Keep in mind, a stateless design is very helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.