REST API URL Template Design

I am currently developing a REST API.

I am developing an API that returns products related to a user, and an API that returns products related to a product.

I cannot be sure how to configure the url correctly.

What I find controversial is that in the case of a URL returning a list of products through the product, these products are re-listed.

Please tell me a good URL pattern.

I am considering the following options.

1.

/domain/v1/relatedProducts/users/{userId}

/domain/v1/relatedProducts/products/{productId}

2.

/domain/v1/user/{userId}/relatedProducts

/domain/v1/products/{productId}/relatedProducts

3. Please provide other URL patterns.

+4
source share
1 answer

, , .

/domain/v1/users/{userId}/products

, users not user products not relatedProducts

/domain/v1/users/{userId}/products/{productId}

: v1, , .

URL

  • ,

restapitutorial

+6

Source: https://habr.com/ru/post/1678712/


All Articles