Installation
Install the S4Kit SDK using your preferred package manager:
Configuration
Create an S4Kit client instance with your configuration:
import { S4Kit } from 's4kit';
const client = new S4Kit({
apiKey: 'sk_live_...', // Required: Your API key
connection: 'production', // Optional: Default SAP instance
baseUrl: 'https://api.s4kit.com', // Optional: Custom API URL
service: 'API_BUSINESS_PARTNER' // Optional: Default OData service
});
Configuration Options
| Option | Type | Required | Description |
|---|
apiKey | string | Yes | Your S4Kit API key (starts with sk_live_ or sk_test_) |
connection | string | No | Default SAP instance alias to use for requests |
baseUrl | string | No | Custom API URL (default: https://api.s4kit.com) |
service | string | No | Default OData service name |
Environment Variables
We recommend storing your API key in environment variables:
const client = new S4Kit({
apiKey: process.env.S4KIT_API_KEY,
connection: process.env.S4KIT_CONNECTION
});
Never commit API keys to source control. Use .env files or secrets management.
Example .env File
S4KIT_API_KEY=sk_live_abc123...
S4KIT_CONNECTION=production
TypeScript Support
The SDK is written in TypeScript and provides full type definitions out of the box:
import { S4Kit, S4KitConfig, QueryOptions } from 's4kit';
const config: S4KitConfig = {
apiKey: process.env.S4KIT_API_KEY!,
connection: 'production'
};
const client = new S4Kit(config);
Generated Types
For full type safety with your SAP entities, use the CLI to generate types from OData metadata:
npx s4kit generate-types --api-key sk_live_... --output ./types
Then use the types in your code:
import type { A_BusinessPartner } from './types/sap';
const partners = await client.A_BusinessPartner.list() as A_BusinessPartner[];
Multiple Clients
You can create multiple client instances for different environments:
const prodClient = new S4Kit({
apiKey: process.env.S4KIT_API_KEY,
connection: 'production'
});
const devClient = new S4Kit({
apiKey: process.env.S4KIT_API_KEY,
connection: 'dev'
});
Or override the connection per-request:
// Use production connection
const prodOrders = await client.A_SalesOrder.list({
connection: 'production'
});
// Use development connection
const devOrders = await client.A_SalesOrder.list({
connection: 'dev'
});