Skip to content

Public API Routes — News & Senators #6

@calebyhan

Description

@calebyhan

Motivation

News and Senators are the two most-visited public sections. Shipping these endpoints first allows the frontend team to integrate real data immediately and validates the full stack end-to-end (model → schema → route → response).

Deliverables

  • Create a reusable pagination utility (app/utils/pagination.py) that accepts page and limit query params and returns offset/limit + total count metadata
  • Implement GET /api/news — paginated, most recent first, only is_published=True
  • Implement GET /api/news/:id — single article, 404 if not found or not published
  • Implement GET /api/senators — filterable by search (name), district_id, committee (id), session (number); defaults to active senators in current session
  • Implement GET /api/senators/:id — single senator with committee assignments included
  • Create router files: app/routers/news.py, app/routers/senators.py
  • Register routers in app/main.py
  • Write integration tests using httpx.AsyncClient with a test database
  • Seed test data in a pytest fixture

Important Notes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions