Your First API Integration
Prerequisites
This hands-on guide walks you through building your first API integration step by step. By the end, you will have a working integration that queries building data and handles errors gracefully.
Step 1: Set Up Your Environment
Install the SDK for your preferred language and configure your API credentials. Create a .env file with your API key:
CONNECTBASE_API_KEY=sk_test_your_key_here
Step 2: Initialize the Client
const client = new ConnectbaseClient({\n apiKey: process.env.CONNECTBASE_API_KEY\n});
Step 3: Make Your First API Call
Query a building by address to get structured data:
const result = await client.buildings.lookup({\n street: "123 Main St",\n city: "Austin",\n state: "TX"\n});\nconsole.log(result.building_id, result.coordinates);
Step 4: Handle Errors
Wrap API calls in try/catch and handle common error types:
try {\n const result = await client.buildings.get(id);\n} catch (err) {\n if (err.status === 404) {\n console.log("Building not found");\n } else if (err.status === 429) {\n console.log("Rate limited, retry after", err.retryAfter);\n }\n}
Step 5: Deploy to Production
Switch from test to live API key and enable retry logic for production reliability.