JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 32
  • Score
    100M100P100Q77409F
  • License Apache-2.0

Type-safe TypeScript SDK for BCIS APIs

Package Exports

  • @bcis/sdk

Readme

@bcis/sdk

Type-safe TypeScript SDK for the BCIS (Building Cost Information Service) APIs. Supports both ESM and CommonJS environments with full TypeScript declarations.


Installation

npm install @bcis/sdk

Authentication

All BCIS APIs require a Bearer JWT obtained via OAuth2. The AuthManager class handles token acquisition, caching, and renewal automatically.

Client Credentials (server-to-server)

Use this flow for back-end or machine-to-machine integrations. Tokens are fetched and renewed automatically — no user interaction required.

import { AuthManager, CoreApiClient, DurationCalculatorClient, ResidentialRebuildClient, ScheduleOfRatesClient } from '@bcis/sdk';

const auth = new AuthManager({
  flow: 'client-credentials',
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  // scopes: ['openid'],  // optional
});

OAuth2 endpoints are resolved automatically via OpenID Connect discovery (see Custom endpoints below).

Authorization Code + PKCE (user-facing applications)

Use this flow when your application acts on behalf of a logged-in user.

import { AuthManager } from '@bcis/sdk';

const auth = new AuthManager({
  flow: 'authorization-code',
  clientId: 'YOUR_CLIENT_ID',
  redirectUri: 'https://yourapp.com/callback',
  scopes: ['openid', 'profile'],
});

// Step 1 — redirect the user
const { url, codeVerifier } = await auth.getAuthorizationUrl();
// persist codeVerifier (e.g. in session), then redirect browser to url

// Step 2 — handle the callback (after user authenticates)
await auth.handleCallback(code, codeVerifier);

// Step 3 — the SDK will now attach the token to every request automatically

Custom OAuth2 endpoints

By default the SDK fetches tokenUrl and authorizationUrl from the BCIS OpenID Connect discovery document at https://id.bcis.co.uk/.well-known/openid-configuration. The result is cached in memory for the lifetime of the process.

You can override individual URLs or point to a different discovery document:

const auth = new AuthManager({
  flow: 'client-credentials',
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',

  // Option A — supply a custom discovery URL (e.g. staging):
  discoveryUrl: 'https://id.staging.bcis.co.uk/.well-known/openid-configuration',

  // Option B — provide endpoint URLs directly (skips discovery entirely):
  tokenUrl: 'https://id.bcis.co.uk/oauth/token',
});

Available Clients

CoreApiClient

Base URL: https://api.bcis.co.uk/core-apis

Core APIs Documentation

Instantiation:

import { AuthManager, CoreApiClient } from '@bcis/sdk';

const client = new CoreApiClient(auth);

// Override the base URL (e.g. for a staging environment):
// const client = new CoreApiClient(auth, { baseUrl: 'https://api.bcis.co.uk/core-apis' });

Methods:

abpRetrieve(params: AbpRetrieveParams): Promise<AbpResponseDto>

Returns results from one of the BCIS Average prices studies

