knitr::opts_chunk$set(echo = TRUE, comment = " ##", error = TRUE, collapse = TRUE)
# foo1 will be a function library(knitr) knit_hooks$set(foo1 = function(before, options, envir) { if (before) { '\\tiny _I appear before a chunk!_\n\n' } else { '\\normalsize \n\n_I am after a chunk..._' } })
users.
(from Wikipedia)https://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services
Web service APIs that adhere to the REST architectural constraints are called RESTful APIs.[12] HTTP-based RESTful APIs are defined with the following aspects:[13]
No R libraries (wrapper) for Github API
Endpoints:
https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps
https://developers.google.com/youtube/v3/docs/playlists/list
CURL intro (using httpbin.org) do in browser, then in curl compare: curl -is httpbin.org vs httpbin.org/get
browser: show curl
curl -sv http://httpbin.org
https://httr2.r-lib.org
show httpbin.org show github.com
```{zsh, foo1="whatever"} curl -s https://api.github.com/users/jimrothstein | head
# json, -i includes headers ```{zsh} curl -si https://api.github.com/users/jimrothstein | head
Why a token?
settings | developer settings (bottom left)
more info: get token: https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api
https://docs.github.com/en/rest ```{zsh, echo=T} export token=$(Rscript -e "cat(Sys.getenv('GITHUB_PAT'))")
curl -si -u jimrothstein:$token https://api.github.com/users/jimrothstein | head
# store the token ~/.Renviron # token, works ```{zsh, echo=T} # Authorization? export token=$(Rscript -e "cat(Sys.getenv('GITHUB_PAT'))") echo $token curl -Hs "Authorization: token $token" https://api.github.com/users/codertocat -I
R has a tool plumber
.
Not for today.
use app? They are going to give their username/password to your app.
(Quote: httr2:: docs)
#knitr::knit_exit()
{ file <- "002_API_R_talk.Rmd" file <- normalizePath(file) file } rmarkdown::render(file, output_dir = "~/Downloads/print_and_delete")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.