API docs
Guides

Integration tutorial

Build a complete integration with Setback from scratch.

Overview

This tutorial walks through building a property lookup feature that retrieves and displays HOA restrictions for a given address.

Architecture

Your integration will:

  1. Accept a parcel APN from user input
  2. Call the Setback API to fetch restrictions
  3. Display structured restriction data to the user

Step 1: Set up your environment

Store your API key as an environment variable:

export SETBACK_API_KEY="your_api_key_here"

Step 2: Fetch parcel restrictions

const API_BASE = 'https://api.setback.io';

async function getParcelRestrictions(apn: string, county: string) {
  const response = await fetch(
    `${API_BASE}/v1/parcels/${apn}/restrictions?county=${county}`,
    {
      headers: {
        'Authorization': `Bearer ${process.env.SETBACK_API_KEY}`,
        'Content-Type': 'application/json',
      },
    }
  );

  if (!response.ok) {
    throw new Error(`API error: ${response.status}`);
  }

  return response.json();
}

Step 3: Filter by confidence

Only show high-confidence results to end users:

function getHighConfidenceFacts(facts: any[]) {
  return facts.filter(fact => fact.confidence >= 0.85);
}

Step 4: Group by type

Organize restrictions by category for display:

function groupByType(facts: any[]) {
  return facts.reduce((groups, fact) => {
    const type = fact.fact_type;
    if (!groups[type]) groups[type] = [];
    groups[type].push(fact);
    return groups;
  }, {} as Record<string, any[]>);
}

Step 5: Handle errors

Implement proper error handling for production:

async function safeGetRestrictions(apn: string, county: string) {
  try {
    const result = await getParcelRestrictions(apn, county);
    return { data: result.data, error: null };
  } catch (error) {
    if (error instanceof Error) {
      return { data: null, error: error.message };
    }
    return { data: null, error: 'Unknown error' };
  }
}

Next steps

  • Add caching to reduce API calls for repeated lookups
  • Implement retry logic with exponential backoff for transient errors
  • Use webhooks (coming soon) to receive notifications when new documents are processed

On this page