=========================================== GITHUB API: Starting with RESTFUL API ===========================================

REFERENCE: https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api

curl https://api.github.com/zen

Add -s (silent)

curl -s  https://api.github.com/zen

Info about user defunkt

curl -s https://api.github.com/users/defunkt
knitr::knit_exit()

TO include HEADERS

curl -i https://api.github.com/users/defunkt

TO see HEADERS Only:

curl --head https://api.github.com/users/defunkt

======================

AUTHENTICATION

======================

Asks for username (anything seems ok)

curl -i -u your_username https://api.github.com/users/octocat

WORKS

(updated 20FEB22)

To retrieve my Github_PAT (stored in ~/.Renviron) and put into zsh shell

token=$(Rscript -e "cat(Sys.getenv('GITHUB_PAT'))")

echo $token

# note x-ratelimit-limit: 5000

curl -si -u jimrothstein:$token https://api.github.com/users/octocat

To get info about me (if authenticated)

curl -i -u jimrothstein:$token https://api.github.com/users/user

curl -i -u jimrothstein:$token https://api.github.com/users/jimrothsein

=========================================================================

WORKS!

endpoint=/status curl ${base}${endpoint}

exit

===============================================================================

Contributors is public

But collobrators is private

===============================================================================

curl -s https://api.github.com/repos/google/go-github/contributors | head -40

curl -s https://api.github.com/repos/jimrothstein/try_things_here/contributors | head -40

===============================================================================

Colloboraters (project manger) is privid and requires authorization.

FAILS

curl -s https://api.github.com/repos/jimrothstein/try_things_here/collaborators

WORKS

curl -s -u jimrothstein:$token https://api.github.com/repos/jimrothstein/try_things_here/collaborators

===============================================================================

file <- "slide_curl_intro_github.Rmd"
file  <- normalizePath(file)
file
rmarkdown::render(file, output_dir="~/Downloads/print_and_delete")


jimrothstein/yt_api documentation built on Nov. 5, 2022, 8:05 p.m.