Resources
SDKs
GuestNetworks ships two official packages: @guestnetworks/sdk (TypeScript/Node.js) and @guestnetworks/cli (command-line). Both use the same Authorization: Bearer token as the REST API.
TypeScript / Node.js
@guestnetworks/sdk
Typed wrappers for every REST endpoint. Handles Authorization headers automatically, retries 429/5xx errors with exponential back-off, and throws typed error classes (GNAuthError, GNRateLimitError, GNNotFoundError). Works in Node.js and any runtime with the global fetch API (Bun, Deno, edge workers).
Install
npm install @guestnetworks/sdk # or pnpm add @guestnetworks/sdk
Initialize the client
import { GuestNetworksClient } from '@guestnetworks/sdk';
const client = new GuestNetworksClient({
apiKey: process.env.GN_API_KEY!, // gn_live_sk_...
baseUrl: 'https://api.guestnetworks.com', // optional — this is the default
timeout: 30_000, // ms — default 30 s
retries: 2, // retries on 429/5xx — default 2
});Venues
// List venues
const { data: venues } = await client.venues.listVenues({ limit: 10 });
// Create a venue
const venue = await client.venues.create({
name: 'Downtown Hotel',
timezone: 'America/New_York',
});
// Get one venue (with zones + integrations)
const info = await client.venues.getVenueInfo({ venue_id: venue.id });
// Update
await client.venues.update({ venue_id: venue.id, name: 'Downtown Hotel (East Wing)' });
// Soft-delete
await client.venues.delete({ venue_id: venue.id });Occupancy
// Current real-time occupancy snapshot
const snap = await client.occupancy.getOccupancy({
venue_id: '<uuid>',
keys: ['occupancy'],
startTs: Date.now() - 300_000, // last 5 minutes
endTs: Date.now(),
interval: 60_000, // 1-minute buckets
agg: 'AVG',
});
// snap → { occupancy: [{ ts: number, value: number }, ...] }
// Historical trend
const trend = await client.occupancy.getOccupancyTrend({
venue_id: '<uuid>',
keys: ['occupancy', 'entries', 'exits'],
startTs: Date.now() - 86_400_000, // last 24 hours
endTs: Date.now(),
interval: 3_600_000, // 1-hour buckets
agg: 'AVG',
});Environment
// Temperature, CO₂, humidity, noise
const env = await client.environment.getEnvironment({
venue_id: '<uuid>',
keys: ['temperature', 'co2', 'humidity'],
startTs: Date.now() - 3_600_000,
endTs: Date.now(),
interval: 300_000,
agg: 'AVG',
});
// env → { temperature: [...], co2: [...], humidity: [...] }Analytics
// Visitor loyalty segmentation
const scoring = await client.analytics.getRepeatVisitorRate({
venue_id: '<uuid>',
range: '30d',
});
// scoring → { segments: [{ name, count, percentage }], total: number }
// Capacity recommendations (occupancy prediction)
const recs = await client.analytics.getCapacityRecommendations({
venue_id: '<uuid>',
dayOfWeek: 1, // Monday
hour: 14, // 2 PM
});
// recs → { mean, p25, p75, p95, sampleSize }Ingest
// Push events to the ingestion pipeline
const result = await client.ingest.pushEvents([
{
venue_id: '<uuid>',
connector_type: 'meraki',
type: 'device_connected',
timestamp: new Date().toISOString(),
payload: {
device_hash: 'device_001',
metrics: { signal_strength: -42, ssid: 'Guest-WiFi' },
},
},
]);
// result → { accepted: 1, rejected: 0, errors: [] }Error handling
import {
GuestNetworksClient,
GNAuthError,
GNRateLimitError,
GNNotFoundError,
GNValidationError,
GNError,
} from '@guestnetworks/sdk';
try {
const venues = await client.venues.listVenues();
} catch (err) {
if (err instanceof GNAuthError) console.error('Invalid API key');
else if (err instanceof GNRateLimitError) {
console.error(`Rate limited — retry in ${err.retryAfterMs}ms`);
}
else if (err instanceof GNNotFoundError) console.error('Resource not found');
else if (err instanceof GNValidationError) console.error('Bad request:', err.message);
else if (err instanceof GNError) console.error('API error:', err.code, err.message);
else throw err;
}Command-line
@guestnetworks/cli
A command-line interface that exposes all SDK operations as shell commands. Useful for scripting, debugging, and ad-hoc data inspection. The CLI binary is gn.
Install
npm install -g @guestnetworks/cli # or run without installing: npx @guestnetworks/cli --help
Configure your API key
# Option 1: environment variable (recommended) export GN_API_KEY="gn_live_sk_..." # Option 2: pass inline gn --key gn_live_sk_... venues list # Option 3: save to config file gn config set apiKey gn_live_sk_...
Venue commands
# List all venues gn venues list # List as JSON gn venues list --json # Create a venue gn venues create --name "Downtown Hotel" --timezone "America/New_York" # Get a specific venue gn venues get <venue-id> # Update a venue gn venues update <venue-id> --name "Downtown Hotel (East Wing)" # Delete a venue gn venues delete <venue-id>
Zone commands
# List zones for a venue gn zones list --venue <venue-id> # Create a zone gn zones create --venue <venue-id> --slug main-floor --name "Main Floor" --type area --capacity 120 # Update a zone gn zones update <zone-id> --venue <venue-id> --capacity 150 # Delete a zone gn zones delete <zone-id> --venue <venue-id>
Occupancy & telemetry
# Current occupancy snapshot gn occupancy get --venue <venue-id> # Telemetry query (last 1 hour, 5-min buckets) gn telemetry query --venue <venue-id> --keys occupancy,temperature --interval 300000 # Output as CSV for spreadsheets gn telemetry query --venue <venue-id> --keys occupancy --csv > occupancy.csv
Integrations
# List integrations for a venue gn integrations list --venue <venue-id> # Connect Meraki gn integrations add --venue <venue-id> --type meraki --api-key $MERAKI_API_KEY --org-id 553998 # Remove an integration gn integrations remove <integration-id> --venue <venue-id>
Alarms
# List active unacknowledged alarms gn alarms list --status ACTIVE_UNACK # Filter by venue and severity gn alarms list --venue <venue-id> --severity CRITICAL # Acknowledge an alarm gn alarms ack <alarm-id> # Clear an alarm gn alarms clear <alarm-id>
Health & status
# Platform health (no auth required) gn health # Integration health per venue gn health integrations --venue <venue-id> # Analytics: visitor scoring gn visitors scoring --venue <venue-id> --range 30d
Base URL & defaults
| Setting | Default value | Override |
|---|---|---|
| SDK default base URL | https://gn-mcp-server.fly.dev | Pass baseUrl to GuestNetworksClient |
| Production base URL | https://api.guestnetworks.com | — (same Fly.dev app, aliased) |
| CLI default server | https://api.guestnetworks.com | Pass --server <url> or gn config set server |
| Request timeout (SDK) | 30 000 ms | Pass timeout to GuestNetworksClient |
| Retries on 429/5xx (SDK) | 2 | Pass retries to GuestNetworksClient |