Learn R Programming

rjsonapi (version 0.1.0)

jsonapi_server: Start a JSONAPI server

Description

Start a JSONAPI server

Usage

jsonapi_server(port = 8000)

Arguments

port
(integer) the port to run the server on. default: 8000

Details

Right now, this function doesn't take arbitrary input, but instead serves the same content as this JSON API example https://github.com/endpoints/endpoints-example. Note that not all features are the same as the full endpoints-example, but most should work.

Right now, this function serves data from static, minified JSON files, so there's no dynamic database underneath.

Kill the server by CTRL+C, ESC or similar.

Examples

Run this code
## Not run: 
# # start server in another R session
# if (interactive()) {
#   jsonapi_server()
# 
#   # Back in this session ...
#   # Connect
#   (conn <- jsonapi_connect("http://localhost:8000"))
# 
#   # Get data
#   conn$url
#   conn$version
#   conn$content_type
#   conn$routes()
#   conn$route("authors")
#   conn$route("chapters")
#   conn$route("authors/1")
#   conn$route("authors/1/books")
#   conn$route("chapters/5")
# }
# ## End(Not run)

Run the code above in your browser using DataLab