360 Secure SkillHub
360 安全技能中心

City of Toronto Open Data

该 Skill 提供 Python 命令行脚本,通过多伦多市开放数据门户的 CKAN API 搜索和列出 537 个以上数据集、查看数据集元数据与资源,并按行数上限、SQL 条件、字段选择和资源 ID 抓取数据存储中的记录,结果可输出 JSON 或 CSV。

raychanpmp
raychanpmp
热度 40.01
最近更新 2026-05-11 17:38:25
分类:数据依赖:代码执行 / 第三方 API应用场景:数据处理 / 研究

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add toronto-opendata
Metadata
name
City of Toronto Open Data
description
Access 537+ datasets from the City of Toronto open data portal. Search, fetch, and analyze city data on transit, traffic, housing, environment, and more via the CKAN API.
permissions
Bash
triggers
["toronto open data","city of toronto data","toronto dataset","open.toronto.ca","toronto transit","toronto housing"]

City of Toronto Open Data

Access and analyze 537+ open datasets from the City of Toronto via the CKAN API. Data covers transit, traffic, housing, environment, budget, community services, and more.

Portal: https://open.toronto.ca Platform: CKAN API: https://ckan0.cf.opendata.inter.prod-toronto.ca

Quick Start

# Search for datasets
python3 scripts/toronto_data.py search "traffic"

# List all datasets
python3 scripts/toronto_data.py list

# View dataset info
python3 scripts/toronto_data.py info 311-service-request-codes

# Fetch data from CKAN datastore
python3 scripts/toronto_data.py fetch traffic-volumes-at-intersections-for-all-modes --limit 5

# Fetch with filters
python3 scripts/toronto_data.py fetch traffic-volumes-at-intersections-for-all-modes --where "total_vehicle > 20000" --limit 10

# Export as CSV
python3 scripts/toronto_data.py fetch traffic-volumes-at-intersections-for-all-modes --limit 100 --csv > traffic.csv

# List datastore-enabled datasets
python3 scripts/toronto_data.py searchable

Commands Reference

Command Description
search <query> Search datasets by keyword
list List all datasets
info <dataset-id> Show dataset metadata and resources
fetch <dataset-id> Fetch data from datastore (opts: --limit, --where, --select, --csv)
searchable List datasets with queryable datastore resources

Query Parameters

  • --limit N — Max rows to return (default: 10)
  • --where "condition" — SQL filter (e.g., "total_vehicle > 20000")
  • --select "col1,col2" — Choose specific columns
  • --csv — Output as CSV instead of JSON
  • --resource-id ID — Specify which resource to query

Dataset IDs

Dataset IDs are URL-safe slugs (e.g., traffic-volumes-at-intersections-for-all-modes). Find them via search or list, or from the dataset URL: open.toronto.ca/dataset/{id}.

Data Sources

All data is sourced from the City of Toronto's Open Data Portal (open.toronto.ca). See references/datasets.md for a curated list of popular datasets.