Spot SDKs

Overview

The Spot SDK provides a typed, developer-friendly interface for interacting with Spot’s API: requesting and managing quotes, accepting or declining coverage, and handling requotes.

💡

Note: For a detailed explanation of the quoting flow, quote acceptance, and enrollment lifecycle, see the Quote API overview.

Requests and response types evolve alongside the Spot API. The latest and most accurate definitions always live in our NPM package.

Key Benefits

  • Strong Type Safety: Fully typed requests/responses to prevent integration errors.
  • Simplified Authentication: Handles authentication operations out of the box.

Installation

Install the SDK for your chosen programming language:

npm install --save @getspot/spot-sdk

Initialization

Instantiate the SDK with your credentials:

import { Spotsdk } from '@getspot/spot-sdk';

const spotsdk = new Spotsdk({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  spotPartnerId: 'YOUR_SPOT_PARTNER_ID',
}):
⚠️

Security Note (Browser Usage)

Use a server-side token exchange to avoid exposing client credentials in frontend code.

Server-Side Token Exchange

// server.ts
import { Spotsdk } from '@getspot/spot-sdk';

const spotsdk = new Spotsdk({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  spotPartnerId: 'YOUR_SPOT_PARTNER_ID',
}):

// API endpoint to generate access token
async function generateAccessToken() {
  const oAuthTokenRequestDto: OAuthTokenRequestDto = {
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
  };

  const { data } = await spotsdk.auth.fetchPartnerToken(oAuthTokenRequestDto);

  return data.accessToken;
}

Client-Side Implementation

// component.ts
// Fetch token from your backend API
const accessToken = fetchSpotAccessToken();

const spotsdk = new Spotsdk({
  clientId: '', // Empty when using accessToken
  clientSecret: '', // Empty when using accessToken
  accessToken,
  spotPartnerId: 'YOUR_SPOT_PARTNER_ID',
}):

// Now you can make authenticated requests

Core SDK Methods

  • spotsdk.quote.getQuote() – request a quote
  • spotsdk.quote.acceptQuote() – accept coverage for a completed purchase
  • spotsdk.quote.declineQuote() – decline a quote when the customer opts out
  • spotsdk.quote.requote() – fetch updated pricing or dates
  • spotsdk.quote.acceptRequote() – finalize updated enrollment
💡

See the Quote API docs for detailed workflow guidance.

Additional Resources

For an up to date description of requests and responses for all of these operations, refer to:


Did this page help you?