Getting Started
Get up and running with the Lightning Logs TypeScript SDK in minutes.
Installation
Install the SDK using npm, yarn, or pnpm
npm install @lightning-logs/sdk
# or
yarn add @lightning-logs/sdk
# or
pnpm add @lightning-logs/sdkFor detailed installation instructions, see the Installation Guide.
Basic Setup
Initialize the SDK client with your Supabase credentials
import { LightningLogsClient } from '@lightning-logs/sdk'
import { createClient } from '@supabase/supabase-js'
// Initialize Supabase client
const supabase = createClient(
'https://your-project.supabase.co',
'your-anon-key'
)
// Initialize Lightning Logs client
const client = new LightningLogsClient({
baseURL: 'https://your-project.supabase.co',
apiKey: 'your-anon-key',
getAuthToken: async () => {
const { data: { session } } = await supabase.auth.getSession()
return session?.access_token || null
}
})Your First API Call
Search logs with a simple query
// Search for error logs
const results = await client.logs.search({
tsFrom: '2025-01-15T00:00:00Z',
tsTo: '2025-01-15T23:59:59Z',
query: "level = 'error'"
})
console.log(`Found ${results.data.length} errors`)
console.log(results.data)Ingest Log Events
Send log events to Lightning Logs
// Ingest log events
const response = await client.logs.ingest([
{
ts: new Date().toISOString(),
level: 'info',
msg: 'User logged in',
service: 'api',
user_id: 'user-123'
},
{
ts: new Date().toISOString(),
level: 'error',
msg: 'Payment failed',
service: 'payment',
req_id: 'req-456'
}
])
console.log(`Ingested ${response.ingested} events`)