---
title: "Using Fryzigg API"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using Fryzigg API}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
not_cran = identical(Sys.getenv("NOT_CRAN"), "true")
online <- !is.null(curl::nslookup("r-project.org", error = FALSE))
eval_param <- not_cran & online

knitr::opts_chunk$set(
	eval = eval_param,
	message = FALSE,
	warning = FALSE,
	collapse = TRUE,
	comment = "#>"
)

library(fitzRoy)
library(dplyr)


dat <- fitzRoy:::stats_fryzigg_2019
```


## Overview
We have included a function to interface with the Fryzigg API. This data set includes advanced AFL stats that are typically not available on existing open data sites such as footywire.com and afltables.com. Many thanks to [Fryzigg](https://github.com/Fryzigg) on providing this API interface. 

### Getting Data

The primary way to access the data is via the `fetch_fryzigg_stats()` function. This function provides an easy interface to the Fryzigg API. It takes one arguments - `season` which can be a single year or multiple years.

```{r results, eval=FALSE, include=TRUE}
dat <- fitzRoy::fetch_player_stats_fryzigg(2019)
```

We can get a quick view the the fields returned from the `fryzigg` API. 

```{r results2, eval=eval_param}
dplyr::glimpse(dat)
```

You can see the data includes both player and team data, where each row is a game by a player. 

```{r results3, eval=eval_param}
head(dat)
```

