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

# OptiSigns SDK QuickStart

> OptiSigns TypeScript SDK Quickstart

The OptiSigns TypeScript SDK provides a simple and intuitive way to manage your digital signage infrastructure programmatically. This documentation covers the main features and examples for common use cases.

## Installation

```bash theme={null}
npm install @optisigns/optisigns
```

## Authentication

Initialize the SDK with your API key. Obtain your key from the [account settings](https://app.optisigns.com/account-setting).

```typescript theme={null}
import { OptiSigns } from "@optisigns/optisigns";

const client = new OptiSigns("YOUR_API_KEY");
```

## Core Operations

### Devices

#### List All Devices

```typescript theme={null}
const devices = await client.devices.listAllDevices();
```

#### Find Device by Name

```typescript theme={null}
const device = await client.devices.findByDeviceName("Reception");
```

#### Get Device by ID

```typescript theme={null}
const device = await client.devices.getDeviceById("device_id");
```

#### Create New Device

```typescript theme={null}
const newDevice = await client.devices.createDevice({
  deviceName: "Reception Screen",
  orientation: "LANDSCAPE",
});
```

#### Update Device

```typescript theme={null}
await client.devices.updateDevice("device_id", {
  deviceName: "Updated Screen Name",
});
```

#### Delete Device

```typescript theme={null}
await client.devices.deleteDeviceById("device_id", "team_id");
```

### Content Management

#### Upload File Asset

```typescript theme={null}
const asset = await client.assets.uploadFileAsset(
  "./path/to/image.jpg",
  "team_id"
);
```

#### Create Website Asset

```typescript theme={null}
const websiteAsset = await client.assets.createWebsiteAppAsset(
  {
    url: "https://example.com",
    title: "Company Website",
  },
  "team_id"
);
```

#### Modify Asset Settings

```typescript theme={null}
await client.assets.modifyAssetSettings(
  "asset_id",
  {
    name: "Updated Asset Name",
    metadata: { key: "value" },
  },
  "team_id"
);
```

## Common Use Cases

### Managing Digital Screens

1. **Push Content to Screen:**

```typescript theme={null}
await client.devices.pushContentToDevice(
  "device_id",
  "content_id",
  "team_id",
  "NOW"
);
```

2. **Reboot Device:**

```typescript theme={null}
await client.devices.rebootDevice("device_id");
```

## Error Handling

The SDK uses TypeScript for better type safety and includes comprehensive error handling. Always wrap API calls in try-catch blocks:

```typescript theme={null}
try {
  const devices = await client.devices.listAllDevices();
  console.log(devices);
} catch (error) {
  console.error("Error fetching devices:", error);
}
```

## Best Practices

1. **Error Handling**: Always implement proper error handling in your applications
2. **Authentication**: Keep your API key secure and never expose it in client-side code
3. **TypeScript**: Take advantage of TypeScript types for better code completion and error detection
4. **Team ID**: Keep track of your team ID for operations that require it

## Code Examples

<CodeGroup>
  ```typescript Device Management theme={null}
  import { OptiSigns } from "@optisigns/optisigns";

  async function manageDevices() {
    const client = new OptiSigns("YOUR_API_KEY");

    try {
      // List all devices
      const devices = await client.devices.listAllDevices();

      // Create a new device
      const newDevice = await client.devices.createDevice({
        deviceName: "Reception Screen",
        orientation: "LANDSCAPE",
      });

      // Update device name
      await client.devices.updateDevice(newDevice.id, {
        deviceName: "Updated Screen Name",
      });
    } catch (error) {
      console.error("Error:", error);
    }
  }
  ```

  ```typescript Asset Management theme={null}
  import { OptiSigns } from "@optisigns/optisigns";

  async function manageAssets() {
    const client = new OptiSigns("YOUR_API_KEY");

    try {
      // Upload a new asset
      const asset = await client.assets.uploadFileAsset(
        "./path/to/image.jpg",
        "team_id"
      );

      // Create a website asset
      const websiteAsset = await client.assets.createWebsiteAppAsset(
        {
          url: "https://example.com",
          title: "Company Website",
        },
        "team_id"
      );

      // Modify asset settings
      await client.assets.modifyAssetSettings(
        asset.id,
        {
          name: "Updated Asset Name",
        },
        "team_id"
      );
    } catch (error) {
      console.error("Error:", error);
    }
  }
  ```
</CodeGroup>

For more detailed information, visit our [API Reference](/api-reference) or contact our support team at [support@optisigns.com](mailto:support@optisigns.com).
