Models¶
Pydantic models for the data services return. All of them subclass the shared Model base (parses
API date strings, tolerant model_validate, readable __repr__/pretty_print) documented at the
bottom of this page.
Bills¶
Summary ¶
Bases: Model
Congressional Research Service (CRS) summary of a bill.
CRS provides objective, nonpartisan summaries of legislation at various stages of the legislative process. Summaries may be updated as bills progress.
Example
summary = Summary( ... text="This bill amends the Clean Air Act...", ... actionDate=date(2023, 1, 15), ... versionCode="00" ... )
Summaries ¶
Bases: Model
Container for a list of bill summaries.
Represents the collection of all CRS summaries for a bill across different versions and stages of the legislative process.
Example
summaries = Summaries(summaries=[ ... Summary(text="Introduced version summary", versionCode="00"), ... Summary(text="Passed House summary", versionCode="36") ... ])
ConstitutionalAuthorityStatement ¶
Bases: Model
Constitutional authority statement for a bill.
House Rule XII, clause 7(c) requires that each bill or joint resolution include a statement citing the specific constitutional authority for enacting the proposed law.
Example
statement = ConstitutionalAuthorityStatement( ... text="Congress has the power to enact this legislation pursuant to Article I, Section 8...", ... submitted_date=date(2023, 1, 9) ... )
TextVersionFormat ¶
Bases: Model
Format information for a specific version of bill text.
Bill text is available in multiple formats (PDF, XML, HTML, etc.). Each format has a URL for downloading or viewing the text.
Example
format = TextVersionFormat( ... url="https://www.congress.gov/118/bills/hr1/BILLS-118hr1ih.pdf", ... type="PDF" ... )
TextVersionFormats ¶
Bases: Model
Container for available formats of a bill text version.
Groups all available format options (PDF, XML, HTML, etc.) for a specific version of bill text.
Example
formats = TextVersionFormats(formats=[ ... TextVersionFormat(url="http://example.com/bill.pdf", type="PDF"), ... TextVersionFormat(url="http://example.com/bill.xml", type="XML") ... ])
TextVersionItem ¶
Bases: Model
A specific version of bill text.
Bills go through multiple versions as they progress through Congress (Introduced, Engrossed, Enrolled, etc.). Each version represents the bill text at a specific stage of the legislative process.
Common Version Types
- IH: Introduced in House
- IS: Introduced in Senate
- EH: Engrossed in House (passed)
- ES: Engrossed in Senate (passed)
- ENR: Enrolled (passed both chambers, sent to President)
Example
version = TextVersionItem( ... type="IH", ... date=date(2023, 1, 9), ... formats=[TextVersionFormat(url="...", type="PDF")] ... )
TextVersions ¶
Bases: Model
Container for all text versions of a bill.
Represents the collection of all text versions for a bill as it progresses through the legislative process. Can handle multiple API response formats.
API Response Forms
- Reference form: {"count": N, "url": "..."}
- Content form: [{"type": "IH", "date": "...", "formats": [...]}]
- Wrapped form: {"textVersions": [...]}
Example
versions = TextVersions(textVersions=[ ... TextVersionItem(type="IH", date=date(2023, 1, 9)), ... TextVersionItem(type="EH", date=date(2023, 3, 15)) ... ])
Members¶
Sponsors & cosponsors¶
Sponsor ¶
Cosponsor ¶
Bases: Model
A cosponsor of a bill, with sponsorship date and withdrawal status.
sponsorship_date
property
writable
¶
sponsorship_date: date | None
Return the date this cosponsorship was made.
is_original_cosponsor
property
writable
¶
is_original_cosponsor: bool | None
Return True if this cosponsor is an original cosponsor.
sponsorship_withdrawn_date
property
writable
¶
sponsorship_withdrawn_date: date | None
Return the date this cosponsorship was withdrawn, if any.
withdrawal_date
property
writable
¶
withdrawal_date: date | None
Alias for sponsorship_withdrawn_date.
Amendments¶
Treaties¶
Congress sessions¶
Congress ¶
Bases: Model, CongressProtocol, AsyncCongressProtocol
Congress model with sync and async extension method type hints.
congress_number_from_url ¶
congress_number_from_url(url: str | None) -> int | None
Extract a session number from a Congress.gov API URL.
Source code in src/congressgov/models/entities/congress.py
16 17 18 19 20 21 22 23 | |
congress_number_from_name ¶
congress_number_from_name(name: str | None) -> int | None
Extract a session number from labels like 119th Congress.
Source code in src/congressgov/models/entities/congress.py
26 27 28 29 30 31 32 33 | |
infer_congress_number ¶
infer_congress_number(*, number: int | None = None, congress: int | None = None, name: str | None = None, url: str | None = None) -> int | None
Resolve a Congress session number from known model fields.
Source code in src/congressgov/models/entities/congress.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
Committees¶
CommitteeBills ¶
Bases: Model
A container for a committee's bills, as BillRefs (to avoid a circular
import with the full Bill model), with optional url/count metadata.
Actions¶
Lightweight references¶
Minimal reference models (BillRef, CommitteeRef, MemberRef, etc.) that carry
just enough identification to link to an entity without importing its full model.
Bill, Committee, Action, and Member all reference each other, so importing the
full models directly would create circular imports; these break that cycle.
from models.base.references import BillRef
full_bill = bill_service.get(
congress=bill_ref.congress,
bill_type=bill_ref.type,
bill_number=bill_ref.number,
)
BillRef ¶
Bases: Model
Enough fields to identify a Bill and fetch it later, without the full model's
dependency chain. Used by Committee, Action, and Amendment models.
CommitteeRef ¶
Bases: Model
Enough fields to identify a Committee, for use in Bill, Action, Meeting, and Report models.
MemberRef ¶
Bases: Model
Enough fields to identify a Member, for use in Sponsor, Action, Vote, and Committee models.
AmendmentRef ¶
Bases: Model
Enough fields to identify an Amendment, for use in Bill and Action models,
and for self-references between amendments.
TreatyRef ¶
NominationRef ¶
bill_to_ref ¶
bill_to_ref(bill: Any) -> BillRef
Convert a full Bill (model instance or dict) to a BillRef.
Source code in src/congressgov/models/base/references.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
committee_to_ref ¶
committee_to_ref(committee: Any) -> CommitteeRef
Convert a full Committee (model instance or dict) to a CommitteeRef.
Source code in src/congressgov/models/base/references.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
member_to_ref ¶
member_to_ref(member: Any) -> MemberRef
Convert a full Member (model instance or dict) to a MemberRef.
Source code in src/congressgov/models/base/references.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
amendment_to_ref ¶
amendment_to_ref(amendment: Any) -> AmendmentRef
Convert a full Amendment (model instance or dict) to an AmendmentRef.
Source code in src/congressgov/models/base/references.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
treaty_to_ref ¶
treaty_to_ref(treaty: Any) -> TreatyRef
Convert a full Treaty (model instance or dict) to a TreatyRef.
Source code in src/congressgov/models/base/references.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
nomination_to_ref ¶
nomination_to_ref(nomination: Any) -> NominationRef
Convert a full Nomination (model instance or dict) to a NominationRef.
Source code in src/congressgov/models/base/references.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
Base model¶
congressgov.models.base.model.Model ¶
Bases: BaseModel
pretty_print ¶
pretty_print(indent: int = 0, max_width: int = 120) -> str
Pretty print the model and its nested fields in a readable, indented format. Handles nested models, lists, dicts, and basic types.
Source code in src/congressgov/models/base/model.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
model_validate
classmethod
¶
model_validate(obj, debug: bool = False, **kwargs)
BaseModel.model_validate, plus: pass debug=True to print field-by-field
diagnostics, and if validation fails (or succeeds with every field None),
retry by unwrapping a single top-level key before giving up.
Source code in src/congressgov/models/base/model.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
CountRef ¶
URL ¶
Bases: Model
A URL value that accepts a plain string, a {"url": ...} dict, or another
URL instance, and normalizes all of them to the same shape. Any model field
typed as URL gets this conversion automatically via the core schema hook below.
model_validate
classmethod
¶
model_validate(value: Any) -> 'URL'
Accept a string, dict, URL instance, or list of any of those.
Source code in src/congressgov/models/base/types.py
19 20 21 22 23 24 25 26 27 28 29 30 | |
__get_pydantic_core_schema__
classmethod
¶
__get_pydantic_core_schema__(source_type: Any, handler)
Wrap the standard model schema with a before-validator so any field
typed as URL accepts a plain string or dict, not just a URL instance.
Source code in src/congressgov/models/base/types.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |