Skip to content

Update API docs: forecasts and self-contained metadata reference - #3589

Merged
Baalmart merged 3 commits into
stagingfrom
apidocs-update
Jun 7, 2026
Merged

Update API docs: forecasts and self-contained metadata reference#3589
Baalmart merged 3 commits into
stagingfrom
apidocs-update

Conversation

@Baalmart

@Baalmart Baalmart commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

🚀 Pull Request

📋 Description

What does this PR do?

Updates the AirQo public API documentation (src/docs-website) across two major areas:

Forecast API (/api/v2/predict/):

  • Rewrites forecasts/overview.md with the current endpoint paths (/predict/daily-forecasting/, /predict/hourly-forecasting/), accurate request parameters (site_id, grid_id, cohort_id), and full response examples for both daily and hourly formats
  • Adds previously missing content sourced from the predict microservice: hourly uncertainty bounds (pm2_5_q10/pm2_5_q90), complete meteorological fields, wind direction as compass string, AQI category table, trend messages, the optional scope disambiguation parameter, and a caching/update frequency note
  • Corrects reference/response-structure.md to reference the current endpoint paths and updated response shape
  • Corrects for-partners/intro.md: cohort-based forecasting is now supported (was incorrectly marked ❌)
  • Updates for-cities/intro.md with accurate forecast parameter note and a direct link to the Forecast API page
  • Adds a 400 Bad Request error entry in reference/error-codes.md for the mutual-exclusion validation on site_id/grid_id/cohort_id
  • Adds forecast endpoints to the endpoint structure tables in both for-cities/intro.md and for-partners/intro.md

Metadata API (new self-contained reference):

  • Creates reference/metadata.md — a complete, internally-hosted Metadata API reference covering grids, cohorts, sites, devices, and locations, with endpoint definitions, query parameters, example responses, device category tables, and common workflow guides
  • Removes all five occurrences of the external link to docs.airqo.net/airqo-rest-api-documentation/api-endpoints/metadata across reference/finding-ids.md, for-cities/intro.md, and for-partners/intro.md, replacing each with deep links into the new internal page
  • Expands reference/finding-ids.md with API-call-based discovery instructions and a new quick-reference table of all eight metadata discovery endpoints

Why is this change needed?

The external metadata documentation link (docs.airqo.net/airqo-rest-api-documentation) is being retired. Keeping references to it would leave users hitting a dead end. All discovery content is now self-contained within this documentation site.

The forecast documentation also referenced deprecated endpoint paths (/predict/hourly-forecast, /predict/daily-forecast) and an outdated response structure, and incorrectly stated that cohort-based forecasting was unavailable — all of which have been corrected to match the current predict microservice behaviour.


🔗 Related Issues

  • Closes #
  • Fixes #
  • Related to #

🔄 Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🔧 Enhancement/improvement
  • 📚 Documentation update
  • ♻️ Refactor
  • 🗑️ Removal/deprecation

🏗️ Affected Services

Microservices changed: N/A — documentation only

Documentation files changed:

  • src/docs-website/docs/api/forecasts/overview.md — full rewrite
  • src/docs-website/docs/api/reference/metadata.md — new file
  • src/docs-website/docs/api/reference/finding-ids.md — expanded
  • src/docs-website/docs/api/reference/response-structure.md — forecast section updated
  • src/docs-website/docs/api/reference/error-codes.md — new 400 error entry
  • src/docs-website/docs/api/for-cities/intro.md — forecast + metadata links updated
  • src/docs-website/docs/api/for-partners/intro.md — forecast availability corrected, metadata links updated

🧪 Testing

  • Unit tests added/updated
  • Manual testing completed
  • All existing tests pass

Test summary:
Manual review of all changed files. Verified zero remaining references to the retired external metadata URL (grep confirmed clean). Cross-checked all internal links between pages for correctness. Endpoint paths, parameters, and response examples validated against the live predict microservice (/src/predict/api/routes.py, prediction.py) and device-registry metadata routes (/src/device-registry/routes/v2/metadata.routes.js, grids.routes.js, cohorts.routes.js).


💥 Breaking Changes

  • No breaking changes
  • Has breaking changes (describe below)

Documentation-only changes. No API behaviour, code, or configuration is modified.


📝 Additional Notes

  • The old forecast endpoints (/predict/hourly-forecast, /predict/daily-forecast) still exist in the microservice for backward compatibility but are not documented here; the new -forecasting variants are the current public-facing API.
  • The reference/metadata.md page covers only publicly accessible metadata endpoints (no JWT-scoped admin endpoints). Internal/tenant-scoped device-registry routes are intentionally excluded from public docs.
  • The forecast cohort_id support correction in for-partners/intro.md aligns with actual microservice behaviour — cohort_id is a valid parameter on both /predict/daily-forecasting/ and /predict/hourly-forecasting/.

✅ Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • Ready for review

Summary by CodeRabbit

  • Documentation
    • Expanded Forecast API documentation with daily and hourly endpoints.
    • Added new Metadata API documentation for discovering grids, cohorts, sites, and devices.
    • Updated guidance for finding Grid IDs, Cohort IDs, and Site IDs.
    • Clarified error response format for conflicting forecast parameters.
    • Updated forecast response structure with new data envelope format.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Baalmart, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 13 minutes and 16 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5b0afd1f-2cff-46ea-a4d6-f2955a38179b

📥 Commits

Reviewing files that changed from the base of the PR and between 07b8069 and 974ae05.

📒 Files selected for processing (5)
  • src/docs-website/docs/api/forecasts/overview.md
  • src/docs-website/docs/api/reference/error-codes.md
  • src/docs-website/docs/api/reference/finding-ids.md
  • src/docs-website/docs/api/reference/metadata.md
  • src/docs-website/docs/api/reference/response-structure.md
📝 Walkthrough

Walkthrough

This PR comprehensively updates API documentation for the AirQo platform, introducing a versioned Forecast API with daily and hourly PM2.5 forecasting endpoints, a new Metadata API for discovering monitoring infrastructure, and realigning all related reference material and client-facing guides.

Changes

API Documentation Overhaul

Layer / File(s) Summary
Forecast API Overview
src/docs-website/docs/api/forecasts/overview.md
New versioned Forecast API documentation describing PM2.5 site-level forecasting via /api/v2/predict/daily-forecasting/ (7-day horizon) and /api/v2/predict/hourly-forecasting/ (240-hour default). Covers request parameters (exactly one of site_id, grid_id, cohort_id), daily and hourly response schemas grouped by day and hour respectively, scope-based aggregated retrieval for grids/cohorts, response field reference tables, AQI category mappings, validation error response for conflicting parameters, and caching guidance aligned to model run cycles.
Metadata API Reference
src/docs-website/docs/api/reference/metadata.md
New comprehensive documentation for the Metadata API, explaining how to browse AirQo infrastructure: grids, cohorts, sites, devices, and administrative locations. Includes endpoint listings, query parameter tables, example request/response payloads, pagination details (limit/skip), and common workflows for discovering Grid, Site, and Device IDs.
Error Codes and Response Structure
src/docs-website/docs/api/reference/error-codes.md, src/docs-website/docs/api/reference/response-structure.md
Clarified that forecast endpoints use success: false error format. Added 400 Bad Request — conflicting forecast parameters section documenting the validation error when multiple scope identifiers are supplied. Updated forecast response examples to document v2 schema with data envelope, date/time range fields, per-site grouping, AQI and meteorological fields, and hourly pagination.
Resource Discovery and Navigation
src/docs-website/docs/api/reference/finding-ids.md
Updated ID-finding guidance to direct users to Metadata API endpoints for discovering Grid, Cohort, and Site IDs instead of external browsing instructions. Added a new "Browsing via the Metadata API" reference table mapping resources to their corresponding endpoints.
Client-Facing Access Guides
src/docs-website/docs/api/for-cities/intro.md, src/docs-website/docs/api/for-partners/intro.md
Updated endpoint structure tables for cities and partners to include new daily and hourly grid/cohort forecast endpoints with their required query parameters. Revised ID-discovery guidance to use the Metadata API (grids summary and cohorts endpoints). Updated availability status to mark "Air quality forecasts" as Premium and available via grid_id/cohort_id. Added links to "Get air quality forecasts" guide in Next steps sections.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

