CS Dude
CS Dude

Reputation: 451

Naming convention for RESTful state specific endpoint

I have the following situation.

Headless CMS with CRUD endpoints using /posts/ which restrict access to an authenticated Users posts. i.e. GET to /posts returns all of the currently authenticated Users Posts.

I would like an endpoint which only returns posts which are 'publish' i.e. their publish_at date is less than the current time.

I was using /posts/published though I believe this to not be good practice.

Essentially, I wish a public endpoint to only provide resource of a specific state. Or is this goal in itself inherently the issue?

Upvotes: 1

Views: 189

Answers (1)

Evert
Evert

Reputation: 99533

What you're doing is perfectly fine. All of these are valid ways to handle this:

GET /posts/published
GET /posts/bystate/published
GET /posts?state=published
GET /published-posts

Upvotes: 1

Related Questions