[R] R and REST API's
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Mon Sep 28 17:26:38 CEST 2009
On Mon, Sep 28, 2009 at 3:01 PM, Gary Lewis <gary.m.lewis at gmail.com> 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.
You can (in many places) replace a filename with url(address) and R
functions such as read.table will work. If the response is XML then
getting the response into a data frame will be so dependent on the
format then it's unlikely there's a generic solution.
Specific solutions exist - for example my geonames package that
queries the geonames server for geographic information:
http://r-forge.r-project.org/projects/geonames/
Note that instead of getting XML and having to parse that, it gets
the JSON representation and use rjson to decode it - which saves a bit
of weight since XML parsing is a bit heavy.
I suspect that if SOAP and WSDL interfaces were more widely used then
some of the R Omegahat projects might be more useful:
http://www.omegahat.org/download/R/packages/
but it seems that informal service definitions via simple REST
interfaces and XML responses are winning.
Barry
More information about the R-help
mailing list