build_api_url: Create an API call to send to api.census.gov

View source: R/build_api_url.R

build_api_urlR Documentation

Create an API call to send to api.census.gov

Description

Create an API call to send to api.census.gov

Usage

build_api_url(
  variables,
  for_geo,
  for_items,
  survey_type,
  table_or_survey_code,
  year,
  ...,
  use_key = TRUE
)

Arguments

variables

<chr[]> a vector of variable names, like "B01001_001E"

for_geo

<chr> the geographical level the data will describe, e.g. "tract"

for_items

<chr[]> one or more instances of for_geo desired, e.g. "*" or "000200", passed on to build_for_geographies()

survey_type

e.g. "acs" or "dec"

table_or_survey_code

e.g. "acs5" or "pl"

year

an integer year, e.g. 2021L

...

<dynamic dots> other items to pass to the query

use_key

<lgl?> optional, should the query include a Census API key from the system environment. Defaults to TRUE

Value

one URL, as a string

Examples

hercacstables:::build_api_url(paste0("B25003_00", 1:3, "E"),
                              "tract",
                              "*",
                              "acs",
                              "acs5",
                              2020L,
                              state = 55L,
                              county = 101L,
                              use_key = FALSE)

hercacstables:::build_api_url(paste0("P1_00", c(1, 3, 4), "N"),
                              "tract",
                              "*",
                              "dec",
                              "pl",
                              2020L,
                              state = 55L,
                              county = 101L,
                              use_key = FALSE)

higherX4Racine/hercacstables documentation built on Jan. 15, 2025, 9:58 p.m.