Loop
Sign inGet started
SDKs

SDKs

Install and use the official Loop SDKs for JavaScript/TypeScript, Python, and Go, with install commands and a minimal end-to-end example in each language.

Overview

Loop ships official, typed SDKs for JavaScript/TypeScript, Python, and Go. Every SDK wraps the same REST API (https://api.loop.dev/v2), shares the same feedback item shape, and authenticates with your LOOP_API_KEY. Pick the client that matches your stack — the concepts and method names carry across all three.

Language Package Client
JavaScript/TypeScript @loop/sdk new Loop(apiKey)
Python loop Loop(api_key=...)
Go loop-go loop.New(apiKey)

Installation

Install the package for your language:

# JavaScript / TypeScript
npm install @loop/sdk

# Python
pip install loop

# Go
go get github.com/loop-dev/loop-go

All three read the API key you provide at construction time. Load it from the environment rather than hardcoding it — see Authentication.

JavaScript / TypeScript

The JS/TS SDK is fully typed and works in Node.js server environments. Initialize the client once and reuse it.

import { Loop } from '@loop/sdk';

const loop = new Loop(process.env.LOOP_API_KEY);

// Create a feedback item
const item = await loop.feedback.create({
  user: { id: 'u_8f2c' },
  message: 'The onboarding flow was clear and quick.',
  sentiment: 'positive',
  source: 'in-app-widget',
});

// List open feedback
const { data } = await loop.feedback.list({ status: 'open', limit: 10 });
console.log(`${data.length} open items, latest: ${item.id}`);

Python

The Python SDK targets Python 3.8+ and mirrors the same method names. Pass user as a dictionary.

import os
from loop import Loop

loop = Loop(api_key=os.environ['LOOP_API_KEY'])

# Create a feedback item
item = loop.feedback.create(
    user={'id': 'u_8f2c'},
    message='The onboarding flow was clear and quick.',
    sentiment='positive',
)

# List open feedback
result = loop.feedback.list(status='open', limit=10)
print(f"{len(result.data)} open items, latest: {item.id}")

Go

The Go SDK uses typed structs and a context.Context on every call. Sentiment values are exported constants such as loop.Positive.

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/loop-dev/loop-go"
)

func main() {
    ctx := context.Background()
    client := loop.New(os.Getenv("LOOP_API_KEY"))

    // Create a feedback item
    item, err := client.Feedback.Create(ctx, &loop.Feedback{
        User:      loop.User{ID: "u_8f2c"},
        Message:   "The onboarding flow was clear and quick.",
        Sentiment: loop.Positive,
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("created %s\n", item.ID)
}

Sentiment values

All SDKs use the same three sentiment values:

SDK value (JS / Python) Go constant Meaning
'positive' loop.Positive Happy or complimentary
'neutral' loop.Neutral Informational or mixed
'negative' loop.Negative Frustrated or reporting a problem

Error handling

Each SDK surfaces API errors as exceptions or returned errors, carrying the HTTP status and an error type. A few patterns to handle:

  • 401 — invalid or revoked API key; check your LOOP_API_KEY.
  • 400 — a validation error, such as a missing message.
  • 429 — rate limited or monthly item quota exceeded; back off and retry.
try {
  await loop.feedback.create({ user: { id: 'u_8f2c' }, message: 'Hi' });
} catch (err) {
  console.error(err.status, err.type, err.message);
}

Next steps

The SDKs are intentionally thin wrappers over a stable API, so anything you can do over REST you can do with a typed client in your language of choice.

← PREVIOUS
Webhooks