Using `read_json` with a header for web-scraping?

I have a newbie web scraping question I was hoping to get some help on. For one of my projects, I've been using the Open Science Framework's API to collect data. Fortunately, it is very accessible and well documented.

For the most part, I have been reading the pages via jsonlite::read_json which has worked well, however after reading the documentation more carefully I see that I really should be authenticating using a header in my request (link goes to relevant the documentation).

An example request I've been sending is:

x <- read_json("*&page=1&format=jsonapi")

My question is, is there a way to authenticate myself using the read_json method? As I've been scaling out I've been getting " Too Many Requests error, and I think authenticiization would help with this. I've found these slides about using the httr package, but I'm not sure if it is right to switch methods and completely redo my code.

I'm not familiar with the httr package, this may involve only changing one line of code, but I wanted to seek advice.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.