# R — gfwr (/docs/sdks/gfwr)



The `gfwr` R package provides access to Global Fishing Watch API v3 from R, returning results as tibbles for analysis with the tidyverse.

The current version of `gfwr` uses API v3. This update includes significant changes to parameter names and output formats compared to earlier versions. For a comprehensive list of changes and migration details, see the [change log](https://globalfishingwatch.github.io/gfwr/news/index.html).

## Overview of changes [#overview-of-changes]

* Updated endpoints, retaining those from v1.1.0.
* New endpoint helpers such as `gfw_event_stats()`.
* Note: Some APIs, primarily designed for frontend applications, were not implemented.

## Installation [#installation]

Install from R-universe:

```r
install.packages("gfwr",
                 repos = c("https://globalfishingwatch.r-universe.dev",
                           "https://cran.r-project.org"))
```

Or install the development version from GitHub:

```r
if (!require("remotes"))
  install.packages("remotes")

remotes::install_github("GlobalFishingWatch/gfwr",
                        dependencies = TRUE)
```

## Authentication [#authentication]

Request an API token from the [GFW API Portal](https://globalfishingwatch.org/our-apis/tokens), then save it to your `.Renviron` as `GFW_TOKEN`:

```r
usethis::edit_r_environ()
# add the following line, then restart your R session:
# GFW_TOKEN="PASTE_YOUR_TOKEN_HERE"
```

`gfwr` reads the token automatically. You can also retrieve it explicitly:

```r
key <- gfw_auth()
```

## Quick start [#quick-start]

```r
library(gfwr)

# Vessel search by MMSI
gfw_vessel_info(query = 224224000,
                search_type = "search")

# Encounter events for a date range
gfw_event(event_type = "ENCOUNTER",
          start_date = "2020-01-01",
          end_date = "2020-01-02")
```

To learn more, visit the [GitHub gfwr official page](https://globalfishingwatch.github.io/gfwr/).
