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).
- cURL
- JavaScript
- Python
curl "https://api.lightfeed.ai/v1/databases/your-database-id/records?limit=500" \
-H "x-api-key: your-api-key"
import { LightfeedClient } from "lightfeed";
// Initialize client with your API key
const client = new LightfeedClient({
apiKey: "your-api-key",
});
async function getAllRecords() {
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);
}
}
getAllRecords();
from lightfeed import LightfeedClient
# Initialize client with your API key
client = LightfeedClient({
"apiKey": "your-api-key"
})
def get_all_records():
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}")
get_all_records()
Records Within a Time Range
This example shows how to retrieve records that were seen within a specific time range.
- cURL
- JavaScript
- Python
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"
import { LightfeedClient } from "lightfeed";
// Initialize client with your API key
const client = new LightfeedClient({
apiKey: "your-api-key",
});
async function getRecordsInTimeRange() {
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);
}
}
getRecordsInTimeRange();
from lightfeed import LightfeedClient
# Initialize client with your API key
client = LightfeedClient({
"apiKey": "your-api-key"
})
def get_records_in_time_range():
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}")
get_records_in_time_range()
Recent Records
This example shows how to retrieve records seen in the last 24 hours.
- cURL
- JavaScript
- Python
# 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"
import { LightfeedClient } from "lightfeed";
// Initialize client with your API key
const client = new LightfeedClient({
apiKey: "your-api-key",
});
async function getRecentRecords() {
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);
}
}
getRecentRecords();
from lightfeed import LightfeedClient
from datetime import datetime, timedelta
# Initialize client with your API key
client = LightfeedClient({
"apiKey": "your-api-key"
})
def get_recent_records():
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}")
get_recent_records()
Example Response
{
"results": [
{
"id": 1345,
"data": {
"company_name": "Acme Inc.",
"industry": "Finance",
"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 |