ragstack
v0.0.3
Published
TypeScript/JavaScript SDK for interacting with the Ragstack API.
Readme
Ragstack SDK
TypeScript/JavaScript SDK for interacting with the Ragstack API.
Installation
npm install ragstack
# or
pnpm add ragstack
# or
yarn add ragstackUsage
import { Ragstack } from "ragstack";
// Initialize the client
const client = new Ragstack({
baseUrl: "https://api.ragstack.ai", // or your self-hosted URL
apiKey: "your_api_key",
});
// Get a namespace
const ns = client.namespace("my-namespace");
// List documents
const { documents } = await ns.documents.all();
// List ingestion jobs
const { jobs, pagination } = await ns.ingestion.all();
// Create an ingestion job
const job = await ns.ingestion.create({
externalId: "my-file",
sources: [{ url: "https://example.com/document.pdf" }],
});Features
- ✅ Full TypeScript support with auto-generated types
- ✅ Comprehensive error handling with detailed error messages
- ✅ Content-Type validation (prevents "Illegal invocation" errors)
- ✅ Namespace management
- ✅ Document management
- ✅ Ingestion job management
- ✅ Search functionality
Development
Building
pnpm buildTesting
cd ../test
pnpm devPublishing
- Update version in
package.json - Build the package:
pnpm build - Login to npm:
npm login - Publish:
npm publish
Recent Improvements (v0.0.3+)
- Better error handling: The SDK now checks Content-Type headers before parsing JSON, preventing cryptic "Illegal invocation" errors
- Clearer error messages: When the server returns HTML instead of JSON, you'll get a clear error message with a preview of the response
- Improved debugging: Error messages now include the HTTP method, path, and response content type
