Expert guidance for developing with the Retreaver Core API TypeScript client. Handles OpenAPI generated code, testing patterns, authentication, and API versioning.
Expert guidance for developing with the TypeScript/JavaScript API client for the Retreaver Core API. This skill provides comprehensive knowledge of the auto-generated OpenAPI client structure, testing patterns, and development workflows.
The Retreaver API client is an **auto-generated OpenAPI client** with manually written unit tests. Key architectural principles:
```bash
npm run build # Build both CommonJS and ES modules
npm run prepare # Auto-runs on install
```
```bash
npm test # Watch mode
npm run test:run # Single run
npm run test:coverage # Coverage report (80% threshold)
npm run test:ui # Vitest UI
```
```bash
npm run lint # TypeScript linting
npm run lint:fix # Auto-fix issues
npm run format # Prettier formatting
npm run format:check # Check formatting
npm run typecheck # Type checking
```
Each API resource follows this structure:
1. **AxiosParamCreator** - Builds request parameters
2. **ApiFp** - Functional programming layer
3. **Api class** - Object-oriented wrapper extending `BaseAPI`
```typescript
import { Configuration } from '@berrydev-ai/retreaver-api-client';
const config = new Configuration({
apiKey: 'your_api_key',
// Optional for multi-company access
// companyId: 'company_id'
});
```
```typescript
// Import from root level
import { CallsApi, Configuration } from '../../../api';
import { setupHttpMocks, mockGet, verifyRequest } from '../../mocks/http-mocks';
import { mockCallsResponse } from '../../mocks/mock-data';
describe('CallsApi', () => {
const { mockAdapter, baseURL } = setupHttpMocks();
test('should fetch calls successfully', async () => {
// Arrange
const api = new CallsApi(new Configuration({ basePath: baseURL }));
mockGet(mockAdapter, '/calls.json', mockCallsResponse);
// Act
const response = await api.getCalls();
// Assert
expect(response.data).toEqual(mockCallsResponse);
verifyRequest(mockAdapter, 'get', '/calls.json');
});
});
```
```typescript
import { CallsApi, AffiliatesApi, Configuration } from '@berrydev-ai/retreaver-api-client';
const config = new Configuration({ apiKey: 'your_api_key' });
const callsApi = new CallsApi(config);
const affiliatesApi = new AffiliatesApi(config);
// Fetch calls (V1)
const calls = await callsApi.getCalls();
// Fetch calls with enhanced data (V2)
const callsV2Api = new CallsV2Api(config);
const enhancedCalls = await callsV2Api.getCalls();
// Manage affiliates
const affiliates = await affiliatesApi.getAffiliates();
```
```typescript
try {
const response = await api.getCalls();
console.log(response.data);
} catch (error) {
if (error.response?.status === 401) {
console.error('Authentication failed');
} else if (error.response?.status === 404) {
console.error('Resource not found');
}
}
```
The client provides typed access to:
All APIs support pagination (25 results per page via Link header) and both JSON and XML formats.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/retreaver-api-client-typescript-development/raw