Questions tagged [json-api]

"JSON API" is a standard for building APIs in JSON format. If you've ever argued with your team about the way your JSON responses should be formatted, JSON API is your anti-bikeshedding weapon.

"JSON API" is a standard for building APIs in JSON format. If you've ever argued with your team about the way your JSON responses should be formatted, JSON API is your anti-bikeshedding weapon.

Furthermore, clients built around JSON API are able to take advantage of its features around efficiently caching responses, sometimes eliminating network requests entirely.

By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus on what matters: your application.

Here's what JSON API (in the ID style) looks like:

{
  "posts": [{
    "id": "1",
    "title": "Rails is Omakase",
    "links": {
      "author": "9",
      "comments": [ "5", "12", "17", "20" ]
    }
  }]
}

and in the URL style:

{
  "posts": [{
    "id": "1",
    "title": "Rails is Omakase",
    "links": {
      "author": "http://example.com/people/9",
      "comments": "http://example.com/comments/5,12,17,20"
    }
  }]
}

JSON API covers creating and updating resources as well, not just responses.

More information can be found on the project's homepage.

636 questions
6
votes
1 answer

Ember.js: How to access JSON API metadata from store.findRecord call

I am currently trying to figure out how to access metadata when using the store.findRecord() call. In the guides (http://guides.emberjs.com/v2.1.0/models/handling-metadata/) it says that metadata can be accessed by doing the…
Sarus
  • 3,093
  • 1
  • 21
  • 25
6
votes
2 answers

JSON API response and ember model names

A quick question about the JSON API response key "type" matching up with an Ember model name. If I have a model, say "models/photo.js" and I have a route like "/photos", my JSON API response looks like this { data: [{ id: "298486374", …
cswright
  • 151
  • 9
6
votes
2 answers

Retrofit JSONAPI converter needed?

Is there some way to use the JSONAPI spec with Retrofit?, don't know how this will work or how to start, any help?. I found this gist: https://gist.github.com/Gregadeaux/cbcc3781fda9d7fa6498, it uses RxJava and some other libraries. Also, is a…
nebiros
  • 687
  • 10
  • 29
6
votes
1 answer

Post to Rails from Emberjs using JSONAPI adapter, Rails not seeing the params

I am trying to save a message model in Emberjs. I am using the JSONAPIAdapter and JSONAPISerilzier. My post to rails hits the right controller and action as a post, but if I look inside with Pry, the data attributes are not there. My…
Paul Byrne
  • 1,493
  • 17
  • 23
6
votes
1 answer

JSON API examples in Swagger 2.0

I'm trying to create example responses for an endpoint with Swagger 2.0. 200: description: Successful response schema: type: object $ref: "#/definitions/User" examples: application/vnd.api+json: …
Salsaparapizza
  • 169
  • 1
  • 2
  • 9
6
votes
0 answers

Using Devise for Omniauth one-time-code flow in Rails JSON API

I'm currently implementing a JSON API for Rails to serve an Android mobile app, which requires Google authentication. The flow I'm hoping for is Google API OAuth2's One-time Code Flow (Hybrid Authentication), as explained in the…
mrstif
  • 1,480
  • 19
  • 25
5
votes
2 answers

OpenAPI vs JSON:API

I couldn't find any resources on the use case differences between JSON:API & OpenAPI From my understanding, JSON:API is more focused on the business data while OpenAPI is more about REST itself? Any pointers would be great, thanks!
Webber
  • 593
  • 6
  • 20
5
votes
1 answer

How do I express JSON-API sparse fieldsets with OpenAPI-3.0

I'm implementing an OpenAPI-3.0 spec for my API, and I plan on using sparse fieldsets as a parameter for GETs. The examples for parameters using style=deepObject are a little sparse, so I'm not sure if I've got this exactly right. - in: query …
Ben Johnson
  • 393
  • 2
  • 6
5
votes
1 answer

Ember Data + JSONAPI - Error: The adapter rejected the commit because it was invalid

I am attempting to submit invalid data via a POST request to a JSONAPI-based API with Ember Data 2.10. The API responds correctly with a 422 code and this payload in the response (note that these are error objects, not a "normal" JSONAPI payload…
Chris Peters
  • 17,133
  • 6
  • 44
  • 64
5
votes
2 answers

JSON API filter included resources

The question is about JSON API specification and how properly do a request (I'm using ruby on rails and the json api resources gem but that's a general question anyway, I know how to implement it, I just want to follow the rules of JSON API at:…
beniutek
  • 1,161
  • 12
  • 27
5
votes
1 answer

ember js get meta informations from json

i have a json data from my server: { "post": { "id": 1, "title": "Progressive Enhancement is Dead", "comments": ["1", "2"], "links": { "user": "/people/tomdale" } }, "meta": { "total": 100 } } look exactly…
Michael
  • 336
  • 1
  • 5
  • 15
5
votes
2 answers

API design - json_api best practice to return no data

I have Rails app that also has an API. I've been trying to follow http://jsonapi.org for the overall structure, but I can't find any guidelines for when it comes to result without any data. I for example have an endpoint that looks like…
Anders
  • 3,065
  • 7
  • 54
  • 106
5
votes
2 answers

Exposing the JSON Schema for API endpoints?

Is there a standard to where and how to expose the schema of API endpoints? For example, let's say the following API endpoints are available: api/companies/ api/companies/{id}/employees/ Where should the schema for the company and employee…
Dave New
  • 34,265
  • 48
  • 183
  • 366
5
votes
1 answer

Return 422 status code in ModelViewSet

For interoperability with EmberData it seems I need to reply with 422 (Unprocessable Entity) instead of 400 (Bad Request) whenever validation errors occur. I have two questions: How can I specify the response status code when using a…
blueFast
  • 33,335
  • 48
  • 165
  • 292
5
votes
2 answers

Why is the HTTP location header only set for POST requests/201 (Created) responses?

Ignoring 3xx responses for a moment, I wonder why the HTTP location header is only used in conjunction with POST requests/201 (Created) responses. From the RFC 2616 spec: For 201 (Created) responses, the Location is that of the new resource which…
Pipo
  • 4,713
  • 7
  • 34
  • 43
1 2
3
42 43