get_ghibli: Retrieve data from the Ghibli API

View source: R/ghibliapi.R

get_ghibliR Documentation

Retrieve data from the Ghibli API

Description

Retrieve data from the Ghibli API

Usage

get_ghibli(type = NULL, id = NULL)

Arguments

type

The endpoint type, one of 'films', 'species', 'people', 'vehicles' or 'locations'. Default to NULL if nothing is provided.

id

The object index. Default is all unless an id is specified.

Value

Either a data.frame (if id is NULL) or a list

References

https://ghibliapi.herokuapp.com

Examples

 get_ghibli(type="films")
 get_ghibli(type="people",id="986faac6-67e3-4fb8-a9ee-bad077c2e7fe")
 ## Not run: 
 require("tidyverse")
 get_ghibli("species") %>%
 filter(name=="Cat") %>%
 select(id) %>%
 get_ghibli("species",id=.) %>%
 subset(.,str_detect(.,"people")) %>%
 str_replace("https://ghibliapi.herokuapp.com/people/","") %>%
 map(~ get_ghibli("people",.)) %>%
 {
  tibble(
  name = map_chr(., "name"),
  gender = map_chr(., "gender"),
  eye_color = map_chr(., "eye_color"),
  hair_color = map_chr(., "hair_color")
  )
 }

## End(Not run)

onertipaday/ghibliapi documentation built on Sept. 13, 2022, 12:22 a.m.