API URI structure #1
mike-pisman
started this conversation in
Polls
Replies: 1 comment
-
The API will support multiple versions, the version Related Issues: unipoll/api#79, unipoll/api#80, unipoll/api#82 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which structure should be used for the API endpoints: hierarchical vs flat.
Both are commonly used. This is in regard to API endpoints and not the front-end client(a Website) URL structure, so SEO, search engine crawlers, etc are not considered. The main focus is to provide a better(more intuitive) structure for front-end developers.
The current layout can be found at https://unipoll-api.1cl.cc/docs
Hierarchical structure:
Tree like structure that defines resource path by their location.
GET /workspaces
return the list of all workspacesGET /workspaces/{id}
return the workspace with specified ID (including groups, members, polls, etc)GET /workspaces/{id}/members
return the list of members from the workspace with specified IDGET /workspaces/{id}/groups
return the list of groups from the workspace with specified IDGET /workspaces/{id}/groups/{id}
return the group (including members, policies, etc) with specified IDGET /workspaces/{id}/groups/{id}/members
return the list of members from the group with specified IDPros
Cons
Flat Structure:
GET /workspaces
return the list of all workspacesGET /workspaces/{id}
return the workspace with specified ID (including groups, members, polls, etc)GET /members?workspace={id}
return the list of members from the workspace with specified IDGET /groups?workspace={id}
return the list of groups from the workspace with specified IDGET /groups/{id}
return the group (including members, policies, etc) with specified IDGET /members?group={id}
return the list of members from the group with specified IDPros
Cons
Hybrid structure:
Current structure, which combines both options and is neither intuitive or correct use of URI.
GET /workspaces
- return the list of all workspacesGET /workspaces/{id}
return the workspace with specified ID (including groups, members, polls, etc)GET /workspaces/{id}/members
return the list of members from the workspace with specified IDGET /workspaces/{id}/groups
return the list of groups from the workspace with specified IDGET /groups/{id}
return the group (including members, policies, etc) with specified IDGET /groups/{id}/members
return the list of members from the group with specified IDFeel free to suggest other advantages/disadvantages of either method.
1 vote ·
Beta Was this translation helpful? Give feedback.
All reactions