Get Records
The Get Records API provides direct access to your database records, allowing you to retrieve all records or filter by timestamp. Results are always returned in descending order by last seen time (most recent first).
GET /v1/databases/{id}/records
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
id | string | Yes | The ID of your Lightfeed database |
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
start_time | string | No | Start of last seen time range (ISO 8601 timestamp) |
end_time | string | No | End of last seen time range (ISO 8601 timestamp) |
limit | number | No | Maximum number of records to return (default: 100, max: 500) |
cursor | string | No | Cursor for pagination (from previous response) |
Example Requests
All records
Export your entire database by paginating through all records in descending order by last seen time (most recent first).
- JavaScript
- Python
- cURL
import { LightfeedClient } from "lightfeed";
// Initialize client with your API key
const client = new LightfeedClient({
apiKey: "your-api-key",
});
try {
const response = await client.getRecords("your-database-id", {
limit: 500,
});
console.log(`Retrieved ${response.results.length} records`);
console.log(response);
} catch (error) {
console.error("Error retrieving records:", error);
}
from lightfeed import LightfeedClient
# Initialize client with your API key
client = LightfeedClient({
"apiKey": "your-api-key"
})
try:
response = client.get_records("your-database-id", {
"limit": 500
})
print(f"Retrieved {len(response['results'])} records")
print(response)
except Exception as e:
print(f"Error retrieving records: {e}")
curl "https://api.lightfeed.ai/v1/databases/your-database-id/records?limit=500" \
-H "x-api-key: your-api-key"
Records Within a Time Range
This example shows how to retrieve records that were seen within a specific time range.
- JavaScript
- Python
- cURL
import { LightfeedClient } from "lightfeed";
// Initialize client with your API key
const client = new LightfeedClient({
apiKey: "your-api-key",
});
try {
const response = await client.getRecords("your-database-id", {
start_time: "2024-12-01T00:00:00Z",
end_time: "2024-12-31T23:59:59Z",
limit: 100,
});
console.log(`Retrieved ${response.results.length} records`);
console.log(response);
} catch (error) {
console.error("Error retrieving records:", error);
}
from lightfeed import LightfeedClient
# Initialize client with your API key
client = LightfeedClient({
"apiKey": "your-api-key"
})
try:
response = client.get_records("your-database-id", {
"start_time": "2024-12-01T00:00:00Z",
"end_time": "2024-12-31T23:59:59Z",
"limit": 100
})
print(f"Retrieved {len(response['results'])} records")
print(response)
except Exception as e:
print(f"Error retrieving records: {e}")
curl "https://api.lightfeed.ai/v1/databases/your-database-id/records?\
start_time=2024-12-01T00:00:00Z&\
end_time=2024-12-31T23:59:59Z&\
limit=100" \
-H "x-api-key: your-api-key"
Recent Records
This example shows how to retrieve records seen in the last 24 hours.
- JavaScript
- Python
- cURL
import { LightfeedClient } from "lightfeed";
// Initialize client with your API key
const client = new LightfeedClient({
apiKey: "your-api-key",
});
try {
// Calculate timestamp for 24 hours ago
const oneDayAgo = new Date();
oneDayAgo.setHours(oneDayAgo.getHours() - 24);
const startTime = oneDayAgo.toISOString();
const response = await client.getRecords("your-database-id", {
start_time: startTime,
});
console.log(
`Retrieved ${response.results.length} records from the last 24 hours`
);
console.log(response);
} catch (error) {
console.error("Error retrieving recent records:", error);
}
from lightfeed import LightfeedClient
from datetime import datetime, timedelta
# Initialize client with your API key
client = LightfeedClient({
"apiKey": "your-api-key"
})
try:
# Calculate timestamp for 24 hours ago
one_day_ago = (datetime.utcnow() - timedelta(days=1)).isoformat() + "Z"
response = client.get_records("your-database-id", {
"start_time": one_day_ago
})
print(f"Retrieved {len(response['results'])} records from the last 24 hours")
print(response)
except Exception as e:
print(f"Error retrieving recent records: {e}")
# Calculate timestamp for 24 hours ago
START_TIME=$(date -u -d "24 hours ago" +"%Y-%m-%dT%H:%M:%SZ")
curl "https://api.lightfeed.ai/v1/databases/your-database-id/records?start_time=${START_TIME}" \
-H "x-api-key: your-api-key"
Example Response
{
"results": [
{
"id": 1345,
"data": {
"company_name": "Acme Inc.",
"industry": "Finance",
"description": "Acme is pioneering the application of large language models to revolutionize regulatory compliance and risk management for financial institutions.",
"website": "https://acme.com",
"employees": 250,
"funding_amount": 5000000,
"is_public": false
},
"timestamps": {
"first_seen_time": "2024-03-15T14:22:13Z",
"last_changed_time": "2024-07-02T09:45:30Z",
"last_seen_time": "2024-10-01T18:30:45Z"
}
}
// Additional results...
],
"pagination": {
"limit": 100,
"next_cursor": "2024-09-01T18:30:45Z_1500",
"has_more": true
}
}
Response Structure
The response contains a list of records and pagination information.
Field | Type | Description |
---|---|---|
results | array | List of records |
pagination | object | Information for continued querying |
Pagination Object
Field | Type | Description |
---|---|---|
limit | number | The requested limit parameter value from the original request |
next_cursor | string | Token to use for fetching the next page (null if no more results) |
has_more | boolean | Indicates whether more results are available |
Record Object
Each record in the results array has the following structure:
Field | Type | Description |
---|---|---|
id | number | Unique identifier for the record |
data | object | The record's structured data |
timestamps | object | Timing information for the record |