safegraph_api.Rd
THIS FUNCTION IS NOT YET FULLY OPERATIONAL AND WILL ONLY WORK FOR PLACEKEY CALLS
safegraph_api(
key,
placekeys = NULL,
location = NULL,
search = NULL,
first = 10,
after = NULL,
dataset = "core",
date = NULL,
select = NULL,
batch = FALSE,
display_call = FALSE,
...
)
A character string containing an API Access Key. See https://docs.safegraph.com/reference/access-and-authentication to get one.
A character vector of Placekeys to look up data with. If this is more than 20 Placekeys long, batching will be performed automatically as long as batch = TRUE
. Cannot be longer than 1000 entries. Exactly one of placekeys
, address
, or search
must be specified.
A named vector of location data, or one-row data.frame
with appropriately-named columns, that specifies a single place of interest to look up data for. Available location variable names, and the different combinations that uniquely identify a single location, are available at https://docs.safegraph.com/reference/lookup-name-address. Exactly one of placekeys
, address
, or search
must be specified.
A named list of filter settings that specifies a set of filter criteria for the SafeGraph POIs. Data will be returned for the first first
matches.
If using search
, return only the first first
matches found. If set to any number above 20
, batching will be performed automatically if batch = TRUE
. Will not accept a value above 1000
.
If using search
, skip the first after
matches before returning the next first
matches.
The SafeGraph response dataset(s) to get from. Can be 'core'
for the SafeGraph Core data, 'geometry'
for geometry files, or 'weekly_patterns'
or 'monthly_patterns'
for weekly/monthly patterns data. Weekly patterns data will be the week of your choosing; monthly patterns data will always be the most recent month. Or, if using the location
or search
options, set to 'placekey'
to return only the Placekeys and not actual data (note you'll get the Placekeys anyway with all the other options). Defaults to 'weekly_patterns'
. See https://docs.safegraph.com/reference/safegraph-response-datasets for more information.
If dataset = 'weekly_patterns'
, this option is required. A string in 'YYYY-MM-DD'
format specifying the week of data you want. Can be any day in that week. The start_date
and end_date
variant currently not supported.
A character vector with the names of the variables you want returned. Defaults to all variables in the dataset. For the list of variables in each dataset
, see the "Response Objects" section on https://docs.safegraph.com/reference/safegraph-response-datasets. For variables like brands
, which has sub-variables brand_id
and brand_name
, putting brands
will get all the sub-variables, or you can just get the sub-variables by themselves.
Set to TRUE
to allow for batching of results if there are more than 20 POIs being returned. Batching may be quite slow if there are a lot of matches! See the rate limiting in the Placekey API docs. Also note the 1000-per-minute rate limit, so if you decide to run multiple of your own large safegraph_api
calls you may want to space them out.
Set to TRUE
to print out the API call.
Currently unused
This function will allow you to make API requests of the SafeGraph API. See the documentation for the Places API here: https://docs.safegraph.com/docs/places-api.
if (FALSE) {
# You can look up data for individual placekeys
mydat = safegraph_api('MY API KEY', placekeys = "222-223@5x4-4b6-mff", select = 'open_hours')
# Or a vector of them
# For specific addresses
address = list('location_name' = "Taco Bell",'street_address' = "710 3rd St", 'city'="San Francisco",'region' = "CA", 'iso_country_code' = "US")
mydat = safegraph_api('MY API KEY', location= address, select = 'open_hours')
# Or for (a subset of) POIs that match a search
search <- list('city' = 'San Francisco', 'brand' = 'Starbucks')
mydat = safegraph_api('MY API KEY', search = search, select = 'raw_visit_counts',
dataset = 'weekly_patterns', date = '2021-01-01')
}