Skip to content

Instantly share code, notes, and snippets.

@IllDepence
Last active March 2, 2018 04:21
Show Gist options
  • Save IllDepence/8f3affb62cc2516eb9ed89918f3baf24 to your computer and use it in GitHub Desktop.
Save IllDepence/8f3affb62cc2516eb9ed89918f3baf24 to your computer and use it in GitHub Desktop.

Root

$ curl -X GET \
       http://127.0.0.1/JSONkeeper/

HTTP/1.0 200 OK

{
  "message": "Storing 7 JSON documents. Serving an Activity Stream Collection with 3 CollectionPages at http://127.0.0.1/JSONkeeper/as/collection.json"
}

Store a JSON document

$ curl -X POST \
       -d '{"foo":"bar"}' \
       -H 'Accept: application/json' \
       -H 'Content-Type: application/json' \
       http://127.0.0.1/JSONkeeper/api

HTTP/1.0 201 CREATED
Location: http://127.0.0.1/JSONkeeper/api/e14f58b0-d0ec-4f35-a83b-49c613daa7a3

{"foo":"bar"}

Store a JSON-LD document

$ curl -X POST \
       -d '{"@context": … , "@id": "foo", … }' \
       -H 'Accept: application/json' \
       -H 'Content-Type: application/ld+json' \
       http://127.0.0.1/JSONkeeper/api

HTTP/1.0 201 CREATED
Location: http://127.0.0.1/JSONkeeper/api/b3529667-0949-418d-b3d8-35d64c6d6ec6

{"@context": … , "@id": "http://127.0.0.1/JSONkeeper/api/b3529667-0949-418d-b3d8-35d64c6d6ec6", … }

Note that the Content-Type is different and the document's @id gets changed.

Retrieve a JSON or JSON-LD document

$ curl -X GET \
       -H 'Accept: application/json' \
       http://127.0.0.1/JSONkeeper/api/e14f58b0-d0ec-4f35-a83b-49c613daa7a3

HTTP/1.0 200 OK

{"foo":"bar"}

Update a JSON document

$ curl -X PUT \
       -d '{"bar":"baz"}' \
       -H 'Accept: application/json' \
       -H 'Content-Type: application/json' \
       http://127.0.0.1/JSONkeeper/api/e14f58b0-d0ec-4f35-a83b-49c613daa7a3

HTTP/1.0 200 OK

{"bar":"baz"}

Update a JSON-LD document

Same as above, but with Content-Type: application/ld+json. @id get's corrected if the update doesn't use the one given when first stored.

Delete a JSON or JSON-LD document

$ curl -X DELETE  \
       http://127.0.0.1/JSONkeeper/api/e14f58b0-d0ec-4f35-a83b-49c613daa7a3

HTTP/1.0 200 OK

Store/Update/Delete a JSON or JSON-LD document with access restriction

Same as above but with an additional header X-Access-Token or X-Firebase-ID-Token.

Access the Activity Stream

$ curl -X GET \
       http://127.0.0.1/JSONkeeper/as/collection.json

HTTP/1.0 200 OK

{"@context": "https://www.w3.org/ns/activitystreams", "type": "Collection", … }

Get a list of all JSON and JSON-LD documents without access restriction

$ curl -X GET \
       http://127.0.0.1/JSONkeeper/api/userlist

HTTP/1.0 200 OK

[
  "http://127.0.0.1/JSONkeeper/api/b3529667-0949-418d-b3d8-35d64c6d6ec6", 
  "http://127.0.0.1/JSONkeeper/api/d69a0f6f-5e0c-4749-ab25-745d3ca016cc", 
  …
]

Get a list of all JSON and JSON-LD documents restricted by a certain X-Access-Token

Same as above but with an additional header X-Access-Token.

Get a list of all JSON and JSON-LD documents by a certain Firebase user

Same as above but with an additional header X-Firebase-ID-Token.

Get a sc:Range within a cr:Curation

$ curl -X GET \
       http://127.0.0.1/JSONkeeper/api/b3529667-0949-418d-b3d8-35d64c6d6ec6/range1

HTTP/1.0 200 OK

{"@context": … , "@type": "sc:Range", … }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment