Answer the question
In order to leave comments, you need to log in
Which endpoint to choose for a singleton resource (RESTish API)?
A user has only one business card page, a page can have only one button.
Possible endpoint options for editing a page button:
1. /pages/{id}/buttons/{id} (I would not like to use just /buttons/{id} because there are several modules, in order to avoid conflicts, suddenly in other modules too there will be some buttons)
2. /page/button
3. for each module its own api uri in the format site.com/api/page/v1, and the endpoint for the button will then be /button
4. /pages/my/button
First option good with a margin for the future, in case the customer decides to add the ability to create multiple pages and add multiple buttons to the page, but at the moment it looks redundant and adds unnecessary hassle.
What would you choose?
Answer the question
In order to leave comments, you need to log in
Does the button work with user data? If yes, then:
POST '/api/v1/profile/'
body: {
name: 'UserName',
/* other data */
contactLink: 'mailto:[email protected]',
}
POST '/api/v1/pages/{page_id}/content/'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question