-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
84 lines (55 loc) · 3.11 KB
/
README.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
options("gu.API.key" = "test")
```
# guardianapi
<!-- badges: start -->
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![CRAN status](https://www.r-pkg.org/badges/version/guardianapi)](https://cran.r-project.org/package=guardianapi)
[![GitHub tag](https://img.shields.io/github/tag/evanodell/guardianapi.svg)](https://github.com/evanodell/guardianapi)
[![](https://cranlogs.r-pkg.org/badges/grand-total/guardianapi)](https://dgrtwo.shinyapps.io/cranview/)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/evanodell/guardianapi?branch=master&svg=true)](https://ci.appveyor.com/project/evanodell/guardianapi)
[![R build status](https://github.com/evanodell/guardianapi/workflows/R-CMD-check/badge.svg)](https://github.com/evanodell/guardianapi/actions)
[![Coverage status](https://codecov.io/gh/evanodell/guardianapi/branch/master/graph/badge.svg)](https://codecov.io/github/evanodell/guardianapi?branch=master)
[![DOI](https://zenodo.org/badge/167837281.svg)](https://zenodo.org/badge/latestdoi/167837281)
<!-- badges: end -->
Access to the Guardian open API <https://open-platform.theguardian.com/>, containing all articles published in the [Guardian](https://www.theguardian.com/) from 1999 to the present. An API key is required, sign up [here](https://open-platform.theguardian.com/access/).
## Installation
`guardianapi` is available on CRAN:
```{r cran-installation, eval = FALSE}
install.packages("guardianapi")
```
You can install the development version `guardianapi` from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("evanodell/guardianapi")
```
## Usage
Save your API key as the environmental variable `GU_API_KEY`, or use the `gu_api_key()` function to set a key for a single session.
`guardianapi` contains functions to query and retrieve articles, tags, editions and sections. For example, return all tags containing the string "apple", which includes both the technology company and Fiona Apple, amongst others.
```{r example1}
library(guardianapi)
tags1 <- gu_tags(query = "apple")
tibble::glimpse(tags1)
```
Return all articles with the string "relationships" and the tag "lifeandstyle/sex" from December 2018:
```{r example2}
relations_sex <- gu_content(query = "relationships", from_date = "2018-12-01",
to_date = "2018-12-31", tag = "lifeandstyle/sex")
tibble::glimpse(relations_sex)
```
See the full package documentation at [docs.evanodell.com/guardianapi](https://docs.evanodell.com/guardianapi).
## Meta
Please note that the 'guardianapi' project is released with a
[Contributor Code of Conduct](https://github.com/evanodell/guardianapi/blob/master/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.
This package is not affiliated with or supported by The Guardian.