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.

asked Aug 24, 2021 at 2:08

1 Answer 1

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.

answered Aug 25, 2021 at 10:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.