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

Post API: Returning additional objects #2620

Closed
ErisDS opened this issue Apr 19, 2014 · 5 comments · Fixed by #2652
Closed

Post API: Returning additional objects #2620

ErisDS opened this issue Apr 19, 2014 · 5 comments · Fixed by #2652
Assignees
Labels
affects:api Affects the Ghost API
Milestone

Comments

@ErisDS
Copy link
Member

ErisDS commented Apr 19, 2014

This issue is a result of the API format discussion in #2362, and is part of a larger project to move our API towards the JSON-API format which is documented in the Epic: #2124. This is one step in the journey towards achieving the Post JSON object format laid out in #2347, and is related to #2604.


The posts API is currently the most functional API. It is the only API which handles proper browse requests with pagination and other options. This is logical and will continue to be built upon.
One of the extra features in the post browse request, is the ability to return all the posts which have a particular tag. This will soon be expanded to also allow you to request all the posts which have a particular user. When making these requests, the object queried for (tag or user) is also included in the response.

Currently this object is returned as a top level property called aspect:

{
    posts: [{...}, {...}],
    aspect: {
        tag: {...}
    }, 
    limit: #,
    ...
}

We want to move this aspect object into the meta object:

{
    posts: [{...}, {...}],
    meta: {
        pagination: {...},
        aspect: {...}
    }
}

We also want to consider whether aspect is the right name for this object, or if there is a better name for it... any suggestions?

@ErisDS ErisDS added this to the 0.4 API milestone Apr 19, 2014
@ErisDS ErisDS added the api label Apr 19, 2014
@hswolff
Copy link
Contributor

hswolff commented Apr 20, 2014

We could take a cue from JSONAPI and include it under the top level linked key.

{
    posts: [{...}, {...}],
    meta: {
        pagination: {...},
    },
    linked: {
         tag: {...},
         user: {...},
    }
}

@sebgie
Copy link
Contributor

sebgie commented Apr 21, 2014

meta is according to JSON API the suggested place to put meta-information about a resource. As aspect is some kind of meta-information it should go there.

More questions:

  • What happens if a tag is not found? At the moment an empty posts result with an invalid tag object as aspect is returned. I think that aspect is empty in that case?
{
    posts: [ ],
    meta: {
        ...
    },
    aspect: {
        tag: {
            slug: "getting"
        }
    }
}
  • Is it possible to have more than one aspect? If yes returning aspects: [{...}] as array would be good.

@ErisDS
Copy link
Member Author

ErisDS commented Apr 22, 2014

Trying desperately to thing of a better name than aspect / aspects. subject? It is the subject of the query. query? queryObject ?

Plural would probably be a good idea though - I imagine one day having posts requested for a particular tag by a particular author. Then there is text search...

@sebgie
Copy link
Contributor

sebgie commented Apr 22, 2014

I think that what is implemented right now is a filter that exactly matches one tag object and then returns all posts that are related with the tag. Maybe filters or filterObjects would be a suitable name?

I don't think that this issue is related to search since a search term is never represented by an object available in our database?

@ErisDS
Copy link
Member Author

ErisDS commented Apr 24, 2014

filters 👍

sebgie added a commit to sebgie/Ghost that referenced this issue Apr 27, 2014
closes TryGhost#2620
- moved aspect -> filters
- updated tests
- fixed inconsistency in pagination object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:api Affects the Ghost API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants