An open API service indexing awesome lists of open source software.

https://github.com/tylerlittlefield/blizz

:snowflake: Minimalistic client to access Blizzard’s API in R
https://github.com/tylerlittlefield/blizz

api blizzard games r rstats

Last synced: 7 days ago
JSON representation

:snowflake: Minimalistic client to access Blizzard’s API in R

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# blizz

[![Travis build status](https://travis-ci.org/tyluRp/blizz.svg?branch=master)](https://travis-ci.org/tyluRp/blizz)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/tyluRp/blizz?branch=master&svg=true)](https://ci.appveyor.com/project/tyluRp/blizz)
[![Codecov test coverage](https://codecov.io/gh/tyluRp/blizz/branch/master/graph/badge.svg)](https://codecov.io/gh/tyluRp/blizz?branch=master)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)

```{r, echo=FALSE}
knitr::include_graphics("man/figures/Nagrand_Concept_Art_Peter_Lee_1.jpg")
```

Minimalistic client to access [Blizzards API](https://develop.battle.net/).

## Installation

You can install from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("tyluRp/blizz")
```

## Additional Setup

You need to create a developer account at Blizzard's [**dev portal**](https://develop.battle.net/). Once you've created an account, a client needs to be made. Creating a client will produce a **Client ID** and **Client Secret**. With these credentials you can run:

```r
# replace ID/SECRET with your own
blizz_auth("ID", "SECRET")
```

After this, you're all set.

If you want to avoid using `blizz_auth()`, you can obtain the Client ID, Secret, and Token by following the [docs](https://develop.battle.net/documentation/guides/getting-started). Then edit the `.Renviron` file manually and supply the credentials like so:

```r
BLIZZARD_CLIENT_ID='your ID'
BLIZZARD_CLIENT_SECRET='your secret'
BLIZZARD_AUTH_TOKEN='your token'
```

Note: Blizzard's authentication tokens expire after 24 hours. To avoid having to refresh the token everyday, `blizz` runs the following command everytime the library is loaded:

```r
blizz_auth(refresh = TRUE)
```

This will remove the expired token from your `.Renviron` and add the fresh token to it. More info on how to get started can be found in [**this**](https://blizz.netlify.com/articles/auth.html) vignette.

## Example

Use the `blizz()` function to access all API endpoints. Note that the leading slash must be included as well:

```{r example1}
library(blizz)

blizz("/d3/data/act/1")
```

Additionally, we can print the response as JSON thanks to the [`jsonlite`](https://github.com/jeroen/jsonlite) package:

```{r example2}
blizz("/d3/data/act/1", json = TRUE)
```

## Acknowledgements

* [Blizzard](https://develop.battle.net/): API
* [Peter Lee](https://www.artstation.com/peterconcept): Nagrand concept art
* [Jeroen Ooms](https://github.com/jeroen): `jsonlite` package
* [r-lib](https://github.com/r-lib): `httr` package