Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Collection+JSON application/vnd.collection+json

{ "collection" :
  {
    "version" : "1.0",
    "href" : "http://example.org/friends/",
    
    "links" : [
      {"rel" : "feed", "href" : "http://example.org/friends/rss"}
    ],
    "items" : [
	  {
		"href" : "http://example.org/friends/jdoe",
		"data" : [
		  {"name" : "full-name", "value" : "J. Doe", "prompt" : "Full Name"},
		  {"name" : "email", "value" : "jdoe@example.org", "prompt" : "Email"}
		],
		"links" : [
		  {"rel" : "blog", "href" : "http://examples.org/blogs/jdoe", "prompt" : "Blog"},
		  {"rel" : "avatar", "href" : "http://examples.org/images/jdoe", "prompt" : "Avatar", "render" : "image"}
		]
	  }
	]
}

HAL application/hal+json

There is a browser demo called HAL Browser.

{
    "_links": {
        "next": { "href": "/page=2", "title": "Page 2" },
        "search": { "href": "/search{?q}", "title": "Search", "templated": true},
        "items": [{
          "href": "/first_item",
		  "title": "Domain Driven Design"
	     },{
		  "href": "/second_item",
		  "title": "REST in Practice"
	     }]
    }
}

Hydra + JSON-LD application/ld+json

There is a browser demo called Hydra Console.

The entity itself:

{
    "@context": "/hydra/api-demo/contexts/EntryPoint.jsonld",
    "@id": "/hydra/api-demo/",
    "@type": "EntryPoint",
    "issues": "/hydra/api-demo/issues/",
    "register_user": "/hydra/api-demo/users/",
    "users": "/hydra/api-demo/users/"
}

The part of the referenced document, which describes the register_user link:

{
    "@context": {
        "vocab": "http://www.markus-lanthaler.com/hydra/api-demo/vocab#",
        "hydra": "http://www.w3.org/ns/hydra/core#",
        "ApiDocumentation": "hydra:ApiDocumentation",
        "property": {
            "@id": "hydra:property",
            "@type": "@id"
        },
        "readonly": "hydra:readonly",
        "writeonly": "hydra:writeonly",
        "expects": {
            "@id": "hydra:expects",
            "@type": "@id"
        },
        "returns": {
            "@id": "hydra:returns",
            "@type": "@id"
        },
        "statusCodes": "hydra:statusCodes",
        "code": "hydra:statusCode",
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "label": "rdfs:label",
        "description": "rdfs:comment",
        "domain": {
            "@id": "rdfs:domain",
            "@type": "@id"
        },
        "range": {
            "@id": "rdfs:range",
            "@type": "@id"
        },
        "subClassOf": {
            "@id": "rdfs:subClassOf",
            "@type": "@id"
        }
    },
    "@id": "http://www.markus-lanthaler.com/hydra/api-demo/vocab",
    "@type": "ApiDocumentation",
    "hydra:supportedClass": [
        {
            "@id": "vocab:EntryPoint",
            "@type": "hydra:Class",
            "subClassOf": null,
            "label": "EntryPoint",
            "description": "The main entry point or homepage of the API.",
            "hydra:supportedOperation": [
                {
                    "@id": "_:entry_point",
                    "@type": "hydra:Operation",
                    "hydra:method": "GET",
                    "label": "The APIs main entry point.",
                    "description": null,
                    "expects": null,
                    "returns": "vocab:EntryPoint",
                    "statusCodes": []
                }
            ],
            "hydra:supportedProperty": [
                {
                    "property": {
                        "@id": "vocab:EntryPoint/registerUser",
                        "@type": "hydra:Link",
                        "label": "register_user",
                        "description": "IRI to register a new user",
                        "domain": "vocab:EntryPoint",
                        "range": "http://www.w3.org/ns/hydra/core#Resource",
                        "hydra:supportedOperation": [
                            {
                                "@id": "_:user_create",
                                "@type": "hydra:Operation",
                                "method": "POST",
                                "label": "Creates a new User entity",
                                "description": null,
                                "expects": "vocab:User",
                                "returns": "vocab:User",
                                "statusCodes": [
                                    {
                                        "code": 201,
                                        "description": "If the User entity was created successfully."
                                    }
                                ]
                            }
                        ]
                    },
                    "hydra:title": "register_user",
                    "hydra:description": "IRI to register a new user",
                    "required": null,
                    "readonly": true,
                    "writeonly": false
                }
            ]
        }
    ]
}

jsonapi application/vnd.api+json

There is a browser demo at JSON API Browser.

{
  "links": {
    "self": "http://example.com/posts",
    "next": "http://example.com/posts?page[offset]=2",
    "last": "http://example.com/posts?page[offset]=10"
  },
  "data": [{
    "type": "posts",
    "id": "1",
    "title": "JSON API paints my bikeshed!",
    "links": {
      "self": "http://example.com/posts/1",
      "author": {
        "self": "http://example.com/posts/1/links/author",
        "related": "http://example.com/posts/1/author",
        "linkage": { "type": "people", "id": "9" }
      },
      "comments": {
        "self": "http://example.com/posts/1/links/comments",
        "related": "http://example.com/posts/1/comments",
        "linkage": [
          { "type": "comments", "id": "5" },
          { "type": "comments", "id": "12" }
        ]
      }
    }
  }],
  "included": [{
    "type": "people",
    "id": "9",
    "first-name": "Dan",
    "last-name": "Gebhardt",
    "twitter": "dgeb",
    "links": {
      "self": "http://example.com/people/9"
    }
  }]
}

Mason application/vnd.mason+json

{
  "id": 1,
  "title": "Program crashes when pressing ctrl-p",
  "attachments": [
    {
      "id": 1,
      "title": "Error report",
      "@links": {
        "self": {
          "href": "http://example.org/attachments/1"
        }
      }
    }
  ],
  "@links": {
    "self": {
      "href": "http://example.org/issues/1"
    },
    "up": [{
      "href": "http://example.org/projects/1",
      "title": "Containing project"
    }]
  },
  "@link-templates": {
    "issue-query": {
      "template": "http://example.org/issues-query?text={query}",
      "title": "Search for issues",
      "description": "This is a simple search.",
      "parameters": [
        {
          "name": "query",
          "description": "Substring search for text in title and description"
        }
      ]
    }
  },
  "@actions": {
    "project-create": {
      "type": "json",
      "href": "http://example.org/projects",
      "title": "Create new project",
      "schemaUrl": "http://example.org/schemas/create-project"
    }
  }
}

Siren application/vnd.siren+json

{
  "class": [ "order" ],
  "properties": { 
      "orderNumber": 42, 
      "itemCount": 3,
      "status": "pending"
  },
  "actions": [
    {
      "name": "add-item",
      "title": "Add Item",
      "method": "POST",
      "href": "http://example.org/orders/42/items",
      "type": "application/x-www-form-urlencoded",
      "fields": [
        { "name": "orderNumber", "type": "hidden", "value": "42" },
        { "name": "productCode", "type": "text" },
        { "name": "quantity", "type": "number" }
      ]
    }
  ],
  "links": [
    { "rel": [ "self" ], "href": "http://example.org/orders/42" },
    { "rel": [ "previous" ], "href": "http://example.org/orders/41" },
    { "rel": [ "next" ], "href": "http://example.org/orders/43" }
  ]
}

UBER application/vnd.uber-amundsen+json

{
  "uber" :
  {
    "version" : "1.0",
    "data" :
    [
      {"rel" : ["self"], "url" : "http://example.org/"},
  	  {
		"name" : "search",
		"rel" : ["search","collection"],
		"url" : "http://example.org/people/search{?givenName,familyName,email}",
		"templated" : "true"
      },
      {
	  	"name" : "name",
	  	"value" : "Home"
	  },
	  {
		"name" : "create",
		"rel" : ["http://example.org/rels/create"],
		"url" : "http://example.org/people/",
		"model" : "g={givenName}&f={familyName}&e={email}",
		"action" : "append"
	  }
	]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.