Skip to main content

Installation

Install the S4Kit SDK using your preferred package manager:
npm install s4kit

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

OptionTypeRequiredDescription
apiKeystringYesYour S4Kit API key (starts with sk_live_ or sk_test_)
connectionstringNoDefault SAP instance alias to use for requests
baseUrlstringNoCustom API URL (default: https://api.s4kit.com)
servicestringNoDefault 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[];
See the CLI documentation for more information on type generation.

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'
});