API Documentation

Complete REST API reference for accessing Canadian government grants data programmatically.

Base URL: https://cgt.xeradb.com/api

Quick Start

All API endpoints return JSON data. No authentication is required for read-only access.

Example Request (cURL):
curl -X GET "https://cgt.xeradb.com/api/api/stats/"
Example Request (JavaScript):
fetch('https://cgt.xeradb.com/api/api/stats/')
  .then(response => response.json())
  .then(data => console.log(data));

Available Endpoints

GET /api/stats/

Get basic grant statistics and aggregations

Description:

Returns summary statistics including total grants, total value, and breakdowns by province, year, and program.

Parameters:

None

Response Example:
{
    "total_grants": 45832,
    "total_value": 15487394729.50,
    "by_province": [
        {
            "recipient_province": "ON",
            "count": 15240,
            "total_value": 5847392847.23
        }
    ],
    "by_year": [
        {
            "fiscal_year": "2023-24",
            "count": 8934,
            "total_value": 3245789234.56
        }
    ],
    "top_programs": [
        {
            "program_name_en": "Industrial Research Assistance Program",
            "count": 3421,
            "total_value": 2398475829.34
        }
    ]
}
Try it out:
GET /api/search/

Search and filter grants with advanced parameters

Description:

Search through grants with text queries and apply various filters. Supports pagination and sorting.

Parameters:
Parameter Type Description Example
search string Search in title, recipient, description, program technology
province string Filter by province/territory ON
fiscal_year string Filter by fiscal year 2023-24
min_value number Minimum grant value 100000
max_value number Maximum grant value 5000000
recipient_type string F (For-profit), N (Non-profit) F
is_major boolean Filter major funding (>$1M) true
is_notable boolean Filter notable/controversial grants true
sort string Sort field (add - for desc) -agreement_value
limit number Results per page (max 1000) 50
offset number Pagination offset 0
Response Example:
{
    "count": 234,
    "limit": 50,
    "offset": 0,
    "results": [
        {
            "id": 12345,
            "reference_number": "172-2023-2024-Q1-123456",
            "recipient_legal_name": "University of Toronto",
            "recipient_province": "ON",
            "recipient_city_en": "Toronto",
            "recipient_type": "N",
            "agreement_title_en": "Advanced AI Research Initiative",
            "agreement_value": 2500000.00,
            "description_en": "Research into advanced artificial intelligence applications...",
            "agreement_start_date": "2023-04-01",
            "agreement_end_date": "2026-03-31",
            "program_name_en": "Industrial Research Assistance Program",
            "naics_sector_en": "Educational services",
            "fiscal_year": "2023-24",
            "is_major_funding": true,
            "is_notable": false,
            "notable_reason": ""
        }
    ]
}
Try it out:
GET /api/recipients/

Get recipient analysis and top recipients

Description:

Returns analysis of grant recipients including top recipients by funding, breakdown by type, and provincial distribution.

Parameters:

None

Response Example:
{
    "top_recipients": [
        {
            "recipient_legal_name": "University of Toronto",
            "total_value": 125487293.50,
            "grant_count": 342,
            "avg_value": 366913.45
        }
    ],
    "by_type": [
        {
            "recipient_type": "N",
            "count": 28394,
            "total_value": 8945738291.23,
            "avg_value": 314982.45
        }
    ],
    "by_province": [
        {
            "recipient_province": "ON",
            "count": 15240,
            "total_value": 5847392847.23,
            "unique_recipients": 3421
        }
    ]
}
Try it out:
GET /api/comprehensive-stats/

Get comprehensive statistics and analytics

Description:

Returns detailed statistics including value distributions, yearly analysis, sector breakdowns, and notable grant categories.

Parameters:

None

Response Sections:
  • basic_stats - Overview statistics (total, average, min, max values)
  • yearly_analysis - Year-over-year trends
  • provincial_analysis - Provincial breakdowns
  • sector_analysis - Industry sector analysis
  • program_analysis - Program effectiveness
  • value_distribution - Grant size distribution
  • notable_breakdown - Notable grant categories
Try it out:
POST /api/calculate/

Calculate personal tax contribution to grants

Description:

Calculate how much of a user's taxes goes to specific grants based on their income and spending.

Request Body:
{
    "annual_income": 75000,
    "gst_eligible_spending": 25000,
    "input_mode": "annual",
    "taxpayer_since_year": 2018
}
Response Example:
{
    "success": true,
    "calculation": {
        "annual_income": 75000.00,
        "taxpayer_since_year": 2018,
        "federal_income_tax": 11327.50,
        "gst_paid": 1250.00,
        "total_tax_contribution": 12577.50,
        "total_tax_contribution_formatted": "$12,577.50",
        "grants_portion_of_taxes_formatted": "$314.44",
        "revenue_share_percentage": 0.00002924
    },
    "grant_shares": [
        {
            "id": 12345,
            "title": "Advanced AI Research",
            "total_value": 2500000.00,
            "user_share": 1.83,
            "user_share_formatted": "$1.83",
            "recipient": "University of Toronto"
        }
    ],
    "yearly_breakdown": [
        {
            "year": 2023,
            "user_share": 45.23,
            "user_share_formatted": "$45.23",
            "grant_count": 1247,
            "top_projects": [...]
        }
    ],
    "future_projections": {
        "continuing_only": {...},
        "with_new_projects": {...},
        "historical_average": 38.45
    },
    "total_grants_share_formatted": "$384.52"
}
Try it out:
Tests sophisticated year-by-year calculations with project duration analysis
Rate Limits

No rate limits currently enforced, but please be respectful:

  • Maximum 1000 results per API call
  • Reasonable request frequency
  • Cache results when possible
  • Use appropriate pagination for large datasets
Data Notes
  • Data updated regularly from official sources
  • All monetary values in Canadian dollars
  • Dates in ISO format (YYYY-MM-DD)
  • Province codes use standard 2-letter abbreviations
  • Notable grants identified by keyword analysis
Error Responses
Code Status Description Example Response
400 Bad Request Invalid parameters {"error": "Invalid input: min_value must be a number"}
404 Not Found Resource not found {"error": "Grant not found"}
405 Method Not Allowed Wrong HTTP method {"error": "POST method required"}
500 Internal Server Error Server error {"error": "Calculation error: Division by zero"}