Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a new API for getting the quote list #84

Open
4 of 5 tasks
rexim opened this issue Mar 23, 2015 · 5 comments
Open
4 of 5 tasks

Define a new API for getting the quote list #84

rexim opened this issue Mar 23, 2015 · 5 comments
Assignees
Milestone

Comments

@rexim
Copy link
Member

rexim commented Mar 23, 2015

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:

{
    "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

@rexim rexim added this to the REST API milestone Mar 23, 2015
@rexim rexim self-assigned this Apr 4, 2015
@ForNeVeR ForNeVeR assigned ForNeVeR and unassigned rexim May 8, 2017
@ForNeVeR
Copy link
Member

ForNeVeR commented May 8, 2017

I'm on it.

@ForNeVeR
Copy link
Member

ForNeVeR commented May 8, 2017

For all parties involved: please note I've added the technical specification to the first post. Feel free to discuss.

@rexim
Copy link
Member Author

rexim commented May 8, 2017

@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
Copy link
Member Author

rexim commented May 8, 2017

Overall I'm approved by this shit 👍

ForNeVeR added a commit that referenced this issue May 8, 2017
@ForNeVeR
Copy link
Member

ForNeVeR commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants