Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 5971

Interfacing with APIs using R: the basics

$
0
0

While R (and its package ecosystem) provides a wealth of functions for querying and analyzing data, in our cloud-enabled world there's now a plethora of online services with APIs you can use to augment R's capabilities. Many of these APIs use a RESTful interface, which means you will typically send/receive data encoded in the JSON format using HTTP commands.

Fortunately, as Steph Locke explains in her most recent R Quick tip, the process is pretty simple using R:

  1. Obtain an authentication key for using the service 
  2. Find the URL of the API service you wish to use
  3. Convert your input data to JSON format using toJSON in the jsonlite package
  4. Send your data to the API service using the POST function in the httr package. Include your API key using the add_headers function
  5. Extract your results from the API response using the fromJSON function

Steph provides an example of detecting text language using the Microsoft Cognitive Services Text Analytics API, but that basic recipe should work for most APIs. (API keys for other Microsoft Cognitive Services APIs for vision, speech, language, knowledge and search are also available for free use with your Github account.) There many APIs available for use around the web, and this list of public APIs maintained by Abhishek Banthia is also a useful resource.

Locke Data: R Quick tip: Microsoft Cognitive Services’ Text Analytics API

 

 


Viewing all articles
Browse latest Browse all 5971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>