Skip to content
Longplay
Docs
Browse docs / Install SDKs and CLI

Install SDKs and CLI

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

Markdown
API v1Updated

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
ClientPackageVersionRuntimeCoverage
JavaScript / TypeScript@tinkerlandai/longplay-sdk (npm)Latest stableNode.js 22+ backends, browsersAll 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/moduleLatest Web releaseBrowsers, no npm requiredThe same browser SDK's entitlements, events, content, Paywalls, Funnels and page experiments
IAM@tinkerlandai/longplay-iam (npm)0.7.10Node.js 22+Build-time App page map generation, validation and upload
Pythontinkerlandai-longplay-sdk (import longplay)Latest stablePython 3.11+Server SDK with sync and async clients; see the platform support table for capabilities
Golongplayai.com/sdk/goLatest stableGo 1.23+Server SDK with a goroutine-safe client; see the platform support table for capabilities
Longplay CLIlongplay0.3.23Node.js 22+Console management, document validation and code-reference scanning
React Native@tinkerlandai/longplay-react-native (npm)Latest stableReact 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 stableSwift 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 stableminSdk 23 / Java 17Customer identity, entitlement and Feature reads, Funnel/Paywall/content presentation, store purchase and restore, events and push; trusted usage writes go through the backend

Installable clients

  • JavaScript / TypeScript

    Package
    @tinkerlandai/longplay-sdk (npm)
    Version
    Latest stable
    Runtime
    Node.js 22+ backends, browsers
    Coverage
    All server and browser capabilities: Customers, entitlements, balances, payments, offers, Features, Funnels, Paywalls, page experiments and screen rendering
  • Web SDK (script)

    Package
    https://cdn.longplayai.com/sdk/module
    Version
    Latest Web release
    Runtime
    Browsers, no npm required
    Coverage
    The same browser SDK's entitlements, events, content, Paywalls, Funnels and page experiments
  • IAM

    Package
    @tinkerlandai/longplay-iam (npm)
    Version
    0.7.10
    Runtime
    Node.js 22+
    Coverage
    Build-time App page map generation, validation and upload
  • Python

    Package
    tinkerlandai-longplay-sdk (import longplay)
    Version
    Latest stable
    Runtime
    Python 3.11+
    Coverage
    Server SDK with sync and async clients; see the platform support table for capabilities
  • Go

    Package
    longplayai.com/sdk/go
    Version
    Latest stable
    Runtime
    Go 1.23+
    Coverage
    Server SDK with a goroutine-safe client; see the platform support table for capabilities
  • Longplay CLI

    Package
    longplay
    Version
    0.3.23
    Runtime
    Node.js 22+
    Coverage
    Console management, document validation and code-reference scanning
  • React Native

    Package
    @tinkerlandai/longplay-react-native (npm)
    Version
    Latest stable
    Runtime
    React Native 0.79+ / Metro 0.82+
    Coverage
    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)

    Package
    tinkerlandai.longplay (SwiftPM registry)
    Version
    Latest stable
    Runtime
    Swift 6 / iOS 16+ / macOS 12+
    Coverage
    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)

    Package
    ai.tinkerland:longplay-sdk (Maven)
    Version
    Latest stable
    Runtime
    minSdk 23 / Java 17
    Coverage
    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.

Related: Platform and capability support

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.

npmShell
npm install --save-exact @tinkerlandai/longplay-sdk@latest
Entry points
ImportRuns inPurpose
@tinkerlandai/longplay-sdk/serverTrusted backendServer Key client, session issuing, Funnel start and decisions, Paywall start and AI usage
@tinkerlandai/longplay-sdkBrowserCustomer Token client, Features, Funnel and Paywall display
@tinkerlandai/longplay-sdk/pageBrowserAnonymous URL redirect experiments
@tinkerlandai/longplay-sdk/visualBrowserAnonymous visual experiments
@tinkerlandai/longplay-sdk/popupBrowserStandalone screen rendering, sanitizing and previews
@tinkerlandai/longplay-sdk/native-shellWebViewFunnel shell assets for native WebViews
@tinkerlandai/longplay-sdk/openrouterTrusted backendOpenRouter usage billing; also install @openrouter/sdk

