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

# Installation

> Install the Webacy TypeScript SDK with npm, pnpm, yarn, or bun and configure ThreatClient or TradingClient with API keys, default chains, and debug logging.

## Requirements

* Node.js 18 or later
* An API key from [developers.webacy.co](https://developers.webacy.co/)

## Install the Package

<CodeGroup>
  ```bash npm theme={null}
  npm install @webacy-xyz/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @webacy-xyz/sdk
  ```

  ```bash yarn theme={null}
  yarn add @webacy-xyz/sdk
  ```

  ```bash bun theme={null}
  bun add @webacy-xyz/sdk
  ```
</CodeGroup>

## Module Support

The SDK supports both ESM and CommonJS:

<CodeGroup>
  ```typescript ESM (Recommended) theme={null}
  import { ThreatClient, TradingClient, Chain } from '@webacy-xyz/sdk';
  ```

  ```javascript CommonJS theme={null}
  const { ThreatClient, TradingClient, Chain } = require('@webacy-xyz/sdk');
  ```
</CodeGroup>

## Initialize a Client

### ThreatClient

For security analysis (addresses, contracts, sanctions, URLs):

```typescript theme={null}
import { ThreatClient, Chain } from '@webacy-xyz/sdk';

const client = new ThreatClient({
  apiKey: process.env.WEBACY_API_KEY,
});
```

### TradingClient

For trading analysis (holder analysis, sniper detection):

```typescript theme={null}
import { TradingClient, Chain } from '@webacy-xyz/sdk';

const client = new TradingClient({
  apiKey: process.env.WEBACY_API_KEY,
});
```

## Configuration Options

Both clients accept the same configuration options:

```typescript theme={null}
const client = new ThreatClient({
  // Required
  apiKey: 'your-api-key',

  // Optional: Set a default chain for all requests
  defaultChain: Chain.ETH,

  // Optional: Enable debug logging
  debug: true, // or 'requests' | 'responses' | 'errors'

  // Optional: Custom base URL (for development)
  baseUrl: 'https://api-development.webacy.com',

  // Optional: Request timeout in milliseconds
  timeout: 30000,
});
```

### Default Chain

Set a default chain to avoid specifying it on every request:

```typescript theme={null}
const client = new ThreatClient({
  apiKey: process.env.WEBACY_API_KEY,
  defaultChain: Chain.ETH,
});

// No need to specify chain - uses ETH
const result = await client.addresses.analyze('0x...');

// Override for specific requests
const solResult = await client.addresses.analyze('So1...', {
  chain: Chain.SOL,
});
```

### Debug Mode

Enable logging to troubleshoot issues:

```typescript theme={null}
const client = new ThreatClient({
  apiKey: process.env.WEBACY_API_KEY,
  debug: true, // Log everything
});

// Or be more specific:
const client = new ThreatClient({
  apiKey: process.env.WEBACY_API_KEY,
  debug: 'requests',  // Only log outgoing requests
  // debug: 'responses', // Only log responses
  // debug: 'errors',    // Only log errors
});
```

<Warning>
  Never commit your API key to version control. Use environment variables or a secrets manager.
</Warning>

## Individual Packages

If you only need specific functionality, install individual packages to reduce bundle size:

| Package                                                                            | Install                               | Description         |
| ---------------------------------------------------------------------------------- | ------------------------------------- | ------------------- |
| [`@webacy-xyz/sdk-core`](https://www.npmjs.com/package/@webacy-xyz/sdk-core)       | `npm install @webacy-xyz/sdk-core`    | Core utilities only |
| [`@webacy-xyz/sdk-threat`](https://www.npmjs.com/package/@webacy-xyz/sdk-threat)   | `npm install @webacy-xyz/sdk-threat`  | Threat analysis     |
| [`@webacy-xyz/sdk-trading`](https://www.npmjs.com/package/@webacy-xyz/sdk-trading) | `npm install @webacy-xyz/sdk-trading` | Trading analysis    |

```typescript theme={null}
// Import from specific packages
import { ThreatClient } from '@webacy-xyz/sdk-threat';
import { TradingClient } from '@webacy-xyz/sdk-trading';
import { Chain, ValidationError } from '@webacy-xyz/sdk-core';
```

## TypeScript Configuration

The SDK is written in TypeScript and includes type definitions. For the best experience, ensure your `tsconfig.json` includes:

```json theme={null}
{
  "compilerOptions": {
    "moduleResolution": "bundler", // or "node16" / "nodenext"
    "esModuleInterop": true,
    "strict": true
  }
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="ThreatClient" icon="shield" href="/sdk/threat-client">
    Analyze addresses, contracts, and URLs
  </Card>

  <Card title="TradingClient" icon="chart-line" href="/sdk/trading-client">
    Holder analysis and trading insights
  </Card>
</CardGroup>
