Querying Data for Devs
Learn how to build queries, create frameworks, and retrieve data programmatically using the Carbon Arc SDK.
API Reference
Available Methods
| Method | Description |
|---|---|
client.explorer.build_framework() | Create a framework defining your data query |
client.explorer.collect_framework_filters() | Discover available filter keys |
client.explorer.collect_framework_filter_options() | Get options for a specific filter |
client.explorer.check_framework_price() | Check cost before purchasing |
client.explorer.buy_frameworks() | Purchase frameworks (charges account) |
client.explorer.get_framework_metadata() | Get metadata for a purchased framework |
client.explorer.get_framework_data() | Retrieve purchased data |
Key Concepts
| Concept | Description |
|---|---|
| Framework | A structured query combining an entity, insight, time range, and filters |
| Entity | The subject of your query (company, product, location, etc.) |
| Insight | The metric or KPI you want to retrieve (spend, transactions, users, etc.) |
| Filters | Optional parameters to narrow your query (geography, time, demographics) |
Typical Workflow
- Discover — Use the Ontology API to find entities and insights
- Build — Create a framework with your query parameters
- Validate — Check filters and estimate price
- Execute — Purchase and retrieve your data
- Analyze — Work with the returned DataFrame
Quick Start
from carbonarc import CarbonArcClient
import pandas as pd
client = CarbonArcClient(
host="https://api.carbonarc.co",
token="YOUR_API_TOKEN"
)
Build a Framework
# Define your query
framework = client.explorer.build_framework(
entities=[{"carc_id": 64719, "representation": "company"}], # Tesla
insight=347,
filters={
"location_resolution": "us",
"date_resolution": "month",
"date_range": {"start_date": "2024-01-01", "end_date": "2024-12-31"}
},
aggregate="sum"
)
# Check price before purchasing
price = client.explorer.check_framework_price(framework)
print(f"Price: ${price:.2f}")
Execute and Retrieve Data
# Purchase the framework (charges your account!)
order = client.explorer.buy_frameworks([framework])
framework_id = order['frameworks'][0]
# Retrieve the data
data = client.explorer.get_framework_data(framework_id=framework_id)
df = pd.DataFrame(data['data'])
print(df.head())
Related Resources
| Resource | Description |
|---|---|
| Library for Devs | Explore available data assets |
| Ontology for Devs | Find entities and insights |
| ID Reference | Understand all ID types |
| Frameworks Overview | Platform documentation on frameworks |
| Pagination | Handle large data assets efficiently |
| Use Cases & Recipes | Real-world examples you can copy and adapt |
| Exporting Data | Export to CSV, Excel, Parquet, databases, and cloud |
| Filters & Date Ranges | Master filtering and date options |
| Error Handling | Implement robust error handling |
Need Help?
- Email: support@carbonarc.co
- GitHub: Carbon Arc Tutorials