Minimalistic client to access Blizzards API.
You can install from GitHub with:
You need to create a developer account at Blizzard’s dev portal. 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:
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. Then edit the .Renviron
file manually and supply the credentials like so:
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:
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 vignette.
Use the blizz()
function to access all API endpoints. Note that the leading slash must be included as well:
library(blizz)
blizz("/d3/data/act/1")
#> ✔ Request: https://us.api.blizzard.com/d3/data/act/1
#> ✔ Status: 200
#> ✔ Content-Type: application/json;charset=UTF-8
#> $slug
#> [1] "act-i"
#>
#> $number
#> [1] 1
#>
#> $name
#> [1] "Act I"
#>
#> $quests
#> id name slug
#> 1 87700 The Fallen Star the-fallen-star
#> 2 72095 The Legacy of Cain the-legacy-of-cain
#> 3 72221 A Shattered Crown a-shattered-crown
#> 4 72061 Reign of the Black King reign-of-the-black-king
#> 5 117779 Sword of the Stranger sword-of-the-stranger
#> 6 72738 The Broken Blade the-broken-blade
#> 7 73236 The Doom in Wortham the-doom-in-wortham
#> 8 72546 Trailing the Coven trailing-the-coven
#> 9 72801 The Imprisoned Angel the-imprisoned-angel
#> 10 136656 Return to New Tristram return-to-new-tristram
Additionally, we can print the response as JSON thanks to the jsonlite
package:
blizz("/d3/data/act/1", json = TRUE)
#> ✔ Request: https://us.api.blizzard.com/d3/data/act/1
#> ✔ Status: 200
#> ✔ Content-Type: application/json;charset=UTF-8
#> {
#> "slug": ["act-i"],
#> "number": [1],
#> "name": ["Act I"],
#> "quests": [
#> {
#> "id": [87700],
#> "name": ["The Fallen Star"],
#> "slug": ["the-fallen-star"]
#> },
#> {
#> "id": [72095],
#> "name": ["The Legacy of Cain"],
#> "slug": ["the-legacy-of-cain"]
#> },
#> {
#> "id": [72221],
#> "name": ["A Shattered Crown"],
#> "slug": ["a-shattered-crown"]
#> },
#> {
#> "id": [72061],
#> "name": ["Reign of the Black King"],
#> "slug": ["reign-of-the-black-king"]
#> },
#> {
#> "id": [117779],
#> "name": ["Sword of the Stranger"],
#> "slug": ["sword-of-the-stranger"]
#> },
#> {
#> "id": [72738],
#> "name": ["The Broken Blade"],
#> "slug": ["the-broken-blade"]
#> },
#> {
#> "id": [73236],
#> "name": ["The Doom in Wortham"],
#> "slug": ["the-doom-in-wortham"]
#> },
#> {
#> "id": [72546],
#> "name": ["Trailing the Coven"],
#> "slug": ["trailing-the-coven"]
#> },
#> {
#> "id": [72801],
#> "name": ["The Imprisoned Angel"],
#> "slug": ["the-imprisoned-angel"]
#> },
#> {
#> "id": [136656],
#> "name": ["Return to New Tristram"],
#> "slug": ["return-to-new-tristram"]
#> }
#> ]
#> }
jsonlite
package