TypeScript SDK
Official TypeScript SDK for Shim. Zero dependencies, works in Node.js 18+ and browsers.Installation
npm
yarn
pnpm
Quick Start
Client Configuration
new ShimClient(config)
apiKey(string, required): Your Shim API keybaseUrl(string, optional): Custom API base URL (for testing)
Batch Repair
client.repair(request)
Fix malformed JSON in one request.
raw_output(string, required): Malformed JSON stringschema(JSONSchema, optional): JSON Schema for validationmode(‘strict’ | ‘lenient’, optional): Repair mode
Promise<RepairResponse>
Example:
Streaming Repair
client.stream.start(options)
Start a new streaming session.
schema(JSONSchema, optional): JSON Schema for validationmode(‘strict’ | ‘lenient’, optional): Repair mode
Promise<{ session_id: string; expires_at: number }>
Example:
client.stream.push(request)
Push a chunk to an active streaming session.
session_id(string, required): Session ID fromstream.start()chunk(string, required): Chunk of JSON to process
Promise<{ state: StreamingState }>
Example:
client.stream.finalize(request)
Finalize a streaming session and get the repaired result.
session_id(string, required): Session ID fromstream.start()
Promise<RepairResponse>
Example:
Complete Streaming Example
TypeScript Support
The SDK includes full TypeScript definitions.Error Handling
The SDK throws errors for network failures. Shim always returns HTTP 200 with structured error responses.Next Steps
Batch Endpoint
API reference for batch repair
Streaming Endpoints
API reference for streaming repair
Response Object
Full response schema
GitHub
View source code
