Don't forget about filters and sorters for this one!
Specification (written by F.)
Prior experience
Note that we already have routes /api/quote/{id} and /api/quote/random. These remains the same.
Also there's a voting API: quote/{id}/upvote, quote/{id}/downvote; I'll discuss these below.
Proposals
1. URL parameters
I propose to adapt for API the same URL scheme we use for our main frontend pages with the addition of the limit parameter: ?limit=a&page=x&order=y&filter=z with all four parts being optional with sensible defaults (default limit matching the corresponding frontend parameter, pageSize = 50).
For reference:
- the possible values for
filter are none (the default; never exposed in a public URL but still valid), year, month, week, and day
- the possible values for
order are time (the default; never exposed yet) and rating
2. Count API
Add a new route /api/quote/count[filter] to get quote count information in the following format:
3. List API
Add a new route /api/quote/list[filter] to get a list of quotes in the same format our current API use.
4. CORS support
As we have plans to develop an isolated frontend for LogList, we'll need all the API routes to properly support CORS. So, there should be a configuration option to enable CORS with the admin-selected domain.
If that'll be easier to implement, enable CORS for the whole site, not just the new API.
5. Voting API
I suggest to finally implement #94 in relation to the voting API: move them to /api/quote/{id}/(up|down)vote, and thus make them a part of the public, supported external API.
Implementation
Don't forget about filters and sorters for this one!
Specification (written by F.)
Prior experience
Note that we already have routes
/api/quote/{id}and/api/quote/random. These remains the same.Also there's a voting API:
quote/{id}/upvote,quote/{id}/downvote; I'll discuss these below.Proposals
1. URL parameters
I propose to adapt for API the same URL scheme we use for our main frontend pages with the addition of the
limitparameter:?limit=a&page=x&order=y&filter=zwith all four parts being optional with sensible defaults (defaultlimitmatching the corresponding frontend parameter,pageSize = 50).For reference:
filterarenone(the default; never exposed in a public URL but still valid),year,month,week, anddayorderaretime(the default; never exposed yet) andrating2. Count API
Add a new route
/api/quote/count[filter]to get quote count information in the following format:{ "count": 123 }3. List API
Add a new route
/api/quote/list[filter]to get a list of quotes in the same format our current API use.4. CORS support
As we have plans to develop an isolated frontend for LogList, we'll need all the API routes to properly support CORS. So, there should be a configuration option to enable CORS with the admin-selected domain.
If that'll be easier to implement, enable CORS for the whole site, not just the new API.
5. Voting API
I suggest to finally implement #94 in relation to the voting API: move them to
/api/quote/{id}/(up|down)vote, and thus make them a part of the public, supported external API.Implementation