Skip to main content

Libraries (SDK)

Official SDKs to integrate our API into your applications. Choose your preferred programming language and get started in minutes.

Available SDKs

We provide official SDKs for the most popular programming languages:

LanguagePackageDocumentationRepository
JavaScript/TypeScript@vigrise/sdkDocsGitHub
PythonvigriseDocsGitHub
Gogithub.com/vigrise/sdk-goDocsGitHub
Javacom.vigrise:sdkDocsGitHub
PHPvigrise/sdkDocsGitHub
RubyvigriseDocsGitHub
C#Vigrise.SDKDocsGitHub
RustvigriseDocsGitHub

Installation & Quick Start

Installation

npm install @vigrise/sdk
# or
yarn add @vigrise/sdk
# or
pnpm add @vigrise/sdk

Quick Start

import { VigriseClient } from '@vigrise/sdk';

// Initialize the client
const client = new VigriseClient({
apiKey: 'your-api-key-here',
});

// Make your first API call
async function example() {
try {
const response = await client.process({
input: 'Hello, World!',
options: {
format: 'json',
},
});
console.log(response.data);
} catch (error) {
console.error('Error:', error.message);
}
}

example();

TypeScript Support

The SDK is written in TypeScript and provides full type definitions out of the box.

import { VigriseClient, ProcessOptions, ProcessResponse } from '@vigrise/sdk';

const client = new VigriseClient({ apiKey: process.env.VIGRISE_API_KEY });

const options: ProcessOptions = {
input: 'Sample input',
format: 'json',
timeout: 5000,
};

const response: ProcessResponse = await client.process(options);

Authentication

All SDKs support multiple authentication methods:

Pass your API key when initializing the client:

const client = new VigriseClient({ apiKey: 'your-api-key-here' });

Environment Variable

Set your API key as an environment variable:

export VIGRISE_API_KEY=your-api-key-here

Then initialize without explicitly passing the key:

const client = new VigriseClient(); // Automatically reads from env

Configuration File

Create a configuration file at ~/.vigrise/config.json:

{
"apiKey": "your-api-key-here",
"baseUrl": "https://api.vigrise.com"
}

Common Features

All SDKs provide these core features:

Error Handling

try {
const response = await client.process({ input: 'data' });
} catch (error) {
if (error.code === 'RATE_LIMIT_EXCEEDED') {
console.log('Rate limit exceeded, try again later');
} else if (error.code === 'INVALID_API_KEY') {
console.log('Invalid API key');
} else {
console.log('An error occurred:', error.message);
}
}

Retry Logic

All SDKs include automatic retry with exponential backoff:

const client = new VigriseClient({
apiKey: 'your-api-key-here',
maxRetries: 3,
retryDelay: 1000, // milliseconds
});

Timeout Configuration

const client = new VigriseClient({
apiKey: 'your-api-key-here',
timeout: 30000, // 30 seconds
});

Custom Base URL

For enterprise or self-hosted deployments:

const client = new VigriseClient({
apiKey: 'your-api-key-here',
baseUrl: 'https://your-custom-domain.com',
});

Advanced Usage

Batch Processing

Process multiple requests efficiently:

const results = await client.batch([
{ input: 'First input' },
{ input: 'Second input' },
{ input: 'Third input' },
]);

results.forEach((result, index) => {
console.log(`Result ${index + 1}:`, result.data);
});

Streaming Responses

For long-running operations:

const stream = await client.processStream({ input: 'large data' });

stream.on('data', (chunk) => {
console.log('Received chunk:', chunk);
});

stream.on('end', () => {
console.log('Stream completed');
});

stream.on('error', (error) => {
console.error('Stream error:', error);
});

Webhooks

Configure webhook callbacks for async operations:

await client.process({
input: 'data',
webhook: {
url: 'https://your-domain.com/webhook',
events: ['completed', 'failed'],
},
});

Rate Limiting

All SDKs automatically handle rate limits and provide rate limit information:

const response = await client.process({ input: 'data' });

console.log('Rate Limit:', response.rateLimit.limit);
console.log('Remaining:', response.rateLimit.remaining);
console.log('Reset:', new Date(response.rateLimit.reset));

Testing

All SDKs support testing with mock responses:

import { VigriseClient, mockResponse } from '@vigrise/sdk/testing';

// In your tests
const client = new VigriseClient({ apiKey: 'test-key' });
client.mock(mockResponse({ data: 'mocked data' }));

const response = await client.process({ input: 'test' });
expect(response.data).toBe('mocked data');

Support


Migration Guides

Upgrading from an older version? Check out our migration guides:


Contributing

We welcome contributions to our SDKs! Each repository has its own contribution guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

See individual SDK repositories for detailed contribution guidelines.