SDKs overview

Loops provides Software Development Kits (SDKs) to facilitate integration with its email platform, abstracting the underlying REST API calls. These SDKs are designed to offer a more idiomatic and developer-friendly experience within specific programming languages, covering common operations such as sending emails, managing contacts, and interacting with automation features. The use of an SDK can reduce the amount of boilerplate code required, handle HTTP requests, and manage API authentication tokens.

The Loops API itself is a RESTful interface that operates over HTTPS, accepting JSON payloads and returning JSON responses. This standard approach allows for direct HTTP client integration in any language, though SDKs offer a higher-level abstraction. For detailed information on the API endpoints and data structures, developers can consult the Loops API reference documentation.

Official SDKs by language

Loops maintains official SDKs for several popular programming languages, ensuring direct support and continuous updates. These SDKs are developed and maintained by the Loops team to guarantee compatibility with the latest API versions and features. They typically include methods for all primary API functionalities, from sending a single email to managing complex audience segments.

The following table outlines the official SDKs available, along with their respective package names and typical installation commands:

Language Package Name Installation Command Maturity
Node.js loops-sdk npm install loops-sdk or yarn add loops-sdk Stable
Python loops-py pip install loops-py Stable
Go go-loops go get github.com/loops/go-loops Stable
Ruby loops-ruby gem install loops-ruby Stable
PHP loops-php composer require loops/loops-php Stable

Each SDK is designed to reflect the native conventions of its language, making integration straightforward for developers familiar with that ecosystem. For specific usage details, including method signatures and available parameters, refer to the Loops developer documentation.

Installation

Installing a Loops SDK typically involves using the standard package manager for the respective programming language. Each SDK is published to its language's primary package repository, ensuring easy access and version management. Detailed installation instructions and requirements, such as minimum language versions, are available in the Loops official documentation.

Node.js Installation

To install the Node.js SDK, navigate to your project directory in the terminal and execute one of the following commands:

npm install loops-sdk
# or
yarn add loops-sdk

This command fetches the loops-sdk package from the npm registry and adds it to your project's dependencies. The Node.js ecosystem, as described by MDN Web Docs on JavaScript modules, uses these package managers for dependency resolution.

Python Installation

For Python projects, the SDK is available via pip:

pip install loops-py

This command installs the loops-py package and its dependencies, making the Loops client available for import in your Python scripts. Pip is the standard package installer for Python, facilitating the management of third-party libraries.

Go Installation

Go developers can install the SDK using the go get command:

go get github.com/loops/go-loops

This command downloads the Go module directly into your Go workspace. Go modules are the standard for dependency management in Go, as detailed in the official Go documentation on managing dependencies.

Ruby Installation

Ruby developers can add the Loops SDK to their project using RubyGems:

gem install loops-ruby

Alternatively, if you are using Bundler, add the following line to your Gemfile and then run bundle install:

gem 'loops-ruby'

PHP Installation

For PHP projects, Composer is the recommended package manager:

composer require loops/loops-php

This command adds the loops/loops-php package to your composer.json file and installs it, making the SDK classes available through Composer's autoloader.

Quickstart example

The following example demonstrates how to send a transactional email using the Node.js SDK. This snippet illustrates the basic steps: initializing the client with an API key, and then calling a method to send an email. For other languages, the structure will be similar, adapting to the respective language's syntax and conventions.

Node.js Quickstart: Sending a Transactional Email

First, ensure you have your Loops API key. You can find this in your Loops account settings.

const LoopsClient = require('loops-sdk');

const loops = new LoopsClient({ apiKey: process.env.LOOPS_API_KEY });

async function sendWelcomeEmail() {
  try {
    const response = await loops.sendTransactional({ 
      transactionalId: 'welcome-email-template', // Replace with your template ID
      email: '[email protected]', // Recipient's email
      data: { 
        firstName: 'Jane', 
        // Other dynamic data for your template
      },
      // Optional: userId, senderId, etc.
    });
    console.log('Email sent successfully:', response.data);
  } catch (error) {
    console.error('Failed to send email:', error.response ? error.response.data : error.message);
  }
}

sendWelcomeEmail();

This example assumes you have a transactional email template set up in your Loops account with the ID welcome-email-template and that it expects a firstName data field. The process.env.LOOPS_API_KEY approach is recommended for securely managing API keys, preventing them from being hardcoded directly into source files. Environment variables are a common method for handling sensitive information in applications, as detailed in secure coding practices discussed by Google Cloud's best practices for secrets management.

Python Quickstart: Adding a Contact

This Python example demonstrates how to add a new contact to your Loops audience using the loops-py SDK.

import os
from loops_py import LoopsClient

loops = LoopsClient(api_key=os.environ.get("LOOPS_API_KEY"))

async def add_new_contact():
    try:
        response = await loops.create_contact(
            email="[email protected]",
            first_name="John",
            last_name="Doe",
            user_id="user_12345",
            subscribed=True,
            source="API Integration"
        )
        print(f"Contact added successfully: {response}")
    except Exception as e:
        print(f"Failed to add contact: {e}")

# To run an async function
import asyncio
asyncio.run(add_new_contact())

This snippet uses os.environ.get("LOOPS_API_KEY") to retrieve the API key from environment variables, similar to the Node.js example, reinforcing secure credential handling. The create_contact method supports various parameters to capture comprehensive user data upon signup or other interaction points, enabling effective segmentation and personalized communication.

Community libraries

While Loops provides official SDKs for major languages, the open nature of its REST API allows the developer community to create and maintain additional libraries. These community-contributed tools can offer support for other programming languages, frameworks, or specialized use cases not covered by the official offerings. Community libraries are often found on platforms like GitHub or language-specific package repositories.

As of late 2025, there are nascent community efforts observed on platforms like GitHub for languages such as Rust and Elixir, although no widely adopted, stable community SDKs have emerged with significant usage statistics or official endorsements from Loops. Developers interested in contributing or finding such libraries are encouraged to search on GitHub for repositories tagged with loops-api or loops-email, or to check relevant community forums and Discord channels dedicated to Loops. When using community-maintained libraries, it is advisable to review their source code, check for active maintenance, and verify compatibility with the latest Loops API versions, as community projects may have varying levels of support and update frequency compared to official SDKs.