FloorMemory TypeScript SDK#
The FloorMemory TypeScript SDK provides full type safety on top of the FloorMemory APIs, making it ideal for:Frontend applications (React, Next.js, Vue)
Large strictly typed codebases
It mirrors the FloorMemory API surface with strongly typed request/response contracts.Query memory-aware conversations
Add content and structured events to Floors
Retrieve activity feeds and conversations
Fetch floor metadata for UI rendering and permissions
Manage floor visibility and settings (owner-only)
There is no single high-level client abstraction.
You work with capability-based API classes (Query, Events, Floors, Auth).
Source Code#
Official TypeScript SDK#
Production Examples (Highly Recommended)#
The examples repository contains:Strictly typed frontend integrations
Multi-turn conversational examples
Production-safe configuration patterns
If you are building a real application, start there.
Installation#
Importing the SDK#
import {
Configuration,
QueryApi,
EventApi,
GetRecentEventsApi,
GetFloorInformationApi,
EditFloorApi,
DefaultApi,
} from "@xfloor/floor-memory-sdk-ts";
Authentication & Setup#
All FloorMemory APIs require:const config = new Configuration({
accessToken: "<USER_ACCESS_TOKEN>",
basePath: "https://appfloor.in", // optional
});
Important Notes#
Token is sent as:
Authorization: Bearer <token>
appId is passed explicitly per API call
appId is never globally configured
Never embed tokens in frontend source code (use secure storage)
Common Parameter Glossary#
| Parameter | Meaning |
|---|
userId | Unique xfloor user identifier. Enables personalization and conversation continuity. |
appId | Calling application context identifier. |
floorId | Single floor scope. |
floorIds | Multi-floor scope (used by Query API). |
blockId | Block container inside floor. |
blockType | Category type (post, forum). |
| Async ingestion | Create Event returns success when queued; use Recent Events to confirm visibility. |
Querying a Floor (Primary API)#
The Query API is the main way to interact with FloorMemory.const queryApi = new QueryApi(config);
const response = await queryApi.query({
userId: "user_123",
floorId: "floor_456",
appId: "1234567890123",
query: "Explain binary search trees",
});
console.log(response.answer);
Parameters#
| Field | Type | Required | Description |
|---|
| userId | string | β
| Enables conversation continuity |
| floorId | string | β
| Floor to search within |
| query | string | β
| Natural language query |
| appId | string | Optional | Application context identifier |
What This Does#
Loads relevant conversation history
Retrieves floor-grounded knowledge
Returns contextual answer
Stores interaction for follow-ups
Adding Content to a Floor (Create Event)#
Use events to add knowledge that future conversations can reference.const eventApi = new EventApi(config);
await eventApi.createEvent(
{
floorId: "floor_456",
userId: "user_123",
title: "Binary Search Tree Notes",
content: "A binary search tree is a node-based data structure...",
blockId: "1765960948723",
blockType: "1",
},
{
appId: "1234567890123",
}
);
Parameters#
| Field | Type | Required | Description |
|---|
| floorId | string | β
| Target floor |
| userId | string | β
| Author |
| title | string | Optional | Feed/UI title |
| content | string | β
| Main text content |
| blockId | string | Optional | Block container |
| blockType | string | Optional | Category (0 for post, 1 for forum) |
| appId | string | Optional | Passed separately |
Event Behavior#
Ingestion is asynchronous
Immediately returns when queued
If your SDK exposes the raw OpenAPI-style API (inputInfo), then:block_id = block container
block_type = category type
app_id is passed separately, not inside payload
Retrieve Recent Events (Activity Feed)#
const eventsApi = new GetRecentEventsApi(config);
const events = await eventsApi.getRecentEvents({
floorId: "floor_456",
userId: "user_123",
appId: "1234567890123",
});
events.forEach(event => {
console.log(event.title);
});
Use this if you need deterministic confirmation of ingestion.
const floorApi = new GetFloorInformationApi(config);
const floor = await floorApi.getFloorInformation({
floorId: "floor_456",
userId: "user_123",
appId: "1234567890123",
});
console.log(floor.title);
console.log(floor.blocks);
Returns metadata only (no embeddings).
Edit Floor (Owner Only)#
const editApi = new EditFloorApi(config);
await editApi.editFloor({
floorId: "floor_456",
userId: "user_123",
appId: "1234567890123",
title: "Advanced Data Structures",
details: "Notes on trees and graphs",
});
Manage Floor Visibility#
const defaultApi = new DefaultApi(config);
await defaultApi.makeFloorPrivate({
floorId: "floor_456",
userId: "user_123",
appId: "1234567890123",
});
Complete Client-Side Example (React)#
import { useState } from "react";
import { Configuration, QueryApi } from "@xfloor/floor-memory-sdk-ts";
const config = new Configuration({
accessToken: localStorage.getItem("XFLOOR_TOKEN")!,
basePath: "https://appfloor.in",
});
const queryApi = new QueryApi(config);
export function AskFloor() {
const [question, setQuestion] = useState("");
const [answer, setAnswer] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
async function ask() {
setLoading(true);
try {
const res = await queryApi.query({
userId: "user_123",
floorId: "floor_456",
appId: "1234567890123",
query: question,
});
setAnswer(res.answer);
} finally {
setLoading(false);
}
}
return (
<div>
<input
value={question}
onChange={e => setQuestion(e.target.value)}
placeholder="Ask somethingβ¦"
/>
<button onClick={ask} disabled={loading}>
Ask
</button>
{answer && <p>{answer}</p>}
</div>
);
}
Using the Official TypeScript Examples#
A React / Next.js frontend
A memory-enabled chat interface
A structured content ingestion UI
Use the official examples:The examples repository demonstrates:Strict TypeScript typing patterns
Clean separation of config and API usage
Deterministic ingestion flow
Multi-floor conversational patterns
Error Handling#
try {
await queryApi.query({ ... });
} catch (error) {
console.error(error);
}
Best Practices#
401 / 403 β Re-authenticate
4xx β Validation or permission issues
5xx β Retry or show fallback UI
One Configuration per logged-in user
Use secure token storage and refresh logic
Keep userId stable for conversation continuity
Where to Go Next#
π Core FloorMemory APIs
Modified atΒ 2026-02-19 05:04:04