📡 From forecasts old to v2 new,
Grids and cohorts forecast true,
Metadata API lights the way,
To find each site, each grid, each day—
Premium PM2.5 clarity found,
With AQI wisdom all around! 🌍✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: updating API documentation for forecasts and adding a self-contained metadata reference, which aligns with the changeset's primary objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch apidocs-update

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/docs-website/docs/api/reference/error-codes.md (1)

8-8: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

The page currently contradicts itself on “consistent” error shape.

Line 8 states consistency, but the documented schemas differ (status/code vs success/error). Please explicitly split error formats by API family (e.g., Devices/Analytics vs Forecast) to prevent incorrect client-side parsing assumptions.

Also applies to: 12-30, 114-122

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/docs-website/docs/api/reference/error-codes.md` at line 8, The doc claims
a single "consistent" error shape but shows two different schemas; update
error-codes.md to explicitly split and document the error formats per API family
(e.g., Devices/Analytics use {status, code, message, data} while Forecast uses
{success, error, details} or whatever the actual shapes are), add clear headings
"Devices/Analytics error format" and "Forecast error format", provide canonical
JSON schema examples for each, and add a short note calling out the difference
so clients know which format to expect for each API family; ensure the examples
match the real response fields used by the implementations referenced in the
repo.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/docs-website/docs/api/forecasts/overview.md`:
- Around line 18-20: The fenced code blocks containing the endpoint snippets
(for example the block with "GET /api/v2/predict/daily-forecasting/") are
missing a language tag and trigger markdownlint MD040; update each such
triple-backtick fence (including the other endpoint/snippet fences in the same
document) to use an explicit language like ```http or ```text so the snippets
render and pass docs CI. Locate the fences around the GET/endpoint examples and
prepend the language identifier to each opening ``` fence.
- Line 53: The docs declare wind_from_direction as "degrees" but examples and
the field reference use compass strings like "NE"; change the canonical
type/units for wind_from_direction to a compass/cardinal-direction string (e.g.,
"N","NE","E", etc.) throughout the doc so examples, the field description and
any sample payloads match; update the top-level schema entry for
wind_from_direction, both example blocks, and the field reference text to
specify "compass" or "cardinal-direction string" instead of "degrees".

In `@src/docs-website/docs/api/reference/metadata.md`:
- Around line 20-22: The fenced code blocks showing HTTP endpoints (e.g., the
block containing "GET /api/v2/devices/metadata/grids?token={SECRET_TOKEN}" and
the other similar endpoint blocks listed) are missing a language tag; add a
language identifier such as ```http (or ```text) to each of those fenced blocks
so markdownlint MD040 is satisfied—update every occurrence mentioned (lines
showing GET ... endpoints at the listed locations) to start with ```http and
leave the block content unchanged.

---

Outside diff comments:
In `@src/docs-website/docs/api/reference/error-codes.md`:
- Line 8: The doc claims a single "consistent" error shape but shows two
different schemas; update error-codes.md to explicitly split and document the
error formats per API family (e.g., Devices/Analytics use {status, code,
message, data} while Forecast uses {success, error, details} or whatever the
actual shapes are), add clear headings "Devices/Analytics error format" and
"Forecast error format", provide canonical JSON schema examples for each, and
add a short note calling out the difference so clients know which format to
expect for each API family; ensure the examples match the real response fields
used by the implementations referenced in the repo.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 655200eb-c711-4040-9a1c-f12c57717366

📥 Commits

Reviewing files that changed from the base of the PR and between 60920b3 and 07b8069.

📒 Files selected for processing (7)
  • src/docs-website/docs/api/for-cities/intro.md
  • src/docs-website/docs/api/for-partners/intro.md
  • src/docs-website/docs/api/forecasts/overview.md
  • src/docs-website/docs/api/reference/error-codes.md
  • src/docs-website/docs/api/reference/finding-ids.md
  • src/docs-website/docs/api/reference/metadata.md
  • src/docs-website/docs/api/reference/response-structure.md

Comment thread src/docs-website/docs/api/forecasts/overview.md Outdated
Comment thread src/docs-website/docs/api/forecasts/overview.md Outdated
Comment thread src/docs-website/docs/api/reference/metadata.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the public API documentation site (src/docs-website) to (1) align Forecast API docs with the current predict-service endpoints/response shapes and (2) replace a retiring external Metadata documentation link with a new, fully self-contained internal Metadata API reference.

Changes:

  • Reworked Forecast API docs to use /api/v2/predict/daily-forecasting/ and /api/v2/predict/hourly-forecasting/, with updated response examples and field references.
  • Added a new internal Metadata API reference page and rewired “Finding IDs” + partner/city intro pages to link to it instead of docs.airqo.net.
  • Added/updated reference content for validation errors and forecast response structure.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/docs-website/docs/api/reference/response-structure.md Updates the forecast response reference to match the current forecasting endpoints and schema pointers.
src/docs-website/docs/api/reference/metadata.md Adds a new internal, self-contained Metadata API reference (grids/cohorts/sites/devices/locations).
src/docs-website/docs/api/reference/finding-ids.md Replaces retired external metadata links with internal Metadata API guidance and adds a discovery endpoint quick table.
src/docs-website/docs/api/reference/error-codes.md Adds a documented 400 error example for mutually exclusive forecast identifiers.
src/docs-website/docs/api/forecasts/overview.md Major rewrite of Forecast API docs including daily/hourly endpoints, examples, and field reference tables.
src/docs-website/docs/api/for-partners/intro.md Updates partner onboarding docs to reflect cohort forecasting availability and new metadata references.
src/docs-website/docs/api/for-cities/intro.md Updates city onboarding docs with forecast endpoints and internal metadata references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +52 to +54
"wind_speed": "m/s",
"wind_from_direction": "degrees",
"forecast_confidence": "%"
Comment on lines +147 to +149
"wind_speed": "m/s",
"wind_from_direction": "degrees",
"forecast_confidence": "%"
Comment on lines +59 to +63
"site_id": "site-123",
"site_name": "Kampala Central",
"site_latitude": 0.3476,
"site_longitude": 32.5825
},
Comment on lines +154 to +158
"site_id": "site-123",
"site_name": "Kampala Central",
"site_latitude": 0.3476,
"site_longitude": 32.5825
},
Comment on lines +207 to +211
"scope": {
"type": "grid",
"id": "grid-123",
"grid_id": "grid-123"
},
Comment on lines +203 to 205
### Scope Metadata Returned

