> ## Documentation Index
> Fetch the complete documentation index at: https://docs.s4kit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with S4Kit in 5 minutes

## Prerequisites

* Node.js 18+ or Bun 1.0+
* An S4Kit account with an API key
* Access to an SAP S/4HANA system (configured in the platform)

## Step 1: Install the SDK

<CodeGroup>
  ```bash npm theme={null}
  npm install s4kit
  ```

  ```bash yarn theme={null}
  yarn add s4kit
  ```

  ```bash pnpm theme={null}
  pnpm add s4kit
  ```

  ```bash bun theme={null}
  bun add s4kit
  ```
</CodeGroup>

## Step 2: Initialize the Client

Create an S4Kit client with your API key and connection name:

```typescript theme={null}
import { S4Kit } from 's4kit';

const client = new S4Kit({
  apiKey: process.env.S4KIT_API_KEY,  // Your API key
  connection: 'production'               // Your SAP instance alias
});
```

<Warning>
  Never commit your API key to source control. Use environment variables instead.
</Warning>

## Step 3: Make Your First Request

Query SAP entities using the intuitive SDK interface:

```typescript theme={null}
// List business partners
const partners = await client.A_BusinessPartner.list({
  top: 10,
  select: ['BusinessPartner', 'BusinessPartnerName', 'BusinessPartnerCategory']
});

console.log(partners);
// [
//   { BusinessPartner: '10100001', BusinessPartnerName: 'Acme Corp', ... },
//   { BusinessPartner: '10100002', BusinessPartnerName: 'Global Inc', ... },
//   ...
// ]
```

## Step 4: Try CRUD Operations

<Tabs>
  <Tab title="Read">
    ```typescript theme={null}
    // Get a single entity by ID
    const partner = await client.A_BusinessPartner.get('10100001');

    // List with filtering
    const customers = await client.A_BusinessPartner.list({
      filter: "BusinessPartnerCategory eq '1'",
      orderBy: 'BusinessPartnerName asc',
      top: 50
    });
    ```
  </Tab>

  <Tab title="Create">
    ```typescript theme={null}
    // Create a new business partner
    const newPartner = await client.A_BusinessPartner.create({
      BusinessPartnerCategory: '1',
      BusinessPartnerFullName: 'New Company Ltd',
      // ... other fields
    });
    ```
  </Tab>

  <Tab title="Update">
    ```typescript theme={null}
    // Update an existing entity (PATCH)
    const updated = await client.A_BusinessPartner.update('10100001', {
      BusinessPartnerFullName: 'Updated Company Name'
    });
    ```
  </Tab>

  <Tab title="Delete">
    ```typescript theme={null}
    // Delete an entity
    await client.A_BusinessPartner.delete('10100001');
    ```
  </Tab>
</Tabs>

## Complete Example

Here's a full working example:

```typescript theme={null}
import { S4Kit } from 's4kit';

async function main() {
  // Initialize client
  const client = new S4Kit({
    apiKey: process.env.S4KIT_API_KEY,
    connection: 'sandbox'
  });

  try {
    // Fetch sales orders from the last 30 days
    const thirtyDaysAgo = new Date();
    thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);

    const orders = await client.A_SalesOrder.list({
      filter: `CreationDate ge datetime'${thirtyDaysAgo.toISOString()}'`,
      select: ['SalesOrder', 'SoldToParty', 'TotalNetAmount', 'TransactionCurrency'],
      expand: ['to_Item'],
      orderBy: 'CreationDate desc',
      top: 100
    });

    console.log(`Found ${orders.length} recent orders`);

    for (const order of orders) {
      console.log(`Order ${order.SalesOrder}: ${order.TotalNetAmount} ${order.TransactionCurrency}`);
    }
  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();
```

## Next Steps

<CardGroup cols={2}>
  <Card title="SDK Installation" icon="download" href="/sdk/installation">
    Learn about SDK configuration options.
  </Card>

  <Card title="Query Options" icon="filter" href="/sdk/querying">
    Master filtering, pagination, and sorting.
  </Card>

  <Card title="Platform Setup" icon="gear" href="/platform/overview">
    Configure SAP systems and API keys.
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/sdk/error-handling">
    Handle errors gracefully in your app.
  </Card>
</CardGroup>
