venue-js
v1.3.1
Published
Venue JS is a lightweight JavaScript/TypeScript SDK for accessing venue data such as occupants, amenities, kiosks, and other IMDF-based features from your Venue API. It provides a simple, unified client for fetching and filtering features by type or ID —
Readme
Venue JS — Data Client SDK
Venue JS is a lightweight JavaScript/TypeScript SDK for accessing venue data such as occupants, amenities, kiosks, and other IMDF-based features from your Venue API. It provides a simple, unified client for fetching and filtering features by type or ID — ideal for use in React apps, kiosk frontends, and data-driven dashboards.
Installation
# with npm
npm install venue-js
# or with yarn
yarn add venue-jsSetup
Import the client and configure it with your project credentials.
import { getDataClient, type VenueClientOptions } from "venue-js"
const venueConfig: VenueClientOptions = {
projectId: import.meta.env.VITE_VENUE_PROJECT_ID,
apiKey: import.meta.env.VITE_VENUE_APIKEY,
baseUrl: import.meta.env.VITE_VENUE_BASEURL,
}
const venueDataClient = getDataClient(venueConfig)Usage
The data client exposes two main functions:
1. filterByType(featureType, options?)
Retrieve all features of a given type.
// Get all occupants
const occupants = await venueDataClient.filterByType("occupant")
// Get all occupants with related data populated
const populatedOccupants = await venueDataClient.filterByType("occupant", { populate: true })Parameters
| Name | Type | Description | |------------------|:------------------:|---------------------------------------------------------:| | featureType | string | feature type, e.g. "occupant", "amenity", "unit" | | options.populate | boolean (optional) | Whether to return fully populated objects with relations |
Returns
An array of feature objects (e.g. occupants).
2. filterById(featureType, id, options?)
Retrieve all features of a given type.
const occupantId = "occupant-1234"
// Basic record
const occupant = await venueDataClient.findById("occupant", occupantId)
// With related data populated
const populatedOccupant = await venueDataClient.findById("occupant", occupantId, { populate: true })Parameters
| Name | Type | Description | |------------------|:------------------:|---------------------------------------------------------:| | featureType | string | feature type, e.g. "occupant", "amenity", "unit" | | id | string | id of a feature | | options.populate | boolean (optional) | Whether to return fully populated objects with relations |
Returns
A single feature object or null if not found.
Available Feature Types
- amenity
- anchor
- building
- fixture
- kiosk
- level
- occupant
- opening
- relationship
- section
- unit
- venue
