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.

693 questions
10
votes
1 answer

Add custom serializer to Swagger in my .Net core API

I'm using the JSONAPI specifications from jsonapi.org, then I'm using the JsonApiSerializer to accomplish the JSONAPI specification, so my response and request body looks like: { "data": { "type": "articles", "id": "stringId", …
HTT
  • 130
  • 1
  • 6
10
votes
2 answers

Do I need Oauth2 For my Web Apps API

I am trying to wrap my brain around building an express.js / node.js based REST API. I have a couple of questions... Do I NEED token based / oauth 1 or 2 security for my api if I'm only concerned about a web application right now (not necessarily…
Daniel White
  • 3,337
  • 8
  • 43
  • 66
9
votes
1 answer

EmberJS Data Assert in setRecordDataFor "Illegal set of identifier"

Using 3.28 I am hitting an assert deep inside Ember Data when retrieving a relationship on one of my models. I can run the following query just fine: return this.store.findRecord('project', project_id) However when I run a subsequent const monitors…
samuraisam
  • 1,927
  • 1
  • 20
  • 24
9
votes
2 answers

JSON API for non-resource responses

Currently, I'm working on new product and making REST API for both - public and internal needs. I started with {json:api} specification and I was pretty happy with it until I faced some questions I cannot find answers to. According to JSON API…
Arūnas Smaliukas
  • 3,231
  • 6
  • 27
  • 46
9
votes
2 answers

Authentication with JWT and JSONAPI

I am implementing REST API using the following technologies/approaches: JSONAPI JWT token I want to implement authentication endpoint, it should receive username and password in POST request in JSONAPI format and return JWT token in JSONAPI…
Sergey Potapov
  • 3,819
  • 3
  • 27
  • 46
9
votes
1 answer

JSON API REST endpoint with permissions-restricted fields

JSON API REST endpoint with permissions-restricted fields I am working on a JSON API-compliant REST api. Some endpoints contain fields that should be restricted (read-only or not available) for certain users. What is the best way to architect the…
8
votes
4 answers

WP REST API fetch posts from post type

How can I get all the posts from a specific custom post type with WP REST API (either v1 or v2)? I'm very new to this and trying to understand how to do that. I am currently using WP REST API v2 and managed to fetch a list of all the post types with…
Jeff
  • 543
  • 2
  • 9
  • 27
8
votes
1 answer

EmberJS embedded items in payload JSONAPI

Ember : 1.13.3 Ember Data : 1.13.5 jQuery : 1.11.3 I am trying to send a JSON payload using ember-data from my EmberJS client to my server. I want to send the entire object graph to the server on saving the project, as I don't want to send…
Asagohan
  • 583
  • 5
  • 19
8
votes
1 answer

Rails 4 Require and Permit Multiple

A long time Java developer - new to ror - I am building a JSON REST API in Rails 4, and I have run into issues using strong parameters. When I perform an HTTP POST request to one of my endpoints, I would like for my controller to require the main…
svarlamov
  • 113
  • 1
  • 9
7
votes
1 answer

What is difference between json-rpc and json-api?

Could anybody explain advantage of using json-rpc over json-api and vice-versa? First and second format are JSON-based, but where I should use one, and where is another?
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
7
votes
1 answer

upload to google cloud store using json api from javascript

I am trying to use gapi to upload an image to google cloud storage.The current code I have is