Package 'caRecall'

Title: Government of Canada Vehicle Recalls Database API Wrapper
Description: Provides API access to the Government of Canada Vehicle Recalls Database <https://tc.api.canada.ca/en/detail?api=VRDB> used by the Defect Investigations and Recalls Division for vehicles, tires, and child car seats. The API wrapper provides access to recall summary information searched using make, model, and year range, as well as detailed recall information searched using recall number.
Authors: Nathan Smith [aut, cre], Mitch Harris [aut], Ryan Koenig [aut]
Maintainer: Nathan Smith <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9000
Built: 2025-03-09 03:26:15 UTC
Source: https://github.com/wraysmith/carecall

Help Index


Count of recalls searching by make or manufacturer

Description

Returns the count of recalls in the Vehicle Recalls Database based on a make or manufacturer search term.

Usage

count_recall_by_make(
  make,
  manufacturer = FALSE,
  start_year = NULL,
  end_year = NULL,
  api_key = NULL
)

Arguments

make

List of make or manufacturer names.

manufacturer

Logical; if TRUE, manufacturer is searched on instead of make.

start_year

Start of year range (optional).

end_year

End of year range (optional).

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by make or manufacturer and returns the count of recalls in the database. The year range of the search can be specified and is based on the manufactured year and not the year a recall occurred.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble providing the count of recalls from the Vehicle Recalls.

Examples

## Not run: 
count_recall_by_make("Nissan")
count_recall_by_make(c("Mazda", "Toyota"), start_year = 2008)
API_KEY <- "xxxxxxxxxxx"
count_recall_by_make("Maz", end_year = 2000, api_key = API_KEY)

## End(Not run)

Count of recalls searching by model

Description

Returns the count of recalls in the Vehicle Recalls Database based on a model search term.

Usage

count_recall_by_model(
  model,
  start_year = NULL,
  end_year = NULL,
  api_key = NULL
)

Arguments

model

List of model names.

start_year

Start of year range (optional).

end_year

End of year range (optional).

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by model and returns the count of recalls in the database. The year range of the search can be specified and is based on the manufactured year and not the year a recall occurred.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble providing the count of recalls from the Vehicle Recalls.

Examples

## Not run: 
count_recall_by_model("civic")
count_recall_by_model(c("Subaru", "Toyota"), start_year = 2008)
API_KEY <- "xxxxxxxxxxx"
count_recall_by_model("Sub", end_year = 2000, api_key = API_KEY)

## End(Not run)

Count of recalls searching by year

Description

Returns the count of recalls in the Vehicle Recalls Database based on a year range search term.

Usage

count_recall_by_years(start_year = 1900, end_year = 2100, api_key = NULL)

Arguments

start_year

Start of year range (optional).

end_year

End of year range (optional).

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by year range and returns the count of recalls in the database. If start_year and/or end_year are not specified, the function will default to the start and/or end years available in the database. Note that the year range is based on the manufactured year and not the year a recall occurred.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble providing the count of recalls from the Vehicle Recalls.

Examples

## Not run: 
count_recall_by_years(2010, 2012)
API_KEY <- "xxxxxxxxxxx"
count_recall_by_years(end_year = 1970, api_key = API_KEY)

## End(Not run)

Retrieves API key from environment

Description

Retrieves API key from environment if available.

Usage

get_vrd_key()

Details

An API key is required to use the functions in caRecall and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here'). Alternatively, instead of setting the API key in the environment, the key can be passed into the functions as an argument.

Value

VRD_API access key if set in environment. If access key is not available, returns an error that the API key is not found and needs to either be set in the environment or passed as an argument into functions.

Examples

## Not run: 
get_vrd_key()

## End(Not run)

Summary of recalls searching by make or manufacturer

Description

Returns summary information of recalls in the Vehicle Recalls Database based on a make or manufacturer search term.

Usage

recall_by_make(
  make,
  manufacturer = FALSE,
  start_year = NULL,
  end_year = NULL,
  limit = 25,
  partial = TRUE,
  api_key = NULL
)

Arguments

make

List of make or manufacturer names. Case insensitive.

manufacturer

Logical; if TRUE, manufacturer is searched on instead of make.

start_year

Start of year range (optional).

end_year

End of year range (optional).

limit

Number indicating how many recall entries should be returned. Defaults to 25 which is the default of the API.

partial