Parameter Type Required Description
include-data-for-graph boolean When true, returns additional data for graph plotting. Default false.
include-subclasses boolean When true, includes sub-divided categories (e.g., size bands) in results. Default false.
building-function string[] A comma-separated list of building function codes used to filter study results. [See the Codes Update API](/docs/bcis-gr
type-of-work string[] A list of type of work codes to filter the results by, the example contains all valid codes.
abp-study 'ABPBUI' | 'ABPFUN' | 'ABPGRP' | 'ABPEM2' | 'ABPEUR' | 'ABPEXT' A six-character code identifying the BCIS study

indicesRetrieve(params: IndicesRetrieveParams): Promise<IndicesResponseDto>

Returns index figures from one or more index series

Parameter Type Required Description
base-of-series string Restricts the index series by year e.g. 1985 or description 1985 mean = 100. Ignored if a series number is provided.
regularity string[] Restricts index series by regularity (monthly, quarterly, annual). Ignored if a series number is used. Defaults
end-date string Restricts index figures up to a specific month yyyy-mm, or leave blank for latest available.
start-date string Restricts index figures to a specific month yyyy-mm, or leave blank for earliest available.
series-identification string[] Comma-delimited list of short names (e.g. BCISTPI:AllIn) or series numbers. [See the Codes Update API](/docs/bcis-grac

tpsRetrieve(params: TpsRetrieveParams): Promise<TpsResponseDto>

Returns results from one of the BCIS Average prices studies

Parameter Type Required Description
short-tps-name string Supports suffixes to filter or refine the study data: - Level Filters: - :region, :county, :district

codesUpdate(params: CodesUpdateParams): Promise<CodesResponseDto>

Returns codes lists or other supporting data

Parameter Type Required Description
if-changed-since string A date in yyyy-mm-dd format. Returns only codes added or modified since this date. Not supported for all code types. L
version string A version string to select relevant code tables.
code-type 'shortTPSName' | 'ABPStudy' | 'BuildingFunction' | 'BuildingFunction:Categories' | 'BuildingFunction:[1-9]' | 'BuildingFunction:Duration' | 'BuildingFunction:Duration:Categories' | 'BuildingFunction:Duration:[1-9]' | 'BuildingFunction:ABP' | 'SimplifiedTypeOfWork' A string to select the code list required. The supported values are: - seriesIdentification: All regularity name

DurationCalculatorClient

Base URL: https://api.bcis.co.uk/rebuild-core

Duration calculator API Documentation

Instantiation:

import { AuthManager, DurationCalculatorClient } from '@bcis/sdk';

const client = new DurationCalculatorClient(auth);

// Override the base URL (e.g. for a staging environment):
// const client = new DurationCalculatorClient(auth, { baseUrl: 'https://api.bcis.co.uk/rebuild-core' });

Methods:

getModels(params: GetModelsParams): Promise<DurationModelsDto>

This endpoint provides a list of models, quarters, and locations. Parameters from these lists will be used to perform duration calculations.

Parameter Type Required Description
publication-date string The date of the publication in YYYY-MM-DD format. Can be used to reproduce a calculation as it would have been performed

getOptions(params: GetOptionsParams): Promise<DurationModelOptionsDto>

This endpoint provides a list of: building functions, procurements, selection of contractor, and client organisations. Parameters from these lists will be used to perform duration calculations.

Parameter Type Required Description
model-id number There are two separate models that underlie the calculator: one for new build projects and one for refurbishment schemes

calculateDuration(params: CalculateDurationParams): Promise<CalculationResultDto>

This endpoint provides the calculated construction duration based on the minimal details that might be available at the feasibility stage of a construction project. For each estimate we provide two interval measures:

  • Confidence interval: quantifies the uncertainty around the estimated mean duration. It gives a range that is likely to contain the true mean duration for projects with the same predictor values.
  • Prediction interval: quantifies the likely range of outcomes for an individual project. It is wider than the confidence interval because it accounts both for uncertainty in the mean estimate and for the natural variability between individual projects. Example: a CI of 5–13 weeks means the expected mean is likely in that range; a PI of 3–20 weeks means an individual project's duration is likely to fall somewhere in that wider range.
Parameter Type Required Description
publication-date string The date on which the project details are published. Can be used to reproduce a calculation as it would have been perfor
organisation-id number The appropriate sector for the client organisation
contractor-selection-id number The selection of contractor that best describes the way in which the contractor will be selected.
procurement-id number The procurement process that best describes the way in which the project will be procured.
function-group-id number The building function of the project. It is based on groups of building functions rather than the full list of building
location-id number The location of the project. Is used to adjust the contract value to UK mean location.
date-applicable string The quarter at which the contract value has been priced. Is used to adjust the contract value to the base price level us
contract-value number The anticipated cost of construction expressed as at the anticipated start on site.
model-id number There are two separate models that underlie the calculator: one for new build projects and one for refurbishment schemes

ResidentialRebuildClient

Base URL: https://api.bcis.co.uk/residential-rebuild-calculator

The BCIS Rebuild Lookup Service calculates the reinstatement cost of a house or flat using minimal information. The target audience includes insurance companies and brokers that require rebuilding costs when quoting a policy on a website or using software.

Instantiation:

import { AuthManager, ResidentialRebuildClient } from '@bcis/sdk';

const client = new ResidentialRebuildClient(auth);

// Override the base URL (e.g. for a staging environment):
// const client = new ResidentialRebuildClient(auth, { baseUrl: 'https://api.bcis.co.uk/residential-rebuild-calculator' });

Methods:

calculate(params: CalculateParams): Promise<CalculationResponse>

Calculate the reinstatement cost of a house or flat

Parameter Type Required Description
postCode string Postcode of the property
type string Type of the property
storeys string Number of storeys in the property
style string Style of the property: detached, terraced, etc
wallType string Type of the walls of the property
roofType string Type of the roof of the property
yearBuilt number Year the property was built
noOfFlats number Number of flats
area number Area of the property in sq.m.
noOfRooms number Number of rooms in the property
noOfBedrooms number Number of bedrooms in the property
noOfGarageSpaces number Number of garage spaces in the property
noOfBathrooms number Number of bathrooms in the property
specialFeatures string Special features of the property, Must be blank, or a comma delimited list containing one or more of 'cellar' or 'noexte

reportUsage(params: ReportUsageParams): Promise<UsageResponse>

Usage of the calculations endpoint within a specified date range

Parameter Type Required Description
startMonth string First month of the usage report
endMonth string Last month of the usage report

ScheduleOfRatesClient

Base URL: https://api.bcis.co.uk/schedule-of-rates

The BCIS Schedule of Rates API is designed for integration with your applications and workflows, the API enables you to retrieve and analyse comprehensive pricing information to support accurate project estimation and cost management.

Instantiation:

import { AuthManager, ScheduleOfRatesClient } from '@bcis/sdk';

const client = new ScheduleOfRatesClient(auth);

// Override the base URL (e.g. for a staging environment):
// const client = new ScheduleOfRatesClient(auth, { baseUrl: 'https://api.bcis.co.uk/schedule-of-rates' });

Methods:

getBooksEdition(): Promise<EditionsDto>

Lists books and editions available to user

getRates(params: GetRatesParams): Promise<GetRateResponseDto>

Lists matching rates

Parameter Type Required Description
selected-node-id string node id, returned data are for the selected node
filter-text string filter term, returned nodes contain the text somewhere in that branch
edition-id string id obtained from get-books-edition

getResources(params: GetResourcesParams): Promise<GetResourceResponseDto>

Lists matching resources

Parameter Type Required Description
selected-node-id string node id, returned data are for the selected node
filter-text string filter term, returned nodes contain the text somewhere in that branch
edition-id string id obtained from get-books-edition

getBuildUp(params: GetBuildUpParams): Promise<GetBuildUpResponseDto>

Lists components of a rate or buildUp

Parameter Type Required Description
entity-id string Id as returned from GetRates or GetResources

Error Handling

BcisApiError is thrown for any non-2xx HTTP response.

import { BcisApiError, CoreApiClient } from '@bcis/sdk';

try {
  const result = await coreApi.abpRetrieve({ ... });
} catch (err) {
  if (err instanceof BcisApiError) {
    console.error(err.status, err.statusText, err.body);
  }
}

TypeScript

All parameter and response types are exported from the package root:

import type {
  // Auth
  AuthConfig,
  ClientCredentialsConfig,
  AuthorizationCodeConfig,
  // Response types (one per API)
  AbpResponseDto,
  IndicesResponseDto,
  TpsResponseDto,
  CodesResponseDto,
  DurationModelsDto,
  DurationModelOptionsDto,
  CalculationResultDto,
  CalculationResponse,
  UsageResponse,
  EditionsDto,
  GetRateResponseDto,
  GetResourceResponseDto,
  GetBuildUpResponseDto,
} from '@bcis/sdk';