[R] R and REST API's

Duncan Temple Lang duncan at wald.ucdavis.edu
Mon Sep 28 20:25:49 CEST 2009


Hi Gary, Greg, et al.

In addition to making some things slightly simpler,
the RCurl package also provides some necessary lower-level
control over the HTTP requests. Firstly, it can handle HTTPS.
Secondly, numerous REST applications will require more information
in the header of the HTTP request, e.g. some authentication information.
url() and friends aren't designed to allow R programmers to specify this.

Also, JSON has come up in this thread. In addition to the rjson, there
is the RJSONIO package which should be a faster, drop-in substitute for rjson.


As for REST winning over SOAP, etc. both are in play and some
providers provide APIs for both (e.g. Amazon).  If you had
to implement a client from scratch for either, REST is definitely simpler.
However, SOAP is much more structured and can be automated because of the availability
of WSDL files that describe the interface. Until WADL becomes established, it is
actually easier for a consumer to programmatically generate a SOAP interface than
each REST interface separately.


BTW, Deb Nolan and I are writing a book on XML and Web Technologies with R
that we hope will appear early next year that will cover many aspects of scraping,
XML and JSON in this flavor.  There are lots of packages on the Omegahat repository
that do this (e.g. Rflickr, RAmazonS3, RAmazonDBREST, Zillow

  D.


Greg Hirson wrote:
> Gary,
> 
> Echoing Barry's suggestion of Omegahat packages, take a look at RCurl -
> http://www.omegahat.org/RCurl/
> It has a function, getForm, which passes GET form parameters as a list
> to curl. I used it and the XML package in writing
> RLastFM (http://cran.r-project.org/web/packages/RLastFM/index.html)
> which implements this for last.fm. With a few XPath queries (in the XML)
> package, you can format the data into a data frame.
> 
> Greg
> 
> Gary Lewis wrote:
>> Hi - Many organizations now make their data available as XML via a
>> REST web service architecture. Is there any R package or facility to
>> access this type of data directly (eg, to make the HTTP GET request
>> and have the downloaded data put into an R data  frame)?
>>
>> I used several R search sites to look for an answer, but came up with
>> very little. Any help would be appreciated.
>>
>> Thanks very much.
>>
>> Gary Lewis
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>   
>




More information about the R-help mailing list