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

# API Overview

> Use the Widgetic API to manage your widgets and compositions

The Widgetic API allows you to programmatically manage widgets, compositions, canvases, and more within your own account.

## Who Is This For?

This section is for developers who:

* Want to integrate Widgetic widgets into their applications
* Need to manage widgets programmatically
* Are building tools that interact with their Widgetic account

> [!NOTE]
>
> If you're a **partner** looking to embed the canvas in your platform, see the [Partner Documentation](https://docs.widgetic.com/docs/partners/overview.md) instead.

## API Key Types

Self-serve developers typically use:

| Key Prefix | Description |
| - | - |
| `wdg_org_` | Workspace API key: made in the dashboard, acts as the workspace, in that workspace only |

A workspace key works only while its workspace is on a paid plan: see [Keys and your workspace plan](https://docs.widgetic.com/docs/authentication.md#keys-and-your-workspace-plan).

## Core Resources

> [card] [Widgets](https://docs.widgetic.com/docs/api/widgets.md)
>
> Create and manage individual widgets

> [card] [Compositions](https://docs.widgetic.com/docs/api/compositions.md)
>
> Combine widgets into layouts

> [card] [Canvases](https://docs.widgetic.com/docs/api/canvases.md)
>
> Work with widget editing canvases

> [card] [Embedding](https://docs.widgetic.com/docs/api/embedding.md)
>
> Show published compositions on your site

## Quick Example

Here's how to fetch your widgets using the API:

```bash cURL theme={"theme":"css-variables"}
curl -X GET "https://api.widgetic.com/v1/widgets" \
  -H "Authorization: Bearer wdg_org_your_api_key"
```

```typescript TypeScript theme={"theme":"css-variables"}
import { WidgetsApi } from '@widgetic/api-sdk-ts';

const widgets = new WidgetsApi('wdg_org_your_api_key');

const { data, meta } = await widgets.getWidgets({
  page: 1,
  size: 20
});

console.log(`Found ${meta?.total} widgets`);
data.forEach(widget => {
  console.log(`- ${widget.name} (${widget.id})`);
});
```

## API Response Format

All API responses follow a consistent format:

### Success Response

```json theme={"theme":"css-variables"}
{
  "success": true,
  "data": { /* Resource or array of resources */ },
  "meta": {
    "page": 1,
    "size": 20,
    "total": 150,
    "hasNextPage": true,
    "hasPreviousPage": false
  }
}
```

### Error Response

```json theme={"theme":"css-variables"}
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Widget not found",
    "correlationId": "req_123e4567-e89b-12d3-a456-426614174000"
  }
}
```

## Pagination

List endpoints page their results with these parameters:

| Parameter | Type | Default | Description |
| - | - | - | - |
| `page` | integer | 1 | Page number (1-indexed) |
| `size` | integer | 20 | Items per page (max 100) |
| `sort` | string | varies | Sort field and direction (e.g., `created_at:desc`), on the lists that take it |

Each endpoint's reference page says which of these it accepts. `GET /widgets` takes `page` and `size` but not `sort` (it is always newest first), and it returns the whole list when you pass neither, so always page it when you do not know how many widgets an account holds.

Example:

```typescript theme={"theme":"css-variables"}
const { data, meta } = await widgets.getWidgets({
  page: 2,
  size: 50
});

if (meta?.hasNextPage) {
  // Fetch next page
}
```

## Rate Limits

API requests are counted per API key over a 15-minute window, and the allowance depends on your plan. A partner key is held to a ceiling of 1,000,000 requests per 15 minutes, which is there to stop a runaway loop, not to meter a platform. Read the allowance that applies to you from the `RateLimit-Limit` header of any response.

A request over the limit is refused with `429 Too Many Requests` and a `Retry-After` header.

See [Rate Limits](https://docs.widgetic.com/docs/reference/rate-limits.md) for more details.

## Idempotency

For state-changing requests (`POST`, `PATCH`, and `PUT` on the endpoints that document it), provide an idempotency key so a retry never runs the operation twice. Some endpoints, such as `POST /widgets`, require it:

```bash theme={"theme":"css-variables"}
curl -X POST "https://api.widgetic.com/v1/widgets" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: unique-request-id-123" \
  -d '{"name": "My Widget", "type": "chart", "content": {}}'
```

See [Idempotency](https://docs.widgetic.com/docs/reference/idempotency.md) for more details.

## Using an SDK

Widgetic publishes a library for TypeScript, Python, Go, Java, C#, Ruby, PHP and Bash. A library takes your API key, builds the request and hands you the answer as typed objects. Install the one for your language:

```bash TypeScript theme={"theme":"css-variables"}
npm install @widgetic/api-sdk-ts
```

```bash Python theme={"theme":"css-variables"}
pip install api-sdk-py
```

```bash Go theme={"theme":"css-variables"}
go get github.com/widgetic/api-sdk-go
```

```xml Java theme={"theme":"css-variables"}
<dependency>
  <groupId>com.widgetic</groupId>
  <artifactId>api-sdk-java</artifactId>
  <version>1.11.151</version>
</dependency>

<!-- Gradle: implementation("com.widgetic:api-sdk-java:1.11.151") -->
```

```bash C# theme={"theme":"css-variables"}
dotnet add package Widgetic.ApiSdk.Cs
```

```bash Ruby theme={"theme":"css-variables"}
gem install api-sdk-rb
```

```bash PHP theme={"theme":"css-variables"}
composer require widgetic/api-sdk-php
```

Then [make a first call](https://docs.widgetic.com/docs/sdks/getting-started.md#3-make-a-first-call), or read what [the libraries](https://docs.widgetic.com/docs/sdks/overview.md) are and how their versions work.

## Next Steps

**1. Explore Widgets**

Learn how to [create and manage widgets](https://docs.widgetic.com/docs/api/widgets.md)

**2. Build Compositions**

Combine widgets into [compositions](https://docs.widgetic.com/docs/api/compositions.md)

**3. Check API Reference**

Browse the complete [API Reference](https://docs.widgetic.com/api-reference/introduction.md)

**4. Call it from your language**

Use an [SDK](https://docs.widgetic.com/docs/sdks/overview.md) for TypeScript, Python, Go, Java, C#, Ruby or PHP


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.