This vignette provides a quick tour of the R package “FlickrAPI”. This package is maintained by Koki Ando.
# pak::pkg_install("koki25ando/FlickrAPI")
library(FlickrAPI)
# Set the API key for a single session
setFlickrAPIKey(api_key = "YOUR_API_KEY_HERE")
# Install the API key for future sessions
setFlickrAPIKey(api_key = "YOUR_API_KEY_HERE", install = TRUE)
# Overwrite an existing API key
setFlickrAPIKey(api_key = "YOUR_API_KEY_HERE", overwrite = TRUE)
There are two functions for searching Flickr photos:
getPhotos()
getPhotoSearch()
getPhotos()
allows you to get public photos for any Flickr user or all photos from the account associated with the Flickr API key.
# Search for photos uploaded by Koki Ando
getPhotos(user_id = "141696738@N08")
getPhotoSearch()
supports a broader range of search options including:
getPhotoSearch(tags = c("cats","dogs"))
# Search for photos of cats and dogs in North Carolina
<- sf::st_read(system.file("shape/nc.shp", package = "sf"))
nc <- sf::st_bbox(nc)
nc_bbox
getPhotoSearch(tags = c("cats","dogs"), bbox = nc_bbox)
getPhotoSearch()
returns 100 photos per page by default but this can be increased to 250 if using the bbox parameter searching by location or 500 otherwise. Additional pages can be accessed using the page parameter.
The extras parameter can be used to return additional information about the photos including “description”, “date_upload”, “date_taken”, “owner_name”, and urls for all available image sizes.
# Search for photos tagged "panda" in the area of Ueno Zoo, Tokyo, Japan
getPhotoSearch(
tags = "panda",
bbox = c(139.7682226529, 35.712627977, 139.7724605432, 35.7181464141),
sort = "interestingness-desc",
extras = c("geo", "tags")
)
There are two functions for getting data about a specific Flickr photo:
getExif()
getPhotoInfo()
getPhotoInfo(photo_id="51899696261",
output = "url")
getExif(photo_id="51872765082")