Sodiaan
Sodiaan

Reputation: 341

Rest endpoints structure

Supposing I have requirements:

How should be endpoints REST API structure?

Upvotes: 1

Views: 303

Answers (1)

Alex Marculescu
Alex Marculescu

Reputation: 5770

Always ask yourself:

What are my Resources?

  • Register by email POST /api/registration
  • Register by social network POST /api/providerRegistration
  • Get some user profile GET /api/user?userId={userId}
  • List my friends GET /api/friends
  • List some user friends GET /api/friends?userId={userId}
  • Add product POST /api/product
  • Edit product PUT/PATCH /api/product/{productId}
  • Search Products GET /api/products?status={status}
  • List my products GET /api/products?userId={userId}

And so on - you get the gist of it. Note that the path (REST Resource) is a noun (product), not a verb (search).

Upvotes: 1

Related Questions