Skip to content

Define a new API for getting the quote list #84

Open

Description

@rexim

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

Activity

  1. added this to the REST API milestone on Mar 23, 2015
  2. self-assigned this
    on Apr 4, 2015
  3. assigned and unassigned on May 8, 2017
  4. ForNeVeR commented on May 8, 2017

    @ForNeVeR
    Member

    I'm on it.

  5. ForNeVeR commented on May 8, 2017

    @ForNeVeR
    Member

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

  6. rexim commented on May 8, 2017

    @rexim
    MemberAuthor

    @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.

  7. rexim commented on May 8, 2017

    @rexim
    MemberAuthor

    Overall I'm approved by this shit 👍

  8. added a commit that references this issue on May 8, 2017
  9. ForNeVeR commented on May 8, 2017

    @ForNeVeR
    Member

    @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.

  10. added 7 commits that reference this issue on May 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions