SDKs

Server-side & Other Environments

Send events from any backend with the Track API. Ready-to-use Python, Go, Ruby, and PHP snippets, plus community SDKs.

Logspot has first-party SDKs for the browser and Node.js. From any other environment, send events directly to the Track API: a single POST authenticated with an API token.

All examples below post to https://api.logspot.io/v1/track with an Authorization: Bearer sk_... header and a JSON body. Create the token in Settings → Integrations, keep it on the server, never in client code. The legacy x-logspot-sk: sk_... header still works. These mirror the snippets in the in-app Integrations panel.

Python

import requests

requests.post(
    "https://api.logspot.io/v1/track",
    headers={"Authorization": "Bearer sk_YOUR_API_TOKEN"},
    json={
        "name": "UserSubscribed",
        "user_id": "[email protected]",
        "metadata": {"plan": "pro"},
    },
    timeout=5,
)

Use json= (not data=) so requests sends Content-Type: application/json. The Track API only accepts JSON bodies.

Go

package main

import (
	"bytes"
	"encoding/json"
	"net/http"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"name":     "UserSubscribed",
		"user_id":  "[email protected]",
		"metadata": map[string]any{"plan": "pro"},
	})

	req, _ := http.NewRequest("POST", "https://api.logspot.io/v1/track", bytes.NewBuffer(body))
	req.Header.Set("Authorization", "Bearer sk_YOUR_API_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	resp, _ := (&http.Client{}).Do(req)
	defer resp.Body.Close()
}

Ruby

require 'net/http'
require 'uri'
require 'json'

uri = URI('https://api.logspot.io/v1/track')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = 'Bearer sk_YOUR_API_TOKEN'
req['Content-Type'] = 'application/json'
req.body = {
  name: 'UserSubscribed',
  user_id: '[email protected]',
  metadata: { plan: 'pro' },
}.to_json

Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }

PHP

<?php

$ch = curl_init('https://api.logspot.io/v1/track');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer sk_YOUR_API_TOKEN',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'name' => 'UserSubscribed',
        'user_id' => '[email protected]',
        'metadata' => ['plan' => 'pro'],
    ]),
]);
curl_exec($ch);
curl_close($ch);

Want an SDK in Your Language?

Let us know, and see the full request/response contract in the Track API reference.

Community SDKs

NestJS SDK