Entry points

  • @tinkerlandai/longplay-sdk/server

    Runs in
    Trusted backend
    Purpose
    Server Key client, session issuing, Funnel start and decisions, Paywall start and AI usage
  • @tinkerlandai/longplay-sdk

    Runs in
    Browser
    Purpose
    Customer Token client, Features, Funnel and Paywall display
  • @tinkerlandai/longplay-sdk/page

    Runs in
    Browser
    Purpose
    Anonymous URL redirect experiments
  • @tinkerlandai/longplay-sdk/visual

    Runs in
    Browser
    Purpose
    Anonymous visual experiments
  • @tinkerlandai/longplay-sdk/popup

    Runs in
    Browser
    Purpose
    Standalone screen rendering, sanitizing and previews
  • @tinkerlandai/longplay-sdk/native-shell

    Runs in
    WebView
    Purpose
    Funnel shell assets for native WebViews
  • @tinkerlandai/longplay-sdk/openrouter

    Runs in
    Trusted backend
    Purpose
    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.

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.

terminalShell
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.htmlHTML
<link rel="preconnect" href="https://api.longplayai.com" crossorigin><link rel="preconnect" href="https://cdn.longplayai.com" crossorigin>

Related: Script installation example

IAM build tooling#

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

Related: IAM build integration

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.

pipShell
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

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

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

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.

terminalShell
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=go')" &&go get longplayai.com/sdk/go@v"$SDK_VERSION"
main.goGo
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.

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
PlatformExact dependencies and lockfiles
JavaScript / React Nativepackage.json, package-lock.json (or pnpm-lock.yaml / yarn.lock)
Web modulelongplay-sdk.js
Pythonrequirements.lock, or pyproject.toml + uv.lock
Gogo.mod, go.sum
SwiftPMPackage.swift, Package.resolved, .swiftpm/configuration/registries.json
Androidlongplay-sdk.version, app/gradle.lockfile

Files to commit

  • JavaScript / React Native

    Exact dependencies and lockfiles
    package.json, package-lock.json (or pnpm-lock.yaml / yarn.lock)
  • Web module

    Exact dependencies and lockfiles
    longplay-sdk.js
  • Python

    Exact dependencies and lockfiles
    requirements.lock, or pyproject.toml + uv.lock
  • Go

    Exact dependencies and lockfiles
    go.mod, go.sum
  • SwiftPM

    Exact dependencies and lockfiles
    Package.swift, Package.resolved, .swiftpm/configuration/registries.json
  • Android

    Exact dependencies and lockfiles
    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.

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.

JavaScriptShell
npm install --save-exact @tinkerlandai/longplay-sdk@0.10.41

Longplay CLI#

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

terminalShell
npm install -g @tinkerlandai/longplay-cli@0.3.23longplay --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:

terminalShell
curl -fsSL https://cdn.longplayai.com/install.sh | shexport 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.

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.

terminalShell
npm install --save-exact @tinkerlandai/longplay-react-native@latestnpm 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.

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.

Related: Native SDK integration

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.

terminalShell
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.swiftSwift
.product(name: "Longplay", package: "tinkerlandai.longplay")
terminalShell
swift package resolveswift 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.

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.ktsKotlin
dependencyResolutionManagement {    repositories {        google()        mavenCentral()        maven {            url = uri("https://cdn.longplayai.com/sdk/android")            content { includeGroup("ai.tinkerland") }        }    }}
terminalShell
SDK_VERSION="$(curl -fsS 'https://cdn.longplayai.com/sdk/longplay/stable?package=android')" &&printf '%s\n' "$SDK_VERSION" > longplay-sdk.version
app/build.gradle.ktsKotlin
val longplaySdkVersion = rootProject.file("longplay-sdk.version").readText().trim() dependencyLocking {    lockAllConfigurations()} dependencies {    implementation("ai.tinkerland:longplay-sdk:$longplaySdkVersion")}
terminalShell
./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.

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.

.envShell
LONGPLAY_API_URL=https://api.longplayai.comLONGPLAY_SERVER_KEY=<SERVER_KEY>LONGPLAY_PROJECT_ID=<APP_UUID>
first-request.tsTypeScript
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;});
  • 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.

Related: Create a Server Key·Environments·Customers and sessions