Important: This documentation applies to v2 of this package.
For v3 docs see vpic.shaggytech.com

Module

api/Fetch

API Fetch Logic.

Module Exports:

Types

View Source api/Fetch.ts, line 2

Classes

Fetch

Members

string

# inner constant BASE_URL

Default Fetch base URL string

Default Value:
  • 'https://vpic.nhtsa.dot.gov/api/vehicles'

View Source api/Fetch.ts, line 27

module:api/Fetch.FetchConfig

# inner constant DEFAULT_CONFIG

Default Fetch configuration options

Properties:
Name Type Default Description
apiResponseFormat string json
baseUrl string BASE_URL

Default: BASE_URL

options FetchRequestOptions {method:"GET"}

View Source api/Fetch.ts, line 32

Type Definitions

object

# ApiResponse

Complete response returned by module:api/Fetch.Fetch#get.

Properties:
Name Type Description
Count number

The number of items returned in the Results object.

Message string

A message describing the Results.

SearchCriteria string

Search terms (VIN, WMI, etc) used in the request URL.

Results Array.<any>

An array of Results returned by NHSTA, specific to each individual API Action.

FetchResponse FetchResponse

Fetch API Response Properties.

See:
  • module:api/Fetch.NhtsaResponse
  • module:api/Fetch.FetchResponse

View Source api/Fetch.ts, line 211

object

# FetchConfig

Used when instantiating a Fetch class or related subclass.

Properties:
Name Type Attributes Description
apiResponseFormat string <optional>

Requested response format from the NHSTA API (hardcoded to 'json' for now).

baseUrl string <optional>

Base of the URL to build fetch URLs from.

options FetchRequestOptions <optional>

Options object provided as the 2nd argument to module:api/Fetch.Fetch#get.

View Source api/Fetch.ts, line 177

object

# FetchRequestOptions

Options object provided as the 2nd argument to module:api/Fetch.Fetch#get.

Properties:
Name Type Attributes Description
method string <optional>

HTTP request method - Default: "GET".

body string | FetchRequestBodyTypes <optional>

HTTP request body - FetchRequestBodyTypes.

headers Record.<string, string> | Headers <optional>

Object, Headers - Default: {}.

credentials 'omit' | 'same-origin' | 'include' <optional>

Default: "omit" - Authentication credentials mode.,

  • "omit" - don't include authentication credentials (e.g. Cookies) in the request.,
  • "same-origin" - include credentials in requests to the same site,
  • "include" - include credentials in requests to all sites.

View Source api/Fetch.ts, line 163

object

# FetchResponse

Fetch API Response properties.

Properties:
Name Type Description
headers Headers

The Headers object associated with the response.

ok boolean

A boolean indicating whether the response was successful (status in the range 200–299) or not.

redirected boolean

Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry).

status number

The status code of the response. (This will be 200 for a success).

statusText string

The status message corresponding to the status code. (e.g., OK for 200).

url string

The URL of the response.

View Source api/Fetch.ts, line 187

object

# NhtsaResponse

Response data returned from the NHSTA API.

Properties:
Name Type Description
Count number

The number of items returned in the Results object.

Message string

A message describing the Results.

SearchCriteria string

Search terms (VIN, WMI, etc) used in the request URL.

Results Array.<any>

An array of Results returned by NHSTA, specific to each individual API Action.

View Source api/Fetch.ts, line 200