# Install SDKs and CLI

Install the JavaScript, Python and Go SDKs and the Longplay CLI, check runtimes, and make a first request.

Last updated: 2026-11-06

[Web version](https://www.longplayai.com/docs/install)

<a id="choose"></a>

## Choose a client

Longplay is the current public integration name; the Longplay packages and native coordinates below are published. Previously published Indiana packages and downloads remain immutable; the CLI installs only the `longplay` command and the `indiana` alias is retired. Preserve configuration and credentials when migrating.

The product is called Longplay. The installation commands and examples below use the actual published package names, commands, and protocol identifiers.

Every client speaks HTTP protocol 0.10. These examples use production API https://api.longplayai.com with that deployment's Sandbox App/Key. Sandbox is still production data. Keep Server Keys on trusted backends; browsers and apps use backend-issued Customer sessions.

**Installable clients**

| Client | Package | Version | Runtime | Coverage |
| --- | --- | --- | --- | --- |
| JavaScript / TypeScript | `@tinkerlandai/longplay-sdk` (npm) | Latest stable | Node.js 22+ backends, browsers | All server and browser capabilities: Customers, entitlements, balances, payments, offers, Features, Funnels, Paywalls, page experiments and screen rendering |
| Web SDK (script) | `https://cdn.longplayai.com/sdk/module` | Latest Web release | Browsers, no npm required | The same browser SDK's entitlements, events, content, Paywalls, Funnels and page experiments |
| IAM | `@tinkerlandai/longplay-iam` (npm) | 0.7.10 | Node.js 22+ | Build-time App page map generation, validation and upload |
| Python | `tinkerlandai-longplay-sdk` (import `longplay`) | Latest stable | Python 3.11+ | Server SDK with sync and async clients; see the platform support table for capabilities |
| Go | `longplayai.com/sdk/go` | Latest stable | Go 1.23+ | Server SDK with a goroutine-safe client; see the platform support table for capabilities |
| Longplay CLI | `longplay` | 0.3.23 | Node.js 22+ | Console management, document validation and code-reference scanning |
| React Native | `@tinkerlandai/longplay-react-native` (npm) | Latest stable | React Native 0.79+ / Metro 0.82+ | Customer identity, holdings, entitlement checks, commerce commands, Offering/Paywall/content resolution, experiments and events; optional native integration adds Funnel/Paywall/content presentation and store purchase/restore; trusted usage writes go through the backend |
| iOS / macOS (Swift) | `tinkerlandai.longplay` (SwiftPM registry) | Latest stable | Swift 6 / iOS 16+ / macOS 12+ | Customer identity, entitlement and Feature reads, Funnel/Paywall/content presentation, store purchase and restore, events and push; trusted usage writes go through the backend |
| Android (Kotlin) | `ai.tinkerland:longplay-sdk` (Maven) | Latest stable | minSdk 23 / Java 17 | Customer identity, entitlement and Feature reads, Funnel/Paywall/content presentation, store purchase and restore, events and push; trusted usage writes go through the backend |

For Python and Go server capabilities and runtime prerequisites, consult the platform support table and each language guide. HTTP reference pages list the method for each operation. Confirm that your chosen SDK version supports the operation, and use the Server Key or Run credential required by its guide. Available operations without a Python or Go method can be called through the HTTP API with the same headers, credentials and error format.

- [Platform and capability support](https://www.longplayai.com/docs/guides/platforms.md)

<a id="javascript"></a>

## JavaScript / TypeScript

Install the latest stable release, then commit exact dependencies and lockfiles. https://cdn.longplayai.com/sdk/longplay/stable resolves the stable version for the selected package; without the package parameter it stays on the last bundled release that older installers rely on, which is not any package's latest version, so always pass the parameter. These examples use protocol 0.10 at https://api.longplayai.com; check the target protocol, API origin and credentials together when changing deployments.

**npm**

```bash
npm install --save-exact @tinkerlandai/longplay-sdk@latest
```

**pnpm**

```bash
pnpm add --save-exact @tinkerlandai/longplay-sdk@latest
```

**yarn**

```bash
yarn add --exact @tinkerlandai/longplay-sdk@latest
```

**Entry points**

| Import | Runs in | Purpose |
| --- | --- | --- |
| `@tinkerlandai/longplay-sdk/server` | Trusted backend | Server Key client, session issuing, Funnel start and decisions, Paywall start and AI usage |
| `@tinkerlandai/longplay-sdk` | Browser | Customer Token client, Features, Funnel and Paywall display |
| `@tinkerlandai/longplay-sdk/page` | Browser | Anonymous URL redirect experiments |
| `@tinkerlandai/longplay-sdk/visual` | Browser | Anonymous visual experiments |
| `@tinkerlandai/longplay-sdk/popup` | Browser | Standalone screen rendering, sanitizing and previews |
| `@tinkerlandai/longplay-sdk/native-shell` | WebView | Funnel shell assets for native WebViews |
| `@tinkerlandai/longplay-sdk/openrouter` | Trusted backend | OpenRouter usage billing; also install `@openrouter/sdk` |

The package ships type declarations and supports ESM bundlers and Node.js 22+. Use Vite, Next.js or webpack, or await `Longplay.ready` from the unified script entry; see Script installation in the JavaScript guide. Never import `/server` into browser code.

<a id="web-script"></a>

## Web SDK: script installation

Plain HTML sites resolve and save an immutable Web module at installation. Loading alone does not create a session or start experiments. The complete example covers backend-issued Customer Tokens and logout cleanup.

**terminal**

```bash
SDK_MODULE_URL="$(curl -fsS https://cdn.longplayai.com/sdk/module)" &&
printf 'export * from "%s";\n' "$SDK_MODULE_URL" > longplay-sdk.js
```

Commit the generated longplay-sdk.js, which points to an immutable module URL. Resolve again explicitly to upgrade. The classic /sdk.js loader still follows Web releases.

Pages that show a Funnel or Paywall can open their connections early. Put these two lines in the page head. `crossorigin` is required: the SDK sends requests without credentials, so a preconnect without it opens a connection the SDK cannot use.

**index.html**

```html
<link rel="preconnect" href="https://api.longplayai.com" crossorigin>
<link rel="preconnect" href="https://cdn.longplayai.com" crossorigin>
```

- [Script installation example](https://www.longplayai.com/docs/sdk/javascript.md#script)

<a id="iam"></a>

## IAM build tooling

**terminal**

```bash
npm install --save-dev --save-exact @tinkerlandai/longplay-iam@0.7.10
```

IAM is versioned independently of the business SDK. Configure generation and local checks first, authorize uploads separately, and explicitly bind the browser to that build's descriptor.

- [IAM build integration](https://www.longplayai.com/docs/iam.md)

<a id="python"></a>

## Python

The Python SDK is distributed from longplayai.com, not PyPI. The distribution is `tinkerlandai-longplay-sdk` and the import is `longplay`. Other dependencies install from your configured package index as usual.

**pip**

```bash
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=python')" &&
python -m pip install "https://cdn.longplayai.com/downloads/python/tinkerlandai_longplay_sdk-$SDK_VERSION-py3-none-any.whl" &&
python -m pip freeze > requirements.lock
```

**uv**

```bash
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=python')" &&
uv add "tinkerlandai-longplay-sdk @ https://cdn.longplayai.com/downloads/python/tinkerlandai_longplay_sdk-$SDK_VERSION-py3-none-any.whl"
```

**requirements.lock: install from lock**

```bash
python -m pip install -r requirements.lock
```

https://cdn.longplayai.com/sdk/python lists each version's wheel and source archive with their SHA-256. Check the installed version:

**terminal**

```bash
python -c "import longplay; print(longplay.__version__, longplay.PROTOCOL_VERSION)"
```

<a id="go"></a>

## Go

The module path is `longplayai.com/sdk/go`. Install it through Go's default module proxy and checksum database; no repository access is needed.

**terminal**

```bash
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=go')" &&
go get longplayai.com/sdk/go@v"$SDK_VERSION"
```

**main.go**

```go
import longplay "longplayai.com/sdk/go"
```

With `GOPROXY=direct`, Go discovers the same module download through https://longplayai.com/sdk/go?go-get=1. Check the version with `go list -m longplayai.com/sdk/go`.

<a id="lock"></a>

## Lock dependencies and upgrade

Resolve stable only during initial installation or an explicit upgrade. Commit the resolved versions and lockfiles; later builds use those files without querying latest again.

**Files to commit**

| Platform | Exact dependencies and lockfiles |
| --- | --- |
| JavaScript / React Native | package.json, package-lock.json (or pnpm-lock.yaml / yarn.lock) |
| Web module | longplay-sdk.js |
| Python | requirements.lock, or pyproject.toml + uv.lock |
| Go | go.mod, go.sum |
| SwiftPM | Package.swift, Package.resolved, .swiftpm/configuration/registries.json |
| Android | longplay-sdk.version, app/gradle.lockfile |

To upgrade, rerun stable resolution, review the version change and commit updated dependencies and lockfiles. To roll back, restore previous files or select an explicit historical version.

<a id="history"></a>

## Historical installs and rollback

Default installs resolve stable. For historical installation or rollback, choose an explicit version and restore its dependencies and lockfiles; the examples below use each package's current published version; package versions are independent. Versioned downloads and registry/Maven records remain immutable when stable advances.

**JavaScript**

```bash
npm install --save-exact @tinkerlandai/longplay-sdk@0.10.41
```

**React Native**

```bash
npm install --save-exact @tinkerlandai/longplay-react-native@0.10.25
```

**Python**

```bash
python -m pip install "https://cdn.longplayai.com/downloads/python/tinkerlandai_longplay_sdk-0.10.27-py3-none-any.whl"
```

**Go**

```bash
go get longplayai.com/sdk/go@v0.10.25
```

**Swift: Package.swift**

```swift
.package(id: "tinkerlandai.longplay", exact: "0.10.25")
```

**Kotlin: app/build.gradle.kts**

```kotlin
implementation("ai.tinkerland:longplay-sdk:0.10.25")
```

<a id="cli"></a>

## Longplay CLI

The CLI requires Node.js 22+. Install the independently versioned management tool from npm:

**terminal**

```bash
npm install -g @tinkerlandai/longplay-cli@0.3.23
longplay --version
```

On macOS and Linux, curl can also download the complete platform archive and verify SHA-256 without npm or sudo. This channel has its own version in the website download manifest:

**terminal**

```bash
curl -fsSL https://cdn.longplayai.com/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
longplay --version
```

Afterwards, `longplay update` upgrades in place from the original installation channel and keeps configuration and credentials. An npm release does not update website archives.

<a id="react-native"></a>

## Install the React Native SDK

Install the independent npm package from latest. Requires React Native 0.79+, Metro 0.82+ and package exports support. --save-exact writes the resolved version to package.json; commit the lockfile and use npm ci afterward.

**terminal**

```bash
npm install --save-exact @tinkerlandai/longplay-react-native@latest
npm ls @tinkerlandai/longplay-react-native --depth=0
```

Import `createLongplayReactNative` from `@tinkerlandai/longplay-react-native`. The package includes ESM, CommonJS and TypeScript declarations, and its data client uses Fetch and AbortController with no native linking; optional native integration is added through autolinking.

The independent package and the `@tinkerlandai/longplay-sdk/react-native` subpath share the same core implementation; choose one entry per app. Both cover Customer identity, holdings, entitlement checks, commerce commands, Offering/Paywall/content resolution, experiments and events. The independent package's optional native integration adds Funnel/Paywall/content presentation and Apple/Google purchase, restore and subscription-management bridges. Trusted usage writes still go through the backend.

<a id="native"></a>

## iOS and Android

Native packages are distributed through Longplay's Swift Package Registry and Maven repository without source repository access. Clients receive backend-issued Customer Tokens and never carry a Server Key; trusted usage writes go through the app's own backend.

- [Native SDK integration](https://www.longplayai.com/docs/sdk/native.md)

<a id="ios"></a>

## iOS / macOS: SwiftPM

Requires Swift 6, iOS 16+ or macOS 12+. Resolve the latest stable release in the consuming Swift package and write an exact dependency to Package.swift. No GitHub repository access is needed.

**terminal**

```bash
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=ios')" &&
swift package-registry set --scope tinkerlandai https://cdn.longplayai.com/sdk/ios &&
swift package add-dependency tinkerlandai.longplay --type registry --exact "$SDK_VERSION"
```

The command writes the exact package version. Add the Longplay product to your target dependencies in Package.swift:

**Package.swift**

```swift
.product(name: "Longplay", package: "tinkerlandai.longplay")
```

**terminal**

```bash
swift package resolve
swift package show-dependencies
```

Use `import Longplay` in application code. This uses Swift Package Registry: declare the dependency in a Swift package, then add that package's product to the Xcode app target. Commit Package.swift, Package.resolved and registry configuration; use swift package resolve --force-resolved-versions in CI. Resolve stable again explicitly when upgrading.

<a id="android"></a>

## Android: Maven

Requires minSdk 23, Java 17 and android.useAndroidX=true in gradle.properties. Resolve stable once at the project root into longplay-sdk.version; builds read that exact version without querying the network.

Add the Longplay repository to dependencyResolutionManagement.repositories in settings.gradle.kts, alongside google() and mavenCentral():

**settings.gradle.kts**

```kotlin
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("https://cdn.longplayai.com/sdk/android")
            content { includeGroup("ai.tinkerland") }
        }
    }
}
```

**terminal**

```bash
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=android')" &&
printf '%s\n' "$SDK_VERSION" > longplay-sdk.version
```

**app/build.gradle.kts**

```kotlin
val longplaySdkVersion = rootProject.file("longplay-sdk.version").readText().trim()

dependencyLocking {
    lockAllConfigurations()
}

dependencies {
    implementation("ai.tinkerland:longplay-sdk:$longplaySdkVersion")
}
```

**terminal**

```bash
./gradlew :app:dependencies --configuration debugRuntimeClasspath --write-locks
```

Import `ai.tinkerland.longplay.LongplayClient` in application code. Gradle reads the POM and module metadata and downloads the AAR; other dependencies remain on Google or Maven Central. Commit longplay-sdk.version and app/gradle.lockfile; omit --write-locks from normal builds. Resolve stable and update locks explicitly when upgrading.

<a id="first-request"></a>

## First request

Create a Sandbox Server Key with `customers:write` in Console, put the variables below in a Git-ignored backend `.env`, and run one of the examples. Success returns a Customer UUID; running it again returns the same Customer with `created` false.

**.env**

```bash
LONGPLAY_API_URL=https://api.longplayai.com
LONGPLAY_SERVER_KEY=<SERVER_KEY>
LONGPLAY_PROJECT_ID=<APP_UUID>
```

**TypeScript: first-request.ts**

```ts
import { createLongplayServer } from "@tinkerlandai/longplay-sdk/server";

const longplay = createLongplayServer({
  baseUrl: process.env.LONGPLAY_API_URL!,
  apiKey: process.env.LONGPLAY_SERVER_KEY!,
  scope: { projectId: process.env.LONGPLAY_PROJECT_ID!, environment: "sandbox" },
});

async function main() {
  const { customer, created } = await longplay.getOrCreateCustomer({
    externalUserId: "user-42",
  });
  console.log(customer.id, created);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
```

**Python: first_request.py**

```python
import os

from longplay import Longplay

with Longplay(
    api_key=os.environ["LONGPLAY_SERVER_KEY"],
    project_id=os.environ["LONGPLAY_PROJECT_ID"],
    environment="sandbox",
    base_url=os.environ["LONGPLAY_API_URL"],
) as client:
    result = client.get_or_create_customer(external_user_id="user-42")
    print(result["customer"]["id"], result["created"])
```

**Go: main.go**

```go
package main

import (
	"context"
	"log"
	"os"

	longplay "longplayai.com/sdk/go"
)

func main() {
	client, err := longplay.NewClient(longplay.Config{
		APIKey:      os.Getenv("LONGPLAY_SERVER_KEY"),
		ProjectID:   os.Getenv("LONGPLAY_PROJECT_ID"),
		Environment: longplay.Sandbox,
		BaseURL:     os.Getenv("LONGPLAY_API_URL"),
	})
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	result, err := client.GetOrCreateCustomer(context.Background(), longplay.CreateCustomerParams{
		ExternalUserID: longplay.Ptr("user-42"),
	})
	if err != nil {
		log.Fatal(err)
	}
	log.Println(result.Customer.ID, result.Created)
}
```

**HTTP: curl**

```bash
curl -sS -X POST "$LONGPLAY_API_URL/api/v1/customers" \
  -H "Authorization: Bearer $LONGPLAY_SERVER_KEY" \
  -H "X-Indiana-Protocol: 0.10" \
  -H "Content-Type: application/json" \
  -d '{"externalUserId":"user-42"}'
```

- 401: the Key is incomplete, expired or revoked. 403: the Key lacks `customers:write`, or the App UUID or environment does not match the Key. Server Key requests must not carry a browser Origin.
- 400 `UNSUPPORTED_PROTOCOL_VERSION`: add the `X-Indiana-Protocol` header to direct HTTP calls; the SDKs send it automatically.

- [Create a Server Key](https://www.longplayai.com/docs/guides/server-auth.md)
- [Environments](https://www.longplayai.com/docs/guides/environments.md)
- [Customers and sessions](https://www.longplayai.com/docs/guides/customers.md)
