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

JSON Data API cleanup for consistency #2124

Closed
10 of 12 tasks
ErisDS opened this issue Feb 4, 2014 · 0 comments
Closed
10 of 12 tasks

JSON Data API cleanup for consistency #2124

ErisDS opened this issue Feb 4, 2014 · 0 comments
Assignees
Labels
affects:api Affects the Ghost API
Milestone

Comments

@ErisDS
Copy link
Member

ErisDS commented Feb 4, 2014

The API needs:

  • a clear naming convention for functions
  • some thought about the names of non BREAD functions
  • a clear naming convention for options / arguments
  • some thought about what options / arguments are available to each function
  • clear convention for return values
  • consistent behaviour for error and warning handling

Once this work is complete, we should rename the API routes from v0.1 to v1.0


Update by @ErisDS 10-04-14:

As a result of the discussion which occurred in #2362, we now have a clear plan of what we want to do with our API in order to make it clear, consistent and easy to make decisions about how things should work.

We want to move our API towards supporting JSON-API, but with one major difference - all included objects should get included inline, rather than using linked objects. Linked object support will be added in the future via some sort of switch.

The move towards the JSON API response format includes a number of distinct changes:

  • The response is an object with a number of keys, one of those keys should be the pluralised name of the primary document type which is being returned. In terms of Ghost, this means posts, tags, users, settings etc.
  • The response object can also contain a meta key, this will be used to return pagination data
  • The key for the primary document type always contains an array, even when only one object is returned. Therefore the response for a single post would look like: { posts: [{ id: 1, uuid: ... } ] }
  • Related objects should default to using their relation name as the key. Therefore in the post response, there should be an author key, not an author_id key.
  • Related objects should only be exanded into full objects when explicitly declared with include.
  • The headers on the response should include a content-type header of 'application/vnd.api+json', 'application/json'.
  • The response to a create request should include a location header like Location: http://myblog.com/ghost/api/posts/12`
  • The keys for pagination data should be moved into a top-level meta object
  • We should add support for PATCH requests (long term)
  • We should add support for the sort query param (long term)

There are quite a few changes, some of them bigger and harder than others, the following is a list of issues which should get us from where we are to where we want to be.

@ErisDS ErisDS added api and removed data labels Feb 26, 2014
sebgie added a commit to sebgie/Ghost that referenced this issue Feb 27, 2014
first 10 % of TryGhost#2124
- added initial version of JSON API tests
- renamed error.errorCode to error.code
- renamed tags.all to tags.browse for consistency
ErisDS pushed a commit that referenced this issue Feb 28, 2014
first 10 % of #2124
- added initial version of JSON API tests
- renamed error.errorCode to error.code
- renamed tags.all to tags.browse for consistency
ErisDS pushed a commit that referenced this issue Mar 14, 2014
first 10 % of #2124
- added initial version of JSON API tests
- renamed error.errorCode to error.code
- renamed tags.all to tags.browse for consistency
sebgie added a commit to sebgie/Ghost that referenced this issue Mar 18, 2014
another 2 % of TryGhost#2124
- renamed `/ghost/api/v0.1/posts/getSlug/ to
`/ghost/api/v0.1/posts/slug/`
- renamed method getSlug to generateSlug
@ErisDS ErisDS changed the title [Draft] JSON Data API cleanup for consistency JSON Data API cleanup for consistency Apr 10, 2014
@ErisDS ErisDS added the epic label Apr 14, 2014
@ErisDS ErisDS modified the milestones: API, 0.5 Apr 15, 2014
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

No branches or pull requests

1 participant