Create Toronto Open Data CKAN parser #54

Closed
opened 2026-01-16 15:49:43 +00:00 by lmiranda · 2 comments
Owner

Overview

Create a parser for fetching data from the Toronto Open Data CKAN API.

File to Create

portfolio_app/toronto/parsers/toronto_open_data.py

API Details

  • Base URL: https://ckan0.cf.opendata.inter.prod-toronto.ca
  • Key Datasets:
    • neighbourhoods-158 - Neighbourhood boundaries
    • neighbourhood-profiles - Census data
    • parks - Park locations
    • school-locations-all-types - School locations
    • licensed-child-care-centres - Childcare centres

Class Structure

class TorontoOpenDataParser:
    BASE_URL = "https://ckan0.cf.opendata.inter.prod-toronto.ca"
    
    def __init__(self, cache_dir: Path | None = None):
        ...
    
    def get_neighbourhoods(self) -> list[NeighbourhoodRecord]:
        """Fetch 158 neighbourhood boundaries as GeoJSON."""
    
    def get_census_profiles(self, year: int = 2021) -> list[CensusRecord]:
        """Fetch neighbourhood census profiles."""
    
    def get_parks(self) -> list[AmenityRecord]:
        """Fetch park locations."""
    
    def get_schools(self) -> list[AmenityRecord]:
        """Fetch school locations."""
    
    def get_childcare_centres(self) -> list[AmenityRecord]:
        """Fetch licensed childcare centre locations."""

Acceptance Criteria

  • Parser fetches data from CKAN API successfully
  • Returns validated Pydantic schema objects
  • Optional caching to reduce API calls
  • get_neighbourhoods() returns exactly 158 records
  • Import test passes
  • Linter passes

Labels

Type/Feature, Priority/High, Component/Backend, Component/API, Tech/Python

## Overview Create a parser for fetching data from the Toronto Open Data CKAN API. ## File to Create `portfolio_app/toronto/parsers/toronto_open_data.py` ## API Details - **Base URL**: `https://ckan0.cf.opendata.inter.prod-toronto.ca` - **Key Datasets**: - `neighbourhoods-158` - Neighbourhood boundaries - `neighbourhood-profiles` - Census data - `parks` - Park locations - `school-locations-all-types` - School locations - `licensed-child-care-centres` - Childcare centres ## Class Structure ```python class TorontoOpenDataParser: BASE_URL = "https://ckan0.cf.opendata.inter.prod-toronto.ca" def __init__(self, cache_dir: Path | None = None): ... def get_neighbourhoods(self) -> list[NeighbourhoodRecord]: """Fetch 158 neighbourhood boundaries as GeoJSON.""" def get_census_profiles(self, year: int = 2021) -> list[CensusRecord]: """Fetch neighbourhood census profiles.""" def get_parks(self) -> list[AmenityRecord]: """Fetch park locations.""" def get_schools(self) -> list[AmenityRecord]: """Fetch school locations.""" def get_childcare_centres(self) -> list[AmenityRecord]: """Fetch licensed childcare centre locations.""" ``` ## Acceptance Criteria - [ ] Parser fetches data from CKAN API successfully - [ ] Returns validated Pydantic schema objects - [ ] Optional caching to reduce API calls - [ ] `get_neighbourhoods()` returns exactly 158 records - [ ] Import test passes - [ ] Linter passes ## Labels `Type/Feature`, `Priority/High`, `Component/Backend`, `Component/API`, `Tech/Python`
Author
Owner

Starting implementation of TorontoOpenDataParser for CKAN API.

Starting implementation of TorontoOpenDataParser for CKAN API.
Author
Owner

Implementation complete:

  • Created parsers/toronto_open_data.py with TorontoOpenDataParser
  • Methods: get_neighbourhoods(), get_census_profiles(), get_parks(), get_schools(), get_childcare_centres()
  • CKAN API integration with caching support
  • Updated parsers/__init__.py with exports
  • Import test passed
Implementation complete: - Created `parsers/toronto_open_data.py` with `TorontoOpenDataParser` - Methods: `get_neighbourhoods()`, `get_census_profiles()`, `get_parks()`, `get_schools()`, `get_childcare_centres()` - CKAN API integration with caching support - Updated `parsers/__init__.py` with exports - Import test passed
lmiranda added this to the Launch: Host, Bio and Toronto House Market Analysis project 2026-01-16 16:06:20 +00:00
lmiranda self-assigned this 2026-01-16 16:06:30 +00:00
lmiranda moved this to Done in Launch: Host, Bio and Toronto House Market Analysis on 2026-01-16 16:06:47 +00:00
Sign in to join this conversation.