April 4, 2014

Vine from R

Have you ever use Vine? This is the web service sharing movies(short clips), which is restricted to only 6 minutes. There are 60 million clips uploaded at the site.

For Vine there is an unofficial web API. Why unofficial? The reason is that tVine does not release the API. So, you need to keep in mind that this API may change without notice.

Now, today, I will try this API from R.There are three steps here.

Step 1. Register vine Step 2. Check the API reference Step 3. Use from R

Step 1. Register vine

First, you need to download the application for your mobile, iOS or Android, and get your accounts. It seems that a part of APIs can be used without registration.

Step 2. Check the API reference

Second, let's move on the API reference site and check the document. It seems that Vine has at least 10 APIs.

Step 3. Use the API from R

At last, we are ready to get data from Vine through the API. Here I show a simple case. I try to get popular clips. In the next post, I will introduce other APIs and my library for the API.

library(httr)
library(jsonlite)
USERNAME <- "ichikawadaisuke@gmail.com"
PASSWORD <- "moomin322"
POST("https:/api.vineapp.com/users/authenticate",
     body= list(username="ichikawadaisuke@gmail.com", 
                password="moomin322"))

Get popular20's URL

library(httr)
library(jsonlite)
req <- GET("https://api.vineapp.com/timelines/popular")
res <- content(req, as="text")
parsed <- fromJSON(res)
# popular20's URL
parsed$data$records$permalinkUrl
##  [1] "https://vine.co/v/MiAlnJALiYL" "https://vine.co/v/MiAZ6wO5HMV"
##  [3] "https://vine.co/v/MiA7ePtrmDU" "https://vine.co/v/MibnqQeVmYU"
##  [5] "https://vine.co/v/Miqrw79lbMi" "https://vine.co/v/MiqmmMhlKAT"
##  [7] "https://vine.co/v/MiKLzrvjiiI" "https://vine.co/v/MiKE9YBp2pQ"
##  [9] "https://vine.co/v/MiADHM3XvjE" "https://vine.co/v/MiAWO9xPgOh"
## [11] "https://vine.co/v/MiA6IpwBqi5" "https://vine.co/v/MiK3MU5VzFE"
## [13] "https://vine.co/v/MiA5Q9Y0uQX" "https://vine.co/v/MiAIEYbOL7r"
## [15] "https://vine.co/v/Miq6uKYQzD7" "https://vine.co/v/MiAmWPWQxD9"
## [17] "https://vine.co/v/MiKYAY07xM6" "https://vine.co/v/MiAWpjg20Vv"
## [19] "https://vine.co/v/MiAz2FAWq99" "https://vine.co/v/MiKVx3Kr1t0"

No comments:

Post a Comment