Skip to content

@venturekit/integrations

Terminal window
npm install @venturekit/integrations@dev
import { apiClient } from '@venturekit/integrations';
const stripe = apiClient({
baseUrl: 'https://api.stripe.com/v1',
headers: { Authorization: `Bearer ${process.env.STRIPE_KEY}` },
retry: { maxRetries: 3 },
timeout: 5000,
});
// The second argument is `ApiRequestOptions` (`{ body?, headers?, params?, ... }`).
// Pass the JSON payload via `body` — it is auto-stringified.
const res = await stripe.post('/charges', {
body: { amount: 1000, currency: 'usd' },
});
  • Automatic retries with exponential backoff
  • Configurable timeouts
  • Request/response/error interceptors
  • Structured ApiError class
import { oauth2 } from '@venturekit/integrations';
const auth = oauth2({
flow: 'client_credentials',
tokenUrl: 'https://oauth.provider.com/token',
clientId: process.env.CLIENT_ID!,
clientSecret: process.env.CLIENT_SECRET!,
});
const client = apiClient({
baseUrl: 'https://api.provider.com',
onRequest: [auth.interceptor()],
});
  • Client credentials and authorization code flows
  • Automatic token refresh
  • Token storage: in-memory (default) or DynamoDB
import { apiKey, apiKeyHeader } from '@venturekit/integrations';
const key = apiKey({ ssm: '/myapp/prod/api-key' });
const client = apiClient({
baseUrl: 'https://api.example.com',
onRequest: [apiKeyHeader(key, 'X-Api-Key', '')],
});
  • Retrieve keys from environment variables, SSM Parameter Store, or Secrets Manager
  • Built-in caching to avoid repeated AWS calls
  • ApiClient, ApiClientOptions, ApiRequestOptions, ApiResponse — HTTP client types
  • RetryOptions, RequestInterceptor, ResponseInterceptor, ErrorInterceptor — interceptor types
  • OAuth2Client, OAuth2Options, TokenSet, TokenStore — OAuth2 types
  • ApiKeyHandle, ApiKeySource, ApiKeyFromEnv, ApiKeyFromSSM, ApiKeyFromSecret — API key types
  • @venturekit/core — required
  • @aws-sdk/client-dynamodb, @aws-sdk/lib-dynamodb — peer (for DynamoDB token store)
  • @aws-sdk/client-ssm — peer (for SSM parameter store)
  • @aws-sdk/client-secrets-manager — peer (for Secrets Manager)