jsonapi_connect | R Documentation |
Connection
jsonapi_connect(url, version, content_type, headers, ...)
url |
(character) Base url, without the version information,
e.g., |
version |
(character) API version. Default: |
content_type |
(character) the content type to set in all request headers. Default: 'application/vnd.api+json' |
headers |
(list) A list of headers to be applied to each requset. |
... |
Curl options passed on to crul::verb-GET. You can set these for all requests, or on each request - see examples. |
Methods
status(...)
: Check server status with a HEAD request
...
: curl options passed on to crul::verb-GET
routes(...)
: Get routes the server supports
...
: curl options passed on to crul::verb-GET
route(endpt, query, include, error_handler, ...)
: Fetch a route,
optional query parameters
endpt
: The endpoint to request data from. required.
query
: a set of query parameters. combined with include
parameter
include
: A comma-separated list of relationship paths.
combined with query parameter
error_handler
: A function for error handling
...
: curl options passed on to crul::verb-GET
## Not run: library("crul") (conn <- jsonapi_connect("http://localhost:8088")) conn$url conn$version conn$content_type conn$status() conn$routes() conn$routes(verbose = TRUE) # get data from speicific routes conn$route("authors") conn$route("chapters") conn$route("authors/1") conn$route("authors/1/books") conn$route("chapters/5") conn$route("chapters/5/book") conn$route("chapters/5/relationships/book") ## include conn$route("authors/1", include = "books") conn$route("authors/1", include = "photos") conn$route("authors/1", include = "photos.title") ## set curl options on jsonapi_connect() call xx <- jsonapi_connect("http://localhost:8088", verbose = TRUE) xx$opts xx$status() ## set headers on initializing the client (conn <- jsonapi_connect("http://localhost:8088", headers = list(foo = "bar"))) ## errors ### route doesn't exist # conn$route("foobar") ### document doesn't exist # conn$route("authors/56") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.