filmov
tv
R Tutorial: Understanding Application Programming Interfaces

Показать описание
---
So far you've used techniques for downloading static files and keeping them around, but most data on the Internet doesn't take that form. It's simply not practical: if you've got complex data, or simply a lot of it, you'd have to waste time and space constantly copying data into CSV files in the background every time something changes. For websites like Wikipedia and Facebook, there are hundreds of millions of changes every day, so it doesn't really make sense as an approach.
Instead, people often make data available behind Application Programming Interfaces, or APIs. These are programs designed to let code interact with a website, in the same way you interact with a web page, and they're used pretty much everywhere. One of the places they're used is in making data available. Instead of a website having to constantly write data to CSVs, it can just hook an API up to its database. Instead of the user having to type in a new URL each time, they can make small, consistent modifications that change the instructions the API is given for what to send back.
What those URLs and instructions look like is something we'll discuss later in the course, because one of the great things about APIs on the web is they make it trivial to write API clients: software libraries in various languages that make it possible for programmers or data scientists to interact with the API without ever having to care about how it's structured, or do the heavy lifting of cleaning up the data.
Nine times out of ten, if you're looking to get data out of an API, R probably has a client for it, that is, an R package that contains functions to retrieve that data.
One simple, useful trick is to Google "CRAN" and then the name of the website to see if one exists. And if there is a client, you should rely on it as much as possible, because much of the time it's a lot easier than writing your own.
Now you're going see an example of this using the pageviews package, which lets you see the number of views of Wikipedia pages. All you have to do is to call the function article_pageviews(), passing the name of a Wikipedia article.
You're calling an R function, just like any other, and do not need to worry about the details of the API.
Now it's your turn to try an example.
#DataCamp #RTutorial #Web #Data #API #token #Application #Programming #Interfaces