You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
@ForNeVeR Why in 2. Count API the field that reports "amount of quotes" is called just "quotes"? I mean we already know that a route /api/quote/count[filter] should probably return amount of quotes (because there are words 'count' and 'quote' in the route). But why do we call the payload field specifically like that? Do we plan to extend the response with more count fields of a different kind?
{
"quotes": 123,
"goats": 52,
"mixers": 63
}
If it is true then those field should be directly related to quotes, because the name of the route implies so. What other quote related counts can we have? Total amount of votes for this specific filter?
I mean, I don't mind the current name, it just raises too many questions in my perverted brain. If the answer is "I couldn't come up with a better name", I'm ok with that.
@rexim that was a leftover from my previous idea when I was considering to count quotes, pages and even return the page size limit from the server. I've fixed the spec; the new name of that parameter is just count.
Activity
ForNeVeR commentedon May 8, 2017
I'm on it.
ForNeVeR commentedon May 8, 2017
For all parties involved: please note I've added the technical specification to the first post. Feel free to discuss.
rexim commentedon May 8, 2017
@ForNeVeR Why in
2. Count APIthe field that reports "amount of quotes" is called just "quotes"? I mean we already know that a route/api/quote/count[filter]should probably return amount of quotes (because there are words 'count' and 'quote' in the route). But why do we call the payload field specifically like that? Do we plan to extend the response with more count fields of a different kind?{ "quotes": 123, "goats": 52, "mixers": 63 }If it is true then those field should be directly related to quotes, because the name of the route implies so. What other quote related counts can we have? Total amount of votes for this specific filter?
I mean, I don't mind the current name, it just raises too many questions in my perverted brain. If the answer is "I couldn't come up with a better name", I'm ok with that.
rexim commentedon May 8, 2017
Overall I'm approved by this shit 👍
#84: add quote count API
ForNeVeR commentedon May 8, 2017
@rexim that was a leftover from my previous idea when I was considering to count quotes, pages and even return the page size limit from the server. I've fixed the spec; the new name of that parameter is just
count.#84: add quote list API
#84: optionally enable CORS
#84: optionally enable CORS
#84: optionally enable CORS
#84: move CORS stuff to its own package
#84: small API fixes and documentation
#84: small API fixes and documentation