```json
"units": { "pm2_5": "ug/m3", "forecast_confidence": "%" },
"forecasts": [
{
"site_details": { "site_id": "site-123", "site_name": "Kampala Central" },
Comment on lines +78 to +81
---

---

Baalmart added 2 commits June 7, 2026 23:52
Fix all issues raised in inline review comments across the forecast and
reference documentation pages.

- Add `http` language tag to all bare fenced code blocks in
  forecasts/overview.md (3 blocks) and reference/metadata.md (13 blocks)
  to satisfy markdownlint MD040 and ensure correct syntax highlighting
- Correct `units.wind_from_direction` value from "degrees" to "compass"
  in both the daily and hourly response examples; the predict microservice
  converts raw degree values to compass strings (e.g. "NE", "SW") before
  returning them, making the old unit label internally inconsistent with
  the example payloads and field reference table
- Replace placeholder `site_id: "site-123"` with a realistic 24-char hex
  ID in forecasts/overview.md (daily + hourly blocks) and
  reference/response-structure.md to match the documented ID format
- Replace placeholder scope IDs ("grid-123") with a realistic 24-char hex
  ID in the scope metadata example in forecasts/overview.md
- Add envelope clarification note before the scope metadata JSON block so
  readers understand the object is nested inside `{ "success": true,
  "data": { ... } }`, consistent with all other response examples
- Split the "consistent error response" claim in reference/error-codes.md
  into two explicitly documented formats — Devices/Analytics API
  (`status`, `message`, `code`) and Forecast API (`success`, `message`,
  `error`) — each with a field table, replacing the contradictory single
  "consistent" description
- Remove duplicate horizontal rule (`---` appearing twice consecutively)
  in reference/finding-ids.md
…eferenceError

The link display text contained a bare {GRID_ID} placeholder which MDX
evaluated as a JSX expression, throwing ReferenceError at static site
generation. Moved the path template into an adjacent code span instead.
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

New azure docs changes available for preview here

@Baalmart
Baalmart merged commit 6acf7cb into staging Jun 7, 2026
27 checks passed
@Baalmart
Baalmart deleted the apidocs-update branch June 7, 2026 21:29
@Baalmart Baalmart mentioned this pull request Jun 7, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants