## ----include = FALSE----------------------------------------------------------
library(fdic)
no_creds <- no_creds_available()
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  eval = !no_creds
)

## ----eval = no_creds, echo = FALSE, comment = NA------------------------------
message(
  "No FDIC API credentials available. Code chunks will not be evaluated."
)

## ----example-1----------------------------------------------------------------
# # Dropping `description` for example due to length of field
# head(fdic_locations) |>
#   subset(select = -description)

## ----example-2----------------------------------------------------------------
# # Review current endpoint definition
# get_locations(limit = 1) |>
#   names()

## ----example-3----------------------------------------------------------------
# # Search for five active institutions in New York
# # Return all available fields
# get_institutions(
#   filters = "STALP:NY AND ACTIVE:1",
#   limit = 5
# )

## ----example-4----------------------------------------------------------------
# # Collect location data for five branches of a specific institution
# # Return all available fields
# get_locations(
#   filters = "CERT:33124",
#   limit = 5
# )

## ----example-5----------------------------------------------------------------
# # Explore the 2025 Summary of Deposit data for non-community banks in New York
# # Collect the coordinates for the top five branch locations by total deposits
# get_sod(
#   filters = "STALP:NY AND !(CB:1) AND YEAR:2025",
#   fields = c("DEPSUM", "NAMEBR", "SIMS_LATITUDE", "SIMS_LONGITUDE", "YEAR"),
#   sort_by = "DEPSUM",
#   descending = TRUE,
#   limit = 5
# )

