knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(useapi) if (dir.exists("example")) { unlink("example", recursive = TRUE) } if (dir.exists("/tmp/useapitest")) { unlink("/tmp/useapitest", recursive = TRUE) } #remove.packages("useapitest")
📩📨 A workflow for building API wrapper/client packages in R.
You can install from Github with:
## install from github devtools::install_github("mkearney/useapi")
This is a basic example of how to create a new API client package:
## create example package create_api_package(path = "/tmp/useapitest", site = "Use API Test", base_url = "https://api.useapitest.com/v1")
See the example useapitest package here.
## load new package library(useapitest) ## create request URL useapitest:::useapitest_api_call(path = "rstats/apidevtools", n = 20, include_entities = TRUE)
It's all ready to send and receive HTTP requests1:
## send GET request r <- useapitest_api_get(path = "rstats/apidevtools", n = 20) ## view data useapitest_as_tbl(r)
1 Note: The example is a fictional website/application and thus will create an error due to an unresolveable host domain.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.