BAGLE

Your First API Call

Encode a signal into 128 frequency-domain coefficients using the BAGLE API.

Python

python
import requests
import os

# Raw signal samples (any numeric signal)
data = {
    "samples": [0.456, -0.123, 0.789, 1.234, -0.567, 0.891],
    "sample_rate": 16000
}

response = requests.post(
    "https://bagle-api.fly.dev/api/v1/encode",
    headers={
        "X-API-Key": os.getenv("BAGLE_API_KEY"),
        "Content-Type": "application/json"
    },
    json=data
)

result = response.json()
print(f"Coefficients: {len(result['coefficients'])} values")
print(f"First 5: {result['coefficients'][:5]}")

TypeScript

typescript
const res = await fetch('https://bagle-api.fly.dev/api/v1/encode', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.BAGLE_API_KEY!,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    samples: [0.456, -0.123, 0.789, 1.234, -0.567, 0.891],
    sample_rate: 16000
  })
});

const { coefficients } = await res.json();
console.log(`Got ${coefficients.length} coefficients`);

Response

json
{
  "coefficients": [0.456, -0.123, 0.789, ...],
  "num_coefficients": 128,
  "sample_rate": 16000,
  "input_length": 6
}

You're all set!

Explore the full API reference to see all endpoints including similarity comparison.

API Reference