Learn
Export Data
Export records as CSV. Accepts the same where, orderBy, skip, limit, and labels parameters as a search query — filtering and sorting apply before export.
Export to CSV
- Python
- TypeScript
- shell
db.records.export_csv() (if available in SDK version — otherwise use REST directly)
# Use the REST endpoint directly if SDK method is unavailable
import requests
response = requests.post(
"https://api.rushdb.com/api/v1/records/export/csv",
headers={"Authorization": f"Bearer {api_key}"},
json={
"labels": ["PERSON"],
"where": {"age": {"$gt": 25}},
"orderBy": {"name": "asc"},
"limit": 1000
}
)
csv_content = response.json()["data"]["fileContent"]
with open("output.csv", "w") as f:
f.write(csv_content)
// Use the REST endpoint directly
const response = await fetch('https://api.rushdb.com/api/v1/records/export/csv', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RUSHDB_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
labels: ['PERSON'],
where: { age: { $gt: 25 } },
orderBy: { name: 'asc' },
limit: 1000
})
})
const { data } = await response.json()
// data.fileContent — CSV string with headers on first row
// data.dateTime — export timestamp
POST /api/v1/records/export/csv
curl -X POST https://api.rushdb.com/api/v1/records/export/csv \
-H "Authorization: Bearer $RUSHDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"labels": ["PERSON"],
"where": {"age": {"$gt": 25}},
"orderBy": {"name": "asc"},
"limit": 1000
}'
Request parameters
| Field | Type | Description |
|---|---|---|
labels | string[] | Restrict to specific labels |
where | object | Filter conditions (same as search) |
orderBy | string | object | Sort criteria |
skip | number | Pagination offset |
limit | number | Max records to return (up to 1 000) |
Response
{
"success": true,
"data": {
"fileContent": "id,label,name,age,email\n018dfc84...,PERSON,John Doe,30,john@example.com",
"dateTime": "2025-04-23T10:15:32.123Z"
}
}
fileContent is a CSV string with headers on the first row. System properties (__proptypes etc.) are stripped automatically. __id and __label are included as id and label.
See also
- Find & Query — search and filter records before export
- Import Data — bring CSV or JSON data in