Core Concept
Output format
Every StateAnchor generation produces three outputs: the wrapper implementation, a README, and a structured endpoint list.
The wrapper implementation
The core output — a ready-to-use module in your chosen language that includes:
- A client class (or functional exports) with one method per endpoint
- TypeScript types (or Python type hints / Go structs) for every request parameter and response shape
- An ApiError class (or equivalent) that wraps HTTP errors with status code and message
- An auth helper that accepts your API key or token in the constructor
- JSDoc / docstrings on every method with parameter descriptions
// Types
export interface User {
id: string;
email: string;
createdAt: string;
}
// Error class
export class ApiError extends Error {
constructor(public readonly status: number, message: string) {
super(message);
this.name = "ApiError";
}
}
// Client
export class MyApiClient {
private base = "https://api.example.com/v1";
constructor(private readonly apiKey: string) {}
async getUser(id: string): Promise<User> {
const res = await fetch(`${this.base}/users/${id}`, {
headers: { Authorization: `Bearer ${this.apiKey}` },
});
if (!res.ok) {
const err = await res.json().catch(() => ({ message: res.statusText }));
throw new ApiError(res.status, err.message ?? err.error);
}
return res.json();
}
}README with usage examples
A complete Markdown README is generated alongside every wrapper containing:
- Package installation instructions
- Constructor signature with required parameters
- A usage example for every method
- Error handling patterns
- A table of all available methods
Structured endpoint list
A machine-readable summary of all endpoints StateAnchor detected in your description. Useful for verifying the AI understood your API correctly. Each entry shows:
- HTTP method and path
- Brief description
- Detected parameters (path, query, body)
- Return type name
Language-specific output notes
| Language | Details |
|---|---|
TypeScript | async/await with fetch. Full JSDoc. Separate interface files optional. |
Python | httpx AsyncClient (async) or requests Session (sync). Type hints + docstrings. |
JavaScript | ES module with JSDoc. Uses native fetch (Node 18+) or node-fetch. |
Go | net/http based. Struct types with json tags. Errors implement the error interface. |
Ruby | Faraday gem. RDoc comments. Error class inherits StandardError. |
MCP Server output
When you generate in MCP mode, the output is a complete Model Context Protocol server instead of a standalone wrapper. See the MCP Server guide for details.