Skip to main content

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

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)

Request parameters

FieldTypeDescription
labelsstring[]Restrict to specific labels
whereobjectFilter conditions (same as search)
orderBystring | objectSort criteria
skipnumberPagination offset
limitnumberMax 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