CSV Export
Qarta supports exporting results as CSV files from several endpoints. This guide shows how to request and work with CSV data.
Supported Endpoints
The following endpoints can return CSV format:
| Endpoint | Method | Path |
|---|---|---|
| Entries search (V1) | GET | /graph/api/v1/reports/portfolio/entries/selection/search |
| Entries selection (V1) | POST | /graph/api/v1/reports/portfolio/entries/selection |
| Entries buffer (V1) | POST | /graph/api/v1/reports/portfolio/entries/buffer-selection |
| Entries search (V2) | POST | /graph/api/v2/reports/portfolio/entries/selection/search |
| Entries selection (V2) | POST | /graph/api/v2/reports/portfolio/entries/selection |
| Entries buffer (V2) | POST | /graph/api/v2/reports/portfolio/entries/buffer-selection |
Note: Points endpoints and other endpoint types return JSON only.
How to Request CSV
CSV format is requested using the HTTP Accept header. Set it to text/csv:
Content Negotiation
Accept: text/csv
When you set this header, the API will respond with CSV data instead of JSON (if the endpoint supports it).
Examples
- cURL
- JavaScript
- Python
curl -X GET "https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search" \
-H "Authorization: YOUR_API_KEY" \
-H "Accept: text/csv" \
-d "filters={\"field\":\"oe_id\",\"value\":\"portfolio_01\"}&source=portfolio_01&columns=name,value,price"
Or to save to a file:
curl -X GET "https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search" \
-H "Authorization: YOUR_API_KEY" \
-H "Accept: text/csv" \
-o "results.csv" \
-d "filters={\"field\":\"oe_id\",\"value\":\"portfolio_01\"}&source=portfolio_01"
const apiKey = 'YOUR_API_KEY';
// Request CSV format
const response = await fetch(
'https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search',
{
method: 'GET',
headers: {
'Authorization': `${apiKey}`,
'Accept': 'text/csv' // Request CSV format
}
}
);
// Get CSV text
const csvText = await response.text();
console.log(csvText);
// Or save to file (Node.js)
const fs = require('fs');
fs.writeFileSync('results.csv', csvText);
import requests
api_key = 'YOUR_API_KEY'
headers = {
'Authorization': f'{api_key}',
'Accept': 'text/csv' # Request CSV format
}
response = requests.get(
'https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search',
params={
'source': 'portfolio_01',
'filters': '[{"field":"oe_id", "value":"abc123"}]',
'columns': 'name,value,price'
},
headers=headers
)
# Save to file
with open('results.csv', 'w') as f:
f.write(response.text)
print('CSV saved to results.csv')
CSV Format
The CSV response includes:
- Header row - Column names specified in the
columnsparameter - Data rows - One row per entry/point
- Encoding - UTF-8
- Delimiter - Comma (
,) - Quoting - Fields containing commas or newlines are quoted
Example CSV output:
name,value,property_type,address
Property A,450000,residential,"123 Main St, Springfield, IL"
Property B,650000,commercial,"456 Oak Ave, Springfield, IL"
Property C,350000,residential,"789 Pine Rd, Springfield, IL"
Column Selection
Control which columns appear in the CSV using the columns parameter:
- cURL
- JavaScript
- Python
# Include specific columns
curl -X GET "https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search" \
-H "Authorization: YOUR_API_KEY" \
-H "Accept: text/csv" \
-d "source=portfolio_01&columns=name,value,address,property_type"
const response = await fetch(
'https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search',
{
method: 'GET',
headers: {
'Authorization': `${apiKey}`,
'Accept': 'text/csv'
}
}
);
response = requests.get(
'https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search',
params={
'source': 'portfolio_01',
'columns': 'name,value,address,property_type'
},
headers=headers
)
Pagination with CSV
When retrieving large datasets, use pagination:
- cURL
- JavaScript
- Python
# First page (10 rows)
curl -X GET "https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search" \
-H "Authorization: YOUR_API_KEY" \
-H "Accept: text/csv" \
-d "source=portfolio_01&limit=10&page=0"
# Second page
curl -X GET "https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search" \
-H "Authorization: YOUR_API_KEY" \
-H "Accept: text/csv" \
-d "source=portfolio_01&limit=10&page=1"
async function getAllEntriesAsCSV() {
const pageSize = 100;
let page = 0;
let allCSV = '';
while (true) {
const response = await fetch(
`https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search`,
{
method: 'GET',
headers: {
'Authorization': `${apiKey}`,
'Accept': 'text/csv'
}
}
);
const csv = await response.text();
const lines = csv.split('\n');
if (page === 0) {
// Keep header row
allCSV = csv;
} else {
// Skip header row for subsequent pages
allCSV += '\n' + lines.slice(1).join('\n');
}
if (lines.length <= pageSize) break;
page++;
}
return allCSV;
}
import csv
import io
def get_all_entries_csv():
all_data = []
page = 0
page_size = 100
while True:
response = requests.get(
'https://graph.quarticle.ro/graph/api/v1/reports/portfolio/entries/selection/search',
params={
'source': 'portfolio_01',
'limit': page_size,
'page': page
},
headers=headers
)
csv_reader = csv.reader(io.StringIO(response.text))
rows = list(csv_reader)
if page == 0:
all_data.extend(rows)
else:
all_data.extend(rows[1:]) # Skip header
if len(rows) <= page_size:
break
page += 1
return all_data
Working with CSV Data
Parsing in JavaScript
function parseCSV(csvText) {
const lines = csvText.trim().split('\n');
const headers = lines[0].split(',');
const data = lines.slice(1).map(line => {
const values = line.split(',');
const obj = {};
headers.forEach((header, index) => {
obj[header] = values[index];
});
return obj;
});
return data;
}
const csvData = await response.text();
const entries = parseCSV(csvData);
console.log(entries[0]); // First entry as object
Parsing in Python
import pandas as pd
# Using pandas (requires: pip install pandas)
df = pd.read_csv('results.csv')
print(df.head())
print(df.describe())
# Or using csv module
import csv
with open('results.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
print(row)
Error Responses
Even when requesting CSV format, errors return JSON:
{
"errorMessage": {
"message": "Invalid source parameter"
}
}
Check HTTP status code to determine if the request succeeded:
- 200 - Success (CSV data)
- 400 - Bad request (JSON error)
- 401 - Unauthorized (JSON error)
- 500 - Server error (JSON error)
Limitations
- CSV is only available for entries/points search and selection endpoints
- Risk reporting endpoints always return PDF/HTML
- Column selection must specify valid field names
- Very large datasets may timeout — use pagination
Tips & Tricks
- Quote handling - Fields with commas, quotes, or newlines are automatically quoted
- Excel compatibility - CSV files open directly in Excel, Google Sheets, etc.
- Large exports - Paginate through results and concatenate CSVs
- Encoding - Always UTF-8; ensure your tools handle this
- Empty results - Returns header row only if no results match
Next Steps
- Spatial Data Guide - Working with geographic shapes
- V1 vs V2 Guide - Understanding API versions
- Use Cases - Real-world examples with CSV export