cap API allows subscribers to access cap-hpi data using HTTP services. A subscriber needs to use their subscriber id and password to gain access.
The current version is 1. All requests should go through this version unless a new version is released. The version is specified in the API route like this: ShortTermForecast/v1
The API will provide both JSON and XML, based on the Accept header received from the client. JSON will be returned if an Accept header is not provided. All valid requests, with a value of "application/json" or "application/xml" will return the requested format.
All requests must be made over HTTPS, any requests made over HTTP will return an error message.
GET https://services.cap.co.uk/ShortTermForecast/v1/VehicleTypes HTTP/1.1
Host: services.cap.co.uk
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 86
Connection: Close
{
"vehicleTypes":[
{
"typeId": 1,
"description": "Car",
"abbreviation": "CAR"
}
]
}
Fundamental data types are provided as typically expected. A string is wrapped in double quotes, an integer (or int) is provided as a whole number, a double is provided with a decimal place. Non-standard data types are covered in the next section.
A date is provided as a string to the API, but must be provided in the ISO 8601 format for year, month and date (YYYY-MM-DD).
For example, the 21st July 2015 would be represented as a string in the format: 2015-07-21.
Sometimes many values need to be in to the API, and this may need to be done as part of an array.
If these are required, they will be part of a POST request, and will be part of the BODY of the request, and will be made up of the other data types. These will conform to the JSON/XML format of arrays.
The authentication will be token based authentication. The subscriber needs to get a token using their cap subscriber ID and password, then use this token for subsequent calls.
Method | Url |
---|---|
POST | v1/Authentication |
Type | Example |
---|---|
Authorization Header | Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== |
The value of the basic authentication is subscriberId:password encoded in base64 encoding. This is used to generate the token, which is then stored in the database. The username and password is then no longer needed until the token expires, in which the client will need to request another token.
Status | Response |
---|---|
200 |
|
401 |
|
500 |
|
Status | Response |
---|---|
200 |
|
401 |
|
500 |
|
The expiresIn
property of the response is measured in minutes - therefore in the above example the expiry time will be 2 hours. This will expire regardless of usage. Once the token has expired the subscriber will have to request a new token to continue using the API.
You need to send your access token with every request to the API as follow:
Type | Example |
---|---|
Authorization Header | Bearer <accesstoken> |
Returns option values data for a cap ID, mileage, option IDs and pack IDs for a specific registration date. This will return a breakdown of how much all of the options are worth in total, as well how much each individual option is worth, and whether it contributed to the overall value according to the relevant rules.
This endpoint can retrieve values for all cap condition types, however only Clean is available for 13-60 months. This is for cars only.
The option and pack IDs can be retrieved if you are subscribed to the cap NVD Web Service.
Method | Url |
---|---|
POST | OptionValues/v1/Options/{CapId} |
Type | Name | Data Type | Optional |
---|---|---|---|
Authorization | Refer to Using the Access Token | No | |
Body | registrationDate | Date | No |
Body | mileage | int | No |
Body | conditionsRequired | Array of strings. (From "Clean", "Average", "Below" or "Retail") | No |
Body | requiredValuationMonths | Array of ints (0-60) | No |
Body | listOfOptionsIdsToValue | Array of ints | Must have at least one here or in listOfPackIdsToValue |
Body | listOfPackIdsToValue | Array of ints | Must have at least one here or in listOfOptionsIdsToValue |
Status | Response |
---|---|
200 |
Note: This is part of the result. To see the full result please try jsfiddle example
|
400 |
|
401 |
|
500 |
|
Status | Response |
---|---|
200 |
Note: This is part of the result. To see the full result please try jsfiddle example
|
There are a standard set of options available on every request for short term forecast valuations. These are listed below:
Name | Data type | Purpose |
---|---|---|
valuationDate | date | The valuation date of a single short term forecast snapshot. If the date supplied is not an exact match then the closest snapshot before this date will be returned |
monthFrom | int | The number of the month to begin the short term forecast valuations from e.g. if the 1st month of a short term forecast is January and 5 is specified then the valuations returned will start from May onwards |
monthTo | int | The number of the month to begin the short term forecast valuations from e.g. if the 1st month of a short term forecast is January and 10 is specified then the valuations returned will end at October |
mileage | int | Restrict valuations to a single mileage point. If this is not provided then all available mileage points will be returned |
These are all contained in a single parameter and separated by |
. Each option value is a key value pair specified using the following pattern name:value
. For example &options=monthFrom:1|monthTo:6
appended to the request will return the 1st 6 months of valuations.
&options=monthFrom:6|monthTo:2
returns:
{
"optionsError": [
"monthFrom option should be less than monthTo option. monthFrom:6, monthTo:2"
]
}
<version="1.0" standalone="no"?>
<optionsErrors>
<optionsError>monthFrom option should be less than monthTo option. monthFrom:6, monthTo:2</optionsError>
</optionsErrors>
Status | Response |
---|---|
200 |
Note: This is part of the result. To see the full result please try jsfiddle example
|
400 |
|
401 |
|
404 |
|
500 |
|
Status | Response |
---|---|
200 |
Note: This is part of the result. To see the full result please try jsfiddle example
|
400 |
|
401 |
|
404 |
|
500 |
|
Returns short term forecast data for the Vehicle Type ID route, with a cap ID. The vehicle types can be obtained by following the Get Vehicle Types route.
Method | Url |
---|---|
GET | ShortTermForecast/v1/{vehicleTypeId}?{capId}&{options} |
Type | Name | Data Type | Optional |
---|---|---|---|
Authorization | Refer to Using the Access Token | No | |
Query String | capId | int | No |
Query String | options | Refer to Short Term Forecast Options | Yes |
Refer to response
Returns short term forecast data for the Vehicle Type ID route, with cap ID, year and letter (i.e. ‘T’ for a 99 plate or ‘64’ for a 2014 plate). The vehicle types can be obtained by following the Get Vehicle Types route.
Method | Url |
---|---|
GET | ShortTermForecast/v1/{vehicleTypeId}/byYearLetter?{capId}&{year}&{letter}&{options} |
Type | Name | Data Type | Optional |
---|---|---|---|
Authorization | Refer to Using the Access Token | No | |
Query String | capId | int | No |
Query String | year | int | No |
Query String | letter | string | No |
Query String | options | Refer to Short Term Forecast Options | Yes |
Refer to response
Returns short term forecast data for the Vehicle Type ID route, with cap ID, year and month. The vehicle types can be obtained by following the Get Vehicle Types route.
Method | Url |
---|---|
GET | ShortTermForecast/v1/{vehicleTypeId}/byYearMonth?{capId}&{year}&{month}&{options} |
Type | Name | Data Type | Optional |
---|---|---|---|
Authorization | Refer to Using the Access Token | No | |
Query String | capId | int | No |
Query String | year | int | No |
Query String | month | int | No |
Query String | options | Refer to Short Term Forecast Options | Yes |
Refer to response
Returns short term forecast data for the Vehicle Type ID route, with a cap ID for a specific plate sequence number. This will return a valuation for a single plate only. The vehicle types can be obtained by following the Get Vehicle Types route.
The plate sequence number can be retrieved if you are subscribed to the cap DVLA Web Service and lookup a VRM.
Method | Url |
---|---|
GET | ShortTermForecast/v1/{vehicleTypeId}/byPlatedId?{capId}&{plateId}&{options} |
Type | Name | Data Type | Optional |
---|---|---|---|
Authorization | Refer to Using the Access Token | No | |
Query String | capId | int | No |
Query String | plateId | int | No |
Query String | options | Refer to Short Term Forecast Options | Yes |
Refer to response
Returns short term forecast data for the Vehicle Type ID route, with cap Id and vehicle registration date. Get Vehicle Types route.
Method | Url |
---|---|
GET | ShortTermForecast/v1/{vehicleTypeId}/byRegistrationDate?{capId}&{registrationDate}&{options} |
Type | Name | Data Type | Optional |
---|---|---|---|
Authorization | Refer to Using the Access Token | No | |
Query String | capId | int | No |
Query String | registrationDate | date | No |
Query String | options | Refer to Short Term Forecast Options | Yes |
Refer to response
Returns a list of vehicle types
Method | Url |
---|---|
GET | ShortTermForecast/v1/VehicleTypes |
Type | Example |
---|---|
Authorization Header | Please refer to using access token |
Status | Response |
---|---|
200 |
Note: This is part of the result. To see the full result please try jsfiddle example
|
401 |
|
500 |
|
Status | Response |
---|---|
200 |
Note: This is part of the result. To see the full result please try jsfiddle example
|
401 |
|
500 |
|
cap API allows subscribers to access WLTP data using HTTPS services.
The current version is 1
. All requests should go through this version unless a new version is released. The version is specified in the API route like this: /v1
The API will provide JSON, based on the Accept header received from the client. JSON will be returned if an Accept header is not provided. All valid requests, with a value of "application/json" will return the requested format.
All requests must be made over HTTPS, any requests made over HTTP will return an error message.
Fundamental data types are provided as typically expected. A string is wrapped in double quotes, an integer (or int) is provided as a whole number, a double is provided with a decimal place. Non-standard data types are covered in the next section.
A date is provided as a string to the API, but must be provided in the ISO 8601 format for year, month and date (YYYY-MM-DD).
For example, the 21st July 2015 would be represented as a string in the format: 2015-07-21.
Sometimes many values need to be requested from the API, and this may need to be done as part of an array. If these are required, they will be part of a POST
request, and will be part of the BODY of the request and will be made up of the other data types. These will conform to the JSON format of arrays.
This service is used to retrieve WLTP emissions values for a specified vehicle.
To get WLTP data for derivative POST
the values below to the WLTP endpoint:
POST https://api.cap-hpi.co.uk/v1/wltp
[
{
"id": "72f6e102-a2ac-437f-a70c-f2beef736fc0",
"derivativeType": "Car",
"capId": 84106,
"modelYear": "2018",
"selectedEquipmentIds": [
517, 682
]
},
{
"id": "77c5ch05-3d35-4297-9d5b-f721d6a24568",
"derivativeType": "Car",
"capId": 81135,
"modelYear": "2019",
"selectedEquipmentIds": [
444
]
}
]
Name | Type | Mandatory | Description |
---|---|---|---|
Array<derivativeConfiguration> | |||
id | string | false | Unique identifier of the request (if supplied by the requestor will be included in the response) |
derivativeType | enum [ Car, LCV ] | true | Unique identifier of vehicle type |
capId | integer | true | Unique identifier assigned to a vehicle derivative in the Cap system |
modelYear | string | true | Model year identifier |
selectedEquipmentIds | array<integer> | true | List of comma-separated Cap equipment IDs that are applicable to the specified derivative. These should be current and valid options |
{
"auditId": "4097a739-cc87-466d-ac67-3a3ead6fb5a4",
"errors": [],
"wltpData" : [
{
"id": "72f6e102-a2ac-437f-a70c-f2beef736fc0",
"validUntil": "2018-07-19T10:55:19Z",
"examinationDate": "2018-07-18T10:55:19Z",
"derivativeType": "Car",
"capId": 84106,
"modelYear": "2018",
"selectedEquipmentIds": [
517, 682
],
"errors": [],
"technicalSpecificationItems": [
{
"id": 170,
"name": "WLTP - CO2 (g/km) - Combined",
"value": 135
},
{
"id": 181,
"name": "WLTP - MPG - Low Speed",
"value": 39.8
}
]
},
{
"id": "77c5ch05-3d35-4297-9d5b-f721d6a24568",
"validUntil": "2018-07-19T10:55:19Z",
"examinationDate": "2018-07-18T10:55:19Z",
"derivativeType": "Car",
"capId": 81135,
"modelYear": "2019",
"selectedEquipmentIds": [
444
],
"errors": [
{
"id": 10004,
"name": "derivative_not_found",
"message": "The vehicle with specified CAP ID was not found in the new vehicle database."
}
],
"technicalSpecificationItems": []
}
]
}
Name | Type | Mandatory | Description |
---|---|---|---|
auditId | guid | true | Unique transaction ID referencing the associated request (generated by the CAP system) |
id | guid | false | Request identifier that can be set (if supplied by the requester) |
derivativeType | enum [ Car, LCV ] | true | Unique identifier of vehicle type |
capId | integer | true | Unique identifier assigned to a vehicle derivative in the CAP system |
modelYear | string | true | Model year identifier |
selectedEquipmentIds | array<integer> | true | List of comma-separated Cap equipment IDs that are applicable to the specified derivative. These should be current and valid options |
validUntil | date | true | Date when the calculated values would expire |
examinationDate | date | true | Date when the WLTP data is calculated |
errors | Array<Error> | ||
id | integer | optional | Error message identifier |
type | string | optional | Error message label (e.g. Invalid_Vehicle_Configuration) |
message | string | optional | The text of the error message which would be displayed to the user |
technicalSpecificationItems | Array<TechnicalSpecificationItem> | ||
id | integer | true | Code associated to the technical data. |
name | string | true | The description of the data item associated to the code item (e.g. "WLTP – CO2 – Low") |
value | string | true | The value associated with the TechnicalSpecificationItem |
Below is a preview of the open API extract in JSON format prepared for ease of use by development teams:
Click here to download the JSON file.