Charts and maps
Every answer has a message_id. Pass it to the chart or map endpoint to draw the answer’s
rows. Each call spends quota, and the answer must have rows.
A chart
POST /v1/messages/{id}/chart returns a chart specification for the answer’s rows, which you
draw with your own charting library:
{
"chartType": "bar",
"index": "district",
"categories": ["median_household_income"],
"data": [
{ "district": "TX-3", "median_household_income": 121000 },
{ "district": "TX-7", "median_household_income": 98000 }
]
}chartTypeis the suggested kind of chart, such asbarorline.indexis the field for the x-axis, or the labels of a pie.categoriesare the fields to plot as series.dataholds the rows to plot.
A map
POST /v1/messages/{id}/map returns an image of the answer’s geographic rows: a PNG 1200
pixels wide by default, or SVG with {"format": "svg"}.
curl -X POST https://platform.teroatlas.ai/v1/messages/m7b2c4d6-1a3e-4f5a-8b9c-0d1e2f3a4b5c/map \
-H "Authorization: Bearer $TERO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"format": "svg"}' \
-o map.svgMaps draw congressional districts. An answer whose rows aren’t districts fails with
422 map_unavailable; ask the question by district to map it.
Maps are a District Intelligence (CDIS) feature. An answer from a Site Selection (SSIS)
conversation fails with 403 feature_disabled, details.feature "map"; chart it instead.
With the SDK
import { writeFileSync } from "node:fs";
import { createTeroClient } from "@teroai/sdk";
const tero = createTeroClient({ api_key: process.env.TERO_API_KEY! });
const answer = await tero.questions.ask({
question: "Which 10 congressional districts in Ohio have the most veterans?",
});
const chart = await tero.messages.chart(answer.message_id);
console.log(chart.chartType, chart.index, chart.categories);
const map = await tero.messages.map(answer.message_id);
writeFileSync("ohio-veterans.png", map.data);Reports
POST /v1/messages/{id}/report writes a report about an answer, with a title, a summary and
sections, at a length of page_count pages, from 1 to 10.