I want to be able to specify the size of the product image in ONE request, I have different ideas about this, here they are:
mysuperstore.com/api/categories/40/products/53?width=100&height=100
I think this is bad practice, because it is not clear what the width and height mean, maybe there is a physical size of the product.
Another variant:
mysuperstore.com/api/categories/40/products/53/image?width=100&height=100
This looks good, but in this case I need to make two requests, it looks like this is another resource identifier (image).
First product request
mysuperstore.com/api/categories/40/products/53/
Second for image URL
mysuperstore.com/api/categories/40/products/53/image?width=100&height=100
Yes, I do not need to return the raw image (data), but just the URL.
I am creating an API on a PHP server using the Slim Framework. I found an example of such an API request with additional parameters
$app->get('/archive(/:year(/:month(/:day)))', function ($year = 2010, $month = 12, $day = 05) use ($app) { echo sprintf('%s-%s-%s', $year, $month, $day); print_r($app->request()->get()); });
That way, the previous URL will match this example, and I can pass all the necessary parameters in a single request.
So my questions are: if this is good practice, perhaps this URL might be confused for those not familiar with the API.
mysuperstore.com/api/categories/40/products/53/image?width=100&height=100
Therefore, I ask someone more experienced in this than me, my goal is to create an API that can be understood clearly without reading tons of API documentation. And my API should follow all best practices.
That is why I ask this question, I hope someone can help me with this.