Logical; if TRUE, returns all partial search term matches.

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by make or manufacturer and returns summary recall information. The year range of the search can be specified and is based on the manufactured year and not the year a recall occurred. Partial search term matches can also be returned by the function and is the default. Note that if partial = FALSE is used, the number of entries returned by the function may be less than the count provided by count_recall_by_make which returns a count for all partial matches.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble of recall summary information from the Vehicle Recalls Database. Includes six columns.

Examples

## Not run: 
recall_by_make("Nissan")
recall_by_make(c("Mazda", "Toyota"), start_year = 2008, partial = FALSE)
API_KEY <- "xxxxxxxxxxx"
recall_by_make("Maz", end_year = 2000, limit = 100, api_key = API_KEY)

## End(Not run)

Summary of recalls searching by model

Description

Returns summary information of recalls in the Vehicle Recalls Database based on a model search term.

Usage

recall_by_model(
  model,
  start_year = NULL,
  end_year = NULL,
  limit = 25,
  partial = TRUE,
  api_key = NULL
)

Arguments

model

List of model names.

start_year

Start of year range (optional).

end_year

End of year range (optional).

limit

Number indicating how many recall entries should be returned. Defaults to 25 which is the default of the API.

partial

Logical; if TRUE, returns all partial search term matches.

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by model and returns summary recall information. The year range of the search can be specified and is based on the manufactured year and not the year a recall occurred. Partial search term matches can also be returned by the function and is the default. Note that if partial = FALSE is used, the number of entries returned by the function may be less than the count provided by count_recall_by_model which returns a count for all partial matches.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble of recall summary information from the Vehicle Recalls Database. Includes six columns.

Examples

## Not run: 
recall_by_model("civic")
recall_by_model(c("RANGER RZR 800", "BRZ"), start_year = 2008, partial = FALSE)
API_KEY <- "xxxxxxxxxxx"
recall_by_model("RANGER", end_year = 2000, limit = 100, api_key = API_KEY)

## End(Not run)

Summary of recalls searching by recall number(s)

Description

Returns summary information of recalls in the Vehicle Recalls Database based on recall numbers(s).

Usage

recall_by_number(recall_number, limit = 25, api_key = NULL)

Arguments

recall_number

List of recall numbers.

limit

Number indicating how many recall entries should be returned. Defaults to 25 which is the default of the API.

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by recall number and returns summary recall information.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble of recall summary information from the Vehicle Recalls Database. Includes six columns.

Examples

## Not run: 
recall_by_number(1977044)
API_KEY <- "xxxxxxxxxxx"
recall_by_number(c(2014216, 2013022), api_key = API_KEY)

## End(Not run)

Summary of recalls searching by years

Description

Returns summary information of recalls in the Vehicle Recalls Database based on a year range search term.

Usage

recall_by_years(start_year = 1900, end_year = 2100, limit = 25, api_key = NULL)

Arguments

start_year

Start of year range.

end_year

End of year range.

limit

Number indicating how many recall entries should be returned. Defaults to 25 which is the default of the API.

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by year range and returns summary recall information. If start_year and/or end_year are not specified, the function will default to the start and/or end years available in the database. Note that the year range is based on the manufactured year and not the year a recall occurred.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble of recall summary information from the Vehicle Recalls Database. Includes six columns.

Examples

## Not run: 
recall_by_years(2010, 2012, limit = 100)
API_KEY <- "xxxxxxxxxxx"
recall_by_years(end_year = 1970, api_key = API_KEY)

## End(Not run)

Detailed information on recalls searching by recall number(s)

Description

Returns detailed information on recalls in the Vehicle Recalls Database based on recall numbers(s).

Usage

recall_details(recall_number, api_key = NULL)

Arguments

recall_number

List of recall numbers.

api_key

API access key to use, if not set in environment.

Details

Queries the Vehicle Recalls Database API by recall number and returns detailed recall information for each number. Note that each recall number provided to the function results in a separate API call. Accordingly, the rate of API calls is limited to one call per second to stay within the API limit. For example, providing a list of 60 recall numbers to the function would take approximately 1 minute to complete.

An API key is required to run the function and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.

The API key can be set in the environment using Sys.setenv(VRD_API = 'your_API_key_here') and will be used by the function, or can be passed into the function using the api_key argument.

Value

A tibble of detailed recall information from the Vehicle Recalls Database. Includes 15 columns.

Examples

## Not run: 
recall_details(1977044)
API_KEY <- "xxxxxxxxxxx"
recall_details(c(2014216, 2013022), api_key = API_KEY)

## End(Not run)