Raghavan
Raghavan

Reputation: 923

Name for a endpoint in a RESTfull way

I am doing a application for a supermarket ,I am designing a endpoint that takes a articleId(an Item id) and return all similar articles and a representative article(has the logic of finding the earliest article within similar article) for that article Id.

I already have a resource end point for articles as /article/{articleid}

What is the best way to name for similars ? (currently it is /article/similars.json&articleid=####)

Upvotes: 0

Views: 40

Answers (1)

Eric Stein
Eric Stein

Reputation: 13672

Make it a query parameter off the collection:

GET /articles?similarTo={articleId}

I'd also suggest that you use a plural (articles) instead of a singular (article) for your collection name. If you want back JSON, use the Accept header to indicate that, or, if you must, stick it on /articles:

GET /articles.json?simiarTo={articleId}

Upvotes: 1

Related Questions