Global Fishing Watch API
SDKs

R — gfwr

The gfwr R package accesses API v3 from R and returns results as tibbles for analysis with the tidyverse.

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.

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

Install from R-universe:

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

Or install the development version from GitHub:

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

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

Authentication

Request an API token from the GFW API Portal, then save it to your .Renviron as GFW_TOKEN:

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:

key <- gfw_auth()

Quick start

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.

On this page