@vepler/sdk
v2.33.0
Published
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@vepler/sdk* API.
Downloads
1,428
Readme
@vepler/sdk
Developer-friendly & type-safe Typescript SDK specifically catered to leverage @vepler/sdk API.
Summary
Vepler Public API: The definitive public API for UK property technology. Access comprehensive property data, listings, planning applications, schools, connectivity scores, and more. Private endpoints (webhooks, admin) are not included in this specification.
Table of Contents
SDK Installation
[!TIP] To finish publishing your SDK to npm and others you must run your first generation action.
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
NPM
npm add <UNSET>PNPM
pnpm add <UNSET>Bun
bun add <UNSET>Yarn
yarn add <UNSET>[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.
Authentication
To use the Vepler SDK, you need an API key. You can obtain one by contacting [email protected].
Once you have your API key, you can initialize the SDK:
import { SDK } from "@vepler/sdk";
const sdk = new SDK({
apiKey: "your-api-key-here",
// Optional: specify a different server URL
serverURL: "https://api.vepler.com",
});For security, we recommend storing your API key in environment variables:
export VEPLER_API_KEY=your-api-key-hereconst sdk = new SDK({
apiKey: process.env.VEPLER_API_KEY,
});Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
SDK Example Usage
Example
import { SDK } from "@vepler/sdk";
const sdk = new SDK({
apiKeyAuth: "vepler_api_YOUR_KEY_HERE",
});
async function run() {
const result = await sdk.address.resolveAddress();
console.log(result);
}
run();
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
| ------------ | ------ | ------- |
| apiKeyAuth | apiKey | API key |
To authenticate with the API the apiKeyAuth parameter must be set when initializing the SDK client instance. For example:
import { SDK } from "@vepler/sdk";
const sdk = new SDK({
apiKeyAuth: "vepler_api_YOUR_KEY_HERE",
});
async function run() {
const result = await sdk.address.resolveAddress();
console.log(result);
}
run();
Available Resources and Operations
Address
- resolveAddress - Resolve addresses to UPRNs with AI
Areas
- getAreas - Get geographic areas by field and IDs
- getAreasWithin - Find areas within a radius of a location
- getBorderingAreas - Find areas that border a target area
- getChildAreas - Get child areas within a parent area
- getCoverage - Calculate geographic coverage
Avm
- getValuationAnalysis - Get detailed valuation analysis
- predictPropertyValue - Predict property value
- predictPropertyValueByLocation - Predict property value by location ID
Connectivity
- getConnectivityScores - Get broadband and mobile connectivity scores
Councils
Epc
- getByLocationId - Get EPC records by location ID
Listings
- getListingById - Get listing by ID
- getListingBySource - Get listing by provider and key
- getListingsByLocation - Get listings by location ID
- queryListings - Query listings with filters
- queryListingsBySource - Query listings by provider and keys
Metrics
- getMetricValues - Get metric values for geographic areas
Planning
- getPlanningApplications - Get planning applications by application IDs
- getPlanningApplicationsBySource - Get planning applications by source IDs
- searchPlanningApplications - Query planning applications with advanced filters
Poi
- getNearestPOI - Find nearest points of interest
- getPOIMultipleTiles - Get POIs from multiple tiles
- getPOITile - Get POIs in a map tile
Property
- aggregateProperties - Aggregate property statistics within a geographic area
- getProperties - Get properties by property IDs
- getPropertiesByLocation - Get properties by location IDs
- getPropertiesBySlugs - Get properties by slugs
- getPropertiesBySource - Get properties by source IDs
- getPropertyTiles - Get property map tiles
- searchProperties - Query properties with advanced filters
Safety
- getV1SafetyCrime - Get crime data near location
- getV1SafetyCrimeStats - Get crime statistics for an area
Schools
- get - Get school by ID
- getBySlug - Get school by slug
- getByUrn - Get school by URN
- getMetrics - Get school metrics
- list - List schools
- listProfiles - List metric profiles
- searchNearby - Search schools near location
- searchWithin - Search schools within bounds
Search
- searchSuggest - Autocomplete search for UK addresses and locations
Streets
- searchStreets - Query streets with flexible identifiers
System
- checkAVMHealth - AVM service health check
- checkAreaReferenceHealth - Area reference service health check
- checkEPCHealth - EPC service health check
- checkListingsHealth - Listings service health check
- checkLocationHealth - Location service health check
- checkPlanningHealth - Planning service health check
- checkPropertyHealth - Property service health check
- checkSearchHealth - Search service health check
Standalone functions
All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
addressResolveAddress- Resolve addresses to UPRNs with AIareasGetAreas- Get geographic areas by field and IDsareasGetAreasWithin- Find areas within a radius of a locationareasGetBorderingAreas- Find areas that border a target areaareasGetChildAreas- Get child areas within a parent areaareasGetCoverage- Calculate geographic coverageavmGetValuationAnalysis- Get detailed valuation analysisavmPredictPropertyValue- Predict property valueavmPredictPropertyValueByLocation- Predict property value by location IDconnectivityGetConnectivityScores- Get broadband and mobile connectivity scorescouncilsGet- Get council by provider IDcouncilsList- List councilsepcGetByLocationId- Get EPC records by location IDlistingsGetListingById- Get listing by IDlistingsGetListingBySource- Get listing by provider and keylistingsGetListingsByLocation- Get listings by location IDlistingsQueryListings- Query listings with filterslistingsQueryListingsBySource- Query listings by provider and keysmetricsGetMetricValues- Get metric values for geographic areasplanningGetPlanningApplications- Get planning applications by application IDsplanningGetPlanningApplicationsBySource- Get planning applications by source IDsplanningSearchPlanningApplications- Query planning applications with advanced filterspoiGetNearestPOI- Find nearest points of interestpoiGetPOIMultipleTiles- Get POIs from multiple tilespoiGetPOITile- Get POIs in a map tilepropertyAggregateProperties- Aggregate property statistics within a geographic areapropertyGetProperties- Get properties by property IDspropertyGetPropertiesByLocation- Get properties by location IDspropertyGetPropertiesBySlugs- Get properties by slugspropertyGetPropertiesBySource- Get properties by source IDspropertyGetPropertyTiles- Get property map tilespropertySearchProperties- Query properties with advanced filterssafetyGetV1SafetyCrime- Get crime data near locationsafetyGetV1SafetyCrimeStats- Get crime statistics for an areaschoolsGet- Get school by IDschoolsGetBySlug- Get school by slugschoolsGetByUrn- Get school by URNschoolsGetMetrics- Get school metricsschoolsList- List schoolsschoolsListProfiles- List metric profilesschoolsSearchNearby- Search schools near locationschoolsSearchWithin- Search schools within boundssearchSearchSuggest- Autocomplete search for UK addresses and locationsstreetsSearchStreets- Query streets with flexible identifierssystemCheckAreaReferenceHealth- Area reference service health checksystemCheckAVMHealth- AVM service health checksystemCheckEPCHealth- EPC service health checksystemCheckListingsHealth- Listings service health checksystemCheckLocationHealth- Location service health checksystemCheckPlanningHealth- Planning service health checksystemCheckPropertyHealth- Property service health checksystemCheckSearchHealth- Search service health check
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { SDK } from "@vepler/sdk";
const sdk = new SDK({
apiKeyAuth: "vepler_api_YOUR_KEY_HERE",
});
async function run() {
const result = await sdk.address.resolveAddress({
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { SDK } from "@vepler/sdk";
const sdk = new SDK({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
apiKeyAuth: "vepler_api_YOUR_KEY_HERE",
});
async function run() {
const result = await sdk.address.resolveAddress();
console.log(result);
}
run();
Error Handling
SDKBaseError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| error.message | string | Error message |
| error.statusCode | number | HTTP response status code eg 404 |
| error.headers | Headers | HTTP response headers |
| error.body | string | HTTP body. Can be empty string if no body is returned. |
| error.rawResponse | Response | Raw HTTP response |
| error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |
Example
import { SDK } from "@vepler/sdk";
import * as errors from "@vepler/sdk/sdk/models/errors";
const sdk = new SDK({
apiKeyAuth: "vepler_api_YOUR_KEY_HERE",
});
async function run() {
try {
const result = await sdk.address.resolveAddress();
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.SDKBaseError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);
// Depending on the method different errors may be thrown
if (error instanceof errors.ResolveAddressResponseBody) {
console.log(error.data$.error); // string
console.log(error.data$.statusCode); // number
console.log(error.data$.success); // boolean
}
}
}
}
run();
Error Classes
Primary error:
SDKBaseError: The base class for HTTP error responses.
Network errors:
ConnectionError: HTTP client was unable to make a request to a server.RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.RequestAbortedError: HTTP request was aborted by the client.InvalidRequestError: Any input used to create a request is invalid.UnexpectedClientError: Unrecognised or unexpected error.
Inherit from SDKBaseError:
CouncilErrorResponse: Applicable to 2 of 52 methods.*ResolveAddressResponseBody: Invalid request parameters. Status code400. Applicable to 1 of 52 methods.*GetAreasByFieldAndIdsResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetAreasWithinRadiusResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetBorderingAreasResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetChildAreasResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetAreaCoverageResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetConnectivityScoresResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetMetricValuesResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetNearestPOIResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetPOIMultipleTilesResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetPOITileResponseBody: Error response format for failed requests. Status code400. Applicable to 1 of 52 methods.*GetValuationAnalysisResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*PredictPropertyValueResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*PredictPropertyValueByLocationResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetEpcByLocationIdResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*QueryListingsResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*QueryListingsBySourceResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*SearchStreetsResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPlanningApplicationsResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPlanningApplicationsBySourceResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*SearchPlanningApplicationsResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*AggregatePropertiesResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPropertiesResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPropertiesByLocationResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPropertiesBySlugsResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPropertiesBySourceResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetPropertyTilesResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*SearchPropertiesResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*GetV1SafetyCrimeResponseBody: Invalid parameters. Status code400. Applicable to 1 of 52 methods.*GetV1SafetyCrimeStatsResponseBody: Invalid parameters. Status code400. Applicable to 1 of 52 methods.*GetSchoolMetricsResponseBody: Error response structure. Status code400. Applicable to 1 of 52 methods.*SearchSuggestResponseBody: Error response. Status code400. Applicable to 1 of 52 methods.*ResolveAddressAddressResponseBody: Unauthorized - Invalid or missing API key. Status code401. Applicable to 1 of 52 methods.*SearchStreetsStreetsResponseBody: Error response. Status code401. Applicable to 1 of 52 methods.*GetAreaCoverageAreasResponseBody: Error response format for failed requests. Status code404. Applicable to 1 of 52 methods.*GetValuationAnalysisAVMResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*PredictPropertyValueByLocationAVMResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*GetListingByIdResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*GetListingBySourceResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*GetSchoolByIdResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*GetSchoolBySlugResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*GetSchoolByUrnResponseBody: Error response. Status code404. Applicable to 1 of 52 methods.*GetValuationAnalysisAVMResponseResponseBody: Error response. Status code422. Applicable to 1 of 52 methods.*PredictPropertyValueAVMResponseBody: Error response. Status code422. Applicable to 1 of 52 methods.*PredictPropertyValueByLocationAVMResponseResponseBody: Error response. Status code422. Applicable to 1 of 52 methods.*ResolveAddressAddressResponseResponseBody: Internal server error. Status code500. Applicable to 1 of 52 methods.*GetAreasByFieldAndIdsAreasResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetAreasWithinRadiusAreasResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetBorderingAreasAreasResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetChildAreasAreasResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetAreaCoverageAreasResponseResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetConnectivityScoresConnectivityResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetMetricValuesMetricsResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetNearestPOIPOIResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetPOIMultipleTilesPOIResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetPOITilePOIResponseBody: Error response format for failed requests. Status code500. Applicable to 1 of 52 methods.*GetValuationAnalysisAVMResponse500ResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*PredictPropertyValueAVMResponseResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*PredictPropertyValueByLocationAVMResponse500ResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetEPCByLocationIdEPCResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetListingByIdListingsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetListingBySourceListingsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetListingsByLocationResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*QueryListingsListingsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*QueryListingsBySourceListingsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*SearchStreetsStreetsResponseResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPlanningApplicationsPlanningResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPlanningApplicationsBySourcePlanningResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*SearchPlanningApplicationsPlanningResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*AggregatePropertiesPropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPropertiesPropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPropertiesByLocationPropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPropertiesBySlugsPropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPropertiesBySourcePropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetPropertyTilesPropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*SearchPropertiesPropertyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetV1SafetyCrimeSafetyResponseBody: Internal server error. Status code500. Applicable to 1 of 52 methods.*GetV1SafetyCrimeStatsSafetyResponseBody: Internal server error. Status code500. Applicable to 1 of 52 methods.*GetSchoolByIdSchoolsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetSchoolBySlugSchoolsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetSchoolByUrnSchoolsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*GetSchoolMetricsSchoolsResponseBody: Error response structure. Status code500. Applicable to 1 of 52 methods.*ListSchoolsResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*SearchSchoolsNearbyResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*SearchSchoolsWithinResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*SearchSuggestSearchResponseBody: Error response. Status code500. Applicable to 1 of 52 methods.*ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValuefor the raw value anderror.pretty()for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:
import { SDK } from "@vepler/sdk";
const sdk = new SDK({
serverURL: "https://api.vepler.com",
apiKeyAuth: "vepler_api_YOUR_KEY_HERE",
});
async function run() {
const result = await sdk.address.resolveAddress();
console.log(result);
}
run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:
import { SDK } from "@vepler/sdk";
import { HTTPClient } from "@vepler/sdk/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new SDK({ httpClient: httpClient });Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console's interface as an SDK option.
[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
import { SDK } from "@vepler/sdk";
const sdk = new SDK({ debugLogger: console });Testing
For local testing, use the provided test script:
# Set your API key
export VEPLER_API_KEY=your-api-key-here
# Run the test script
bun run test-local.tsThe test script will verify:
- API connectivity
- Authentication
- Basic CRUD operations
- Error handling
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
