-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_API_Omdb.Rmd
71 lines (44 loc) · 1.49 KB
/
2_API_Omdb.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "methods@manchester: API intro: Omdb API"
author: "Renata Topinkova"
date: "15 06 2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Load libraries
```{r libs}
library(httr)
library(dplyr)
```
## Endpoint & apikey
Get to the Omdb API website: https://www.omdbapi.com/
- Apply for a free API token: https://www.omdbapi.com/apikey.aspx
- Select Account type: Free
- Once you receive your API key via email, enter it into the endpoint in place of #### in the code
**Note:** As a best practice, you should not be hardcoding your API tokens into your code. Instead, it is better to make use of R environments.
More on this: https://bookdown.org/paul/apis_for_social_scientists/best-practices.html
```{r endpoints}
## Replace #### with the token you have received via email
endpoint <- "http://www.omdbapi.com/?apikey=####"
```
## Your turn!
### ### 1. Find out which movie has id "tt0425112"
```{r}
```
### 2. Get the full plot of the mystery movie that from ex. 1
```{r}
```
### 3. Find movies that have "dog" in their title.
Note: There should be more than one.
```{r}
```
### BONUS 1: Get more "dog" movies.
Hint: Look into the documentation. Which parameter you could use to get additional results?
```{r}
```
### BONUS 2: Bind the results from exercise 3 (and optionally, also Bonus 1) into a dataframe (tibble)
There are many solutions from different packages (base, dplyr, tidyr, purrr), don't be afraid to experiment!
```{r}
```