> ## 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.

# Get started with an SDK

> Install a Widgetic library, set your API key and make a first call in TypeScript, Python, Go, Java, C#, Ruby or PHP

This page takes you from nothing to a first call. Pick your language in any tab: every example on the SDK pages follows it.

## 1. Install the library

```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
```

> [!NOTE]
>
> **Does npm warn about the Node.js version (`EBADENGINE`)?** The TypeScript package declares Node.js 26.12.1 or later, which is more than the code needs: it runs on Node.js 18 or later. We ran 3.1.1 on Node.js 18, 20, 22, 24 and 26; Node.js 16 fails because it has no built-in `fetch`. npm only warns on an older Node.js, and refuses to install only when `engine-strict` is on.

What each library needs, and the version you get, is in [The libraries](https://docs.widgetic.com/docs/sdks/overview.md#the-libraries). The Bash library is one script, not a package: its [README](https://github.com/widgetic/api-sdk-bash) says how to install it.

## 2. Make an API key

Open [**Settings → API keys**](https://widgetic.com/workspaces?settings=api-keys) in the workspace you want to work in (the link opens the one you used last, or your first) and select **Create key**. Give it a name and choose what it may do: Full access, or a limit to what your application needs (see [Choose how much a key may do](https://docs.widgetic.com/docs/api-keys.md#choose-how-much-a-key-may-do)). The key starts with `wdg_org_`, and it works in the workspace it was made in. Keep it in an environment variable, so it never lands in your code or your repository:

```bash theme={"theme":"css-variables"}
export WIDGETIC_API_KEY=wdg_org_your_api_key_here
```

> [!NOTE]
>
> Platforms that run Widgetic for their own customers use a second kind of key, a partner key. It is sent the same way. See [API keys](https://docs.widgetic.com/docs/api-keys.md) for the two kinds, and [API classes](https://docs.widgetic.com/docs/sdks/api-classes.md#which-key-a-class-needs) for the classes that need a partner key.

## 3. Make a first call

This lists the widgets your workspace owns, one page of 20. A new workspace has none yet, so the list can be empty.

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

const widgetsApi = new WidgetsApi(process.env.WIDGETIC_API_KEY!);

const result = await widgetsApi.getWidgets({
  page: 1,
  size: 20,
});
console.log(result);
```

```python Python theme={"theme":"css-variables"}
import os

import api_sdk_py

configuration = api_sdk_py.Configuration(access_token=os.environ["WIDGETIC_API_KEY"])

with api_sdk_py.ApiClient(configuration) as api_client:
    widgets_api = api_sdk_py.WidgetsApi(api_client)
    result = widgets_api.get_widgets(page=1, size=20)
    print(result)
```

```go Go theme={"theme":"css-variables"}
package main

import (
	"context"
	"fmt"
	"os"

	widgetic "github.com/widgetic/api-sdk-go"
)

func main() {
	ctx := context.WithValue(context.Background(), widgetic.ContextAccessToken, os.Getenv("WIDGETIC_API_KEY"))
	client := widgetic.NewAPIClient(widgetic.NewConfiguration())

	result, _, err := client.WidgetsAPI.GetWidgets(ctx).Page(1).Size(20).Execute()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
	fmt.Println(result)
}
```

```java Java theme={"theme":"css-variables"}
import com.widgetic.api.ApiClient;
import com.widgetic.api.ApiException;
import com.widgetic.api.Configuration;
import com.widgetic.api.api.WidgetsApi;

public class Example {
    public static void main(String[] args) throws ApiException {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBearerToken(System.getenv("WIDGETIC_API_KEY"));

        WidgetsApi widgetsApi = new WidgetsApi(client);

        var result = widgetsApi.getWidgets(1, 20, null, null, null);
        System.out.println(result);
    }
}
```

```csharp C# theme={"theme":"css-variables"}
using System;
using Widgetic.ApiSdk.Cs.Api;
using Widgetic.ApiSdk.Cs.Client;

var configuration = new Configuration
{
    AccessToken = Environment.GetEnvironmentVariable("WIDGETIC_API_KEY")!,
};
var widgetsApi = new WidgetsApi(configuration);

var result = widgetsApi.GetWidgets(page: 1, size: 20);
Console.WriteLine(result);
```

```ruby Ruby theme={"theme":"css-variables"}
require 'api-sdk-rb'

ApiSdkRb.configure do |config|
  config.access_token = ENV['WIDGETIC_API_KEY']
end

widgets_api = ApiSdkRb::WidgetsApi.new

result = widgets_api.get_widgets(page: 1, size: 20)
puts result
```

```php PHP theme={"theme":"css-variables"}
<?php

require_once __DIR__ . '/vendor/autoload.php';

use WidgeticApi\Api\WidgetsApi;
use WidgeticApi\Configuration;

$config = Configuration::getDefaultConfiguration()->setAccessToken(getenv('WIDGETIC_API_KEY'));
$widgetsApi = new WidgetsApi(new GuzzleHttp\Client(), $config);

$result = $widgetsApi->getWidgets(page: 1, size: 20);
print_r($result);
```

> [!NOTE]
>
> The Java samples use `var` and text blocks, so they need Java 15 or later. The library itself runs on Java 8.

The call returns what the API sends: `success`, `data` and, for a list, `meta`. See [Pagination](https://docs.widgetic.com/api-reference/pagination.md#response-format) for the shape. If the call fails instead, read [Requests and errors](https://docs.widgetic.com/docs/sdks/requests-and-errors.md#handle-errors).

## Set the address and a timeout

A library sends every call to `https://api.widgetic.com/v1`, so there is nothing to set. Two things are worth setting in a service: a timeout, because the default comes from each language's HTTP client and some wait for ever, and the key, read from the environment as above. Here both are set, with the address spelled out:

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

const configuration = new Configuration({
  basePath: 'https://api.widgetic.com/v1', // the default
  accessToken: process.env.WIDGETIC_API_KEY,
});
const widgetsApi = new WidgetsApi(configuration);

// Stop waiting after 10 seconds: the second argument of every call goes to fetch
const result = await widgetsApi.getWidgets({ page: 1, size: 20 }, { signal: AbortSignal.timeout(10_000) });
console.log(result.data.length);
```

```python Python theme={"theme":"css-variables"}
import os

import api_sdk_py

configuration = api_sdk_py.Configuration(
    host="https://api.widgetic.com/v1",  # the default
    access_token=os.environ["WIDGETIC_API_KEY"],
)

with api_sdk_py.ApiClient(configuration) as api_client:
    widgets_api = api_sdk_py.WidgetsApi(api_client)

    # Stop waiting after 10 seconds
    result = widgets_api.get_widgets(page=1, size=20, _request_timeout=10)
    print(len(result.data))
```

```go Go theme={"theme":"css-variables"}
package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"

	widgetic "github.com/widgetic/api-sdk-go"
)

func main() {
	configuration := widgetic.NewConfiguration()
	configuration.Servers = widgetic.ServerConfigurations{{URL: "https://api.widgetic.com/v1"}} // the default
	configuration.HTTPClient = &http.Client{Timeout: 10 * time.Second}                          // the default waits for ever

	client := widgetic.NewAPIClient(configuration)
	ctx := context.WithValue(context.Background(), widgetic.ContextAccessToken, os.Getenv("WIDGETIC_API_KEY"))

	result, _, err := client.WidgetsAPI.GetWidgets(ctx).Page(1).Size(20).Execute()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(len(result.Data))
}
```

```java Java theme={"theme":"css-variables"}
import com.widgetic.api.ApiClient;
import com.widgetic.api.ApiException;
import com.widgetic.api.Configuration;
import com.widgetic.api.api.WidgetsApi;

public class Configure {
    public static void main(String[] args) throws ApiException {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://api.widgetic.com/v1"); // the default
        client.setBearerToken(System.getenv("WIDGETIC_API_KEY"));
        client.setConnectTimeout(10_000); // milliseconds
        client.setReadTimeout(10_000);

        WidgetsApi widgetsApi = new WidgetsApi(client);

        var result = widgetsApi.getWidgets(1, 20, null, null, null);
        System.out.println(result.getData().size());
    }
}
```

```csharp C# theme={"theme":"css-variables"}
using System;
using Widgetic.ApiSdk.Cs.Api;
using Widgetic.ApiSdk.Cs.Client;

var configuration = new Configuration
{
    BasePath = "https://api.widgetic.com/v1", // the default
    AccessToken = Environment.GetEnvironmentVariable("WIDGETIC_API_KEY")!,
    Timeout = 10_000, // milliseconds
};
var widgetsApi = new WidgetsApi(configuration);

var result = widgetsApi.GetWidgets(page: 1, size: 20);
Console.WriteLine(result.Data.Count);
```

```ruby Ruby theme={"theme":"css-variables"}
require 'api-sdk-rb'

ApiSdkRb.configure do |config|
  config.access_token = ENV['WIDGETIC_API_KEY']
  config.scheme = 'https'          # the default
  config.host = 'api.widgetic.com' # the default
  config.base_path = '/v1'         # the default
  config.timeout = 10              # seconds; the default, 0, waits for ever
end

widgets_api = ApiSdkRb::WidgetsApi.new
result = widgets_api.get_widgets(page: 1, size: 20)
puts result.data.length
```

```php PHP theme={"theme":"css-variables"}
<?php

require_once __DIR__ . '/vendor/autoload.php';

use GuzzleHttp\Client;
use WidgeticApi\Api\WidgetsApi;
use WidgeticApi\Configuration;

$config = Configuration::getDefaultConfiguration()
    ->setHost('https://api.widgetic.com/v1') // the default
    ->setAccessToken(getenv('WIDGETIC_API_KEY'));

// Any Guzzle client works: this one gives up after 10 seconds
$widgetsApi = new WidgetsApi(new Client(['timeout' => 10]), $config);

$result = $widgetsApi->getWidgets(page: 1, size: 20);
echo count($result->getData()), PHP_EOL;
```

A few classes live outside `/v1`. The public embed routes (`PublicEmbedApi`) answer at `https://api.widgetic.com/embed`, so the samples of that class set the address to `https://api.widgetic.com`.

## Next steps

> [card] [Requests and errors](https://docs.widgetic.com/docs/sdks/requests-and-errors.md)
>
> Page through a list, create something safely, and handle a failed call

> [card] [API classes](https://docs.widgetic.com/docs/sdks/api-classes.md)
>
> Find the class and the method for an endpoint

> [card] [Authentication](https://docs.widgetic.com/docs/authentication.md)
>
> The kinds of key, and limiting what a key can do

> [card] [API reference](https://docs.widgetic.com/api-reference/introduction.md)
>
> Every endpoint, with a sample in your language


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