Async API¶
Every sync service has an Async* counterpart with the same method surface, importable from
congressgov.async_api:
from congressgov.async_api import AsyncBill
bill = await AsyncBill(client=async_client).get(congress=118, bill_type="hr", bill_number=1)
Async Congress.gov services.
from congressgov.async_api import AsyncBill, AsyncMember
AsyncAmendment ¶
AsyncAmendment(client: 'AuthenticatedClient | None' = None)
Bases: AsyncApiService
Amendment service provides API access for fetching Congressional amendment data.
This service class handles API interactions for fetching amendments from the Congress.gov API. Instance methods on the Amendment model (registered in congressgov.services.extensions.amendments) provide additional functionality.
Separation of Concerns: - This service class: Fetches data from API (get, search) - Amendment model extensions: Operate on fetched data (expand, get_actions, etc.) - Amendments model extensions: Query and filter collections (filter, by_type, etc.)
USAGE EXAMPLES
Fetch an amendment¶
amendment_service = Amendment(client=my_client) amendment = amendment_service.get(congress=118, amendment_type="hamdt", amendment_number="1")
Use extension methods¶
expanded = amendment.expand(attributes=['actions', 'cosponsors']) actions = amendment.get_actions()
Search for amendments¶
amendments = amendment_service.search(congress=118, limit=10) house_amdts = amendments.house_amendments()
Initialize Amendment service.
Source code in src/congressgov/services/async_api/amendment.py
73 74 75 76 | |
get
async
¶
get(*, client: 'AuthenticatedClient | None' = None, congress: int, amendment_type: str, amendment_number: str, format_: str | None = None) -> 'AmendmentModel'
Retrieve a single amendment's details from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. |
None
|
congress
|
int
|
Congress number. |
required |
amendment_type
|
str
|
Amendment type (e.g., 'hamdt', 'samdt'). |
required |
amendment_number
|
str
|
Amendment number. |
required |
format_
|
str | None
|
Response format. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Amendment |
'AmendmentModel'
|
Parsed Amendment model with client attached. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If parameters are invalid (includes suggestions) |
APIError
|
If API request fails |
ClientNotFoundError
|
If no client is available |
Example
amendment_service = Amendment(client=my_client) amendment = amendment_service.get(congress=118, amendment_type="hamdt", amendment_number="1") expanded = amendment.expand()
Source code in src/congressgov/services/async_api/amendment.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
search
async
¶
search(*, client: 'AuthenticatedClient | None' = None, congress: int | None = None, amendment_type: str | None = None, format_: str | None = None, offset: int | None = None, limit: int | None = None, from_date_time: str | None = None, to_date_time: str | None = None, sort: str | None = None) -> 'AmendmentsModel'
Search for amendments using the universal search system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. |
None
|
congress
|
int | None
|
Congress number (optional). |
None
|
amendment_type
|
str | None
|
Amendment type (optional). |
None
|
format_
|
str | None
|
Response format. |
None
|
offset
|
int | None
|
Offset for pagination. |
None
|
limit
|
int | None
|
Limit for pagination. |
None
|
from_date_time
|
str | None
|
Start date/time filter. |
None
|
to_date_time
|
str | None
|
End date/time filter. |
None
|
sort
|
str | None
|
Sort order. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Amendments |
'AmendmentsModel'
|
Parsed Amendments collection model. |
Example
amendment_service = Amendment(client=my_client) amendments = amendment_service.search(congress=118, limit=50) house_amdts = amendments.house_amendments()
Source code in src/congressgov/services/async_api/amendment.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
AsyncBill ¶
AsyncBill(client: 'AuthenticatedClient | None' = None)
Bases: AsyncApiService
Async Bill service provides non-blocking API access for fetching Congressional bill data.
This async service class mirrors the sync Bill service but uses async/await for non-blocking operations. It handles API interactions asynchronously for fetching bills from the Congress.gov API.
Separation of Concerns: - This service class: Fetches data from API asynchronously (get, search) - Bill model extensions: Operate on fetched data (expand_async, get_actions_async, etc.) - Bills model extensions: Query and filter collections (filter, by_type, etc.)
Key Benefits: - Non-blocking API calls allow concurrent operations - Efficient batch processing with asyncio.gather() - Streaming support for large datasets - Full compatibility with async frameworks (FastAPI, Django async)
USAGE EXAMPLES
Basic async usage - fetch a bill¶
async_bill_service = AsyncBill(client=my_client) bill = await async_bill_service.get(congress=118, bill_type="hr", bill_number=1)
Fetch multiple bills concurrently¶
tasks = [ async_bill_service.get(congress=118, bill_type="hr", bill_number=i) for i in range(1, 11) ] bills = await asyncio.gather(*tasks)
Search for bills¶
bills = await async_bill_service.search(congress=118, bill_type="hr", limit=10)
Stream large datasets¶
async for batch in async_bill_service.search_stream(congress=118, batch_size=50): for bill in batch.bills: # Process each bill without loading all into memory await process_bill(bill)
Initialize AsyncBill service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
Optional API client instance. Can also be provided per-method. |
None
|
Source code in src/congressgov/services/async_api/bill.py
115 116 117 118 119 120 121 122 123 | |
get
async
¶
get(*, client: 'AuthenticatedClient | None' = None, congress: int, bill_type: str, bill_number: int, format_: str | None = None) -> 'BillModel'
Retrieve a single bill's details from the API asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. If None, will use self.client if available. |
None
|
congress
|
int
|
Congress number (e.g., 118 for 118th Congress). |
required |
bill_type
|
str
|
Bill type (e.g., 'hr', 's', 'hjres', 'sjres'). |
required |
bill_number
|
int
|
Bill number. |
required |
format_
|
str | None
|
Response format (default: json). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Bill |
'BillModel'
|
Parsed Bill model instance from API response with client attached. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If parameters are invalid (includes suggestions) |
APIError
|
If API request fails |
ClientNotFoundError
|
If no client is available |
Example
async_bill_service = AsyncBill(client=my_client) bill = await async_bill_service.get(congress=118, bill_type="hr", bill_number=1)
Now use async extension methods¶
expanded_bill = await bill.expand_async() actions = await bill.get_actions_async()
Source code in src/congressgov/services/async_api/bill.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
search
async
¶
search(*, client: 'AuthenticatedClient | None' = None, congress: int | None = None, bill_type: str | None = None, format_: str | None = None, offset: int | None = None, limit: int | None = None, from_date_time: str | None = None, to_date_time: str | None = None, sort: str | None = None) -> 'BillsModel'
Search for bills using the universal search system asynchronously.
This method provides flexible searching across bills with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. If None, will use self.client if available. |
None
|
congress
|
int | None
|
Congress number to filter by (e.g., 118 for 118th Congress). |
None
|
bill_type
|
str | None
|
Bill type to filter by. Valid values: - 'hr': House Bill - 's': Senate Bill - 'hjres': House Joint Resolution - 'sjres': Senate Joint Resolution - 'hconres': House Concurrent Resolution - 'sconres': Senate Concurrent Resolution - 'hres': House Simple Resolution - 'sres': Senate Simple Resolution |
None
|
format_
|
str | None
|
Response format (default: json). |
None
|
offset
|
int | None
|
Pagination offset (number of records to skip). |
None
|
limit
|
int | None
|
Maximum number of results to return (default: 20). |
None
|
from_date_time
|
str | None
|
Start date/time for filtering (ISO 8601 format). |
None
|
to_date_time
|
str | None
|
End date/time for filtering (ISO 8601 format). |
None
|
sort
|
str | None
|
Sort order (e.g., 'updateDate+desc'). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Bills |
'BillsModel'
|
Collection of bills matching the search criteria with attached client |
'BillsModel'
|
for extension methods. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If parameters are invalid (includes suggestions) |
APIError
|
If API request fails |
ClientNotFoundError
|
If no client is available |
Example
async_bill_service = AsyncBill(client=my_client)
Search for House bills from 118th Congress¶
bills = await async_bill_service.search(congress=118, bill_type="hr", limit=50) print(f"Found {len(bills.bills)} House bills")
Search with date filters¶
bills = await async_bill_service.search( ... congress=118, ... from_date_time="2023-01-01T00:00:00Z", ... to_date_time="2023-12-31T23:59:59Z", ... limit=100 ... )
Source code in src/congressgov/services/async_api/bill.py
187 188 189 190 191 192 193 194 195 196 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
search_stream
async
¶
search_stream(*, congress: int | None = None, bill_type: str | None = None, batch_size: int = 100, **kwargs: Any) -> AsyncIterator['BillsModel']
Stream bills in batches for memory-efficient processing of large datasets.
This method yields batches of bills without loading the entire result set into memory at once. Ideal for processing thousands of bills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
congress
|
int | None
|
Congress number to filter by. |
None
|
bill_type
|
str | None
|
Bill type to filter by. |
None
|
batch_size
|
int
|
Number of bills per batch (default: 100). |
100
|
**kwargs
|
Any
|
Additional search parameters (from_date_time, to_date_time, etc.) |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
BillsModel |
AsyncIterator['BillsModel']
|
Batches of bills |
Example
async_bill_service = AsyncBill(client=my_client)
Stream and process bills in batches¶
async for batch in async_bill_service.search_stream( ... congress=118, ... batch_size=50 ... ): ... for bill in batch.bills: ... # Process each bill ... await process_bill(bill) ... print(f"Processed batch of {len(batch.bills)} bills")
Source code in src/congressgov/services/async_api/bill.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
search_by_laws
async
¶
search_by_laws(*, client: 'AuthenticatedClient | None' = None, congress: int | None = None, law_type: str | None = None, law_number: int | None = None, format_: str | None = None, offset: int | None = None, limit: int | None = None) -> 'BillModel | BillsModel'
Search for bills by public or private law asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. |
None
|
congress
|
int | None
|
Congress number. |
None
|
law_type
|
str | None
|
Law type ('pub' or 'priv'). |
None
|
law_number
|
int | None
|
Specific law number. |
None
|
format_
|
str | None
|
Response format. |
None
|
offset
|
int | None
|
Pagination offset. |
None
|
limit
|
int | None
|
Maximum results. |
None
|
Returns:
| Type | Description |
|---|---|
'BillModel | BillsModel'
|
BillModel or BillsModel depending on search specificity. |
Example
Get specific public law¶
bill = await async_bill_service.search_by_laws( ... congress=117, ... law_type="pub", ... law_number=108 ... )
Source code in src/congressgov/services/async_api/bill.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
AsyncBoundCongressionalRecord ¶
AsyncBoundCongressionalRecord(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
BoundCongressionalRecord service provides API access for bound congressional record data.
Source code in src/congressgov/services/async_api/bound_congressional_record.py
23 24 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, year: int = None, month: int = None, format_: str = None, offset: int = None, limit: int = None)
Search for bound congressional records using the universal search system.
Source code in src/congressgov/services/async_api/bound_congressional_record.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
AsyncCRSReport ¶
AsyncCRSReport(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
CRSReport service provides API access for CRS report data.
Source code in src/congressgov/services/async_api/crsreport.py
22 23 24 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, format_: str = None, offset: int = None, limit: int = None)
Search for CRS reports using the universal search system.
Source code in src/congressgov/services/async_api/crsreport.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
AsyncCommittee ¶
AsyncCommittee(client: 'AuthenticatedClient | None' = None)
Bases: AsyncApiService
Committee service provides API access for fetching Congressional committee data.
Separation of Concerns: - This service class: Fetches data from API (get, search) - Committee model extensions: Operate on fetched data (expand, get_bills, etc.) - Committees model extensions: Query and filter collections
Source code in src/congressgov/services/async_api/committee.py
75 76 77 | |
get
async
¶
get(*, client: 'AuthenticatedClient | None' = None, chamber: str, committee_code: str, format_: str | None = None) -> 'CommitteeModel'
Get detailed information about a specific committee.
Source code in src/congressgov/services/async_api/committee.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_by_congress
async
¶
get_by_congress(*, client: 'AuthenticatedClient | None' = None, congress: int, chamber: str, committee_code: str, format_: str | None = None) -> 'CommitteeModel'
Get committee detail scoped to a specific Congress.
Source code in src/congressgov/services/async_api/committee.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 | |
search
async
¶
search(*, client: 'AuthenticatedClient | None' = None, congress: int | None = None, chamber: str | None = None, format_: str | None = None, offset: int | None = None, limit: int | None = None) -> 'CommitteesModel'
Search for committees using the universal search system.
Source code in src/congressgov/services/async_api/committee.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
AsyncCommitteeMeeting ¶
AsyncCommitteeMeeting(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
CommitteeMeeting service provides API access for committee meeting data.
Source code in src/congressgov/services/async_api/committee_meeting.py
33 34 35 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, chamber: str, event_id: str, format_: str = None) -> CommitteeMeetingModel
Get detailed information about a specific committee meeting.
Source code in src/congressgov/services/async_api/committee_meeting.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, chamber: str = None, format_: str = None, offset: int = None, limit: int = None) -> CommitteeMeetingsModel
Search for committee meetings using the universal search system.
Source code in src/congressgov/services/async_api/committee_meeting.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
AsyncCommitteePrint ¶
AsyncCommitteePrint(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
CommitteePrint service provides API access for committee print data.
Source code in src/congressgov/services/async_api/committee_print.py
42 43 44 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, jacket_number: int, chamber: str, format_: str = None) -> CommitteePrintModel
Get detailed information about a specific committee print.
Source code in src/congressgov/services/async_api/committee_print.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_text
async
¶
get_text(*, client: AuthenticatedClient | None = None, congress: int, chamber: str, jacket_number: int, format_: str = None)
Return text versions for a committee print.
Source code in src/congressgov/services/async_api/committee_print.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, format_: str = None, offset: int = None, limit: int = None) -> CommitteePrintsModel
Search for committee prints using the universal search system.
Source code in src/congressgov/services/async_api/committee_print.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
AsyncCommitteeReport ¶
AsyncCommitteeReport(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
CommitteeReport service provides API access for committee report data.
Source code in src/congressgov/services/async_api/committee_report.py
42 43 44 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, report_type: str, report_number: int, format_: str = None) -> CommitteeReportModel
Get detailed information about a specific committee report.
Source code in src/congressgov/services/async_api/committee_report.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
get_text
async
¶
get_text(*, client: AuthenticatedClient | None = None, congress: int, report_type: str, report_number: int, format_: str = None)
Return text versions for a committee report.
Source code in src/congressgov/services/async_api/committee_report.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, report_type: str = None, format_: str = None, offset: int = None, limit: int = None) -> CommitteeReportsModel
Search for committee reports using the universal search system.
Source code in src/congressgov/services/async_api/committee_report.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
AsyncCongress ¶
AsyncCongress(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
Congress service provides API access for Congressional session data.
Source code in src/congressgov/services/async_api/congress.py
42 43 44 | |
current
async
¶
current(*, client: AuthenticatedClient | None = None, format_: str = None) -> CongressModel
Get the current Congress session information.
Source code in src/congressgov/services/async_api/congress.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, format_: str = None) -> CongressModel
Get detailed information about a specific Congress session.
Source code in src/congressgov/services/async_api/congress.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, format_: str = None, offset: int = None, limit: int = None) -> CongressesModel
List all Congress sessions.
Source code in src/congressgov/services/async_api/congress.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
AsyncCongressionalRecord ¶
AsyncCongressionalRecord(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
CongressionalRecord service provides API access for congressional record data.
Source code in src/congressgov/services/async_api/congressional_record.py
16 17 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, year: int = None, month: int = None, day: int = None, format_: str = None, offset: int = None, limit: int = None)
Search for congressional records using the universal search system.
Source code in src/congressgov/services/async_api/congressional_record.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
AsyncDailyCongressionalRecord ¶
AsyncDailyCongressionalRecord(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
Async daily Congressional Record API.
Source code in src/congressgov/services/async_api/daily_congressional_record.py
43 44 45 | |
AsyncHearing ¶
AsyncHearing(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
Hearing service provides API access for Congressional hearing data.
Source code in src/congressgov/services/async_api/hearing.py
25 26 27 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, chamber: str, jacket_number: int, format_: str = None) -> HearingModel
Get detailed information about a specific hearing.
Source code in src/congressgov/services/async_api/hearing.py
29 30 31 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 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, chamber: str = None, format_: str = None, offset: int = None, limit: int = None) -> HearingsModel
Search for hearings using the universal search system.
Source code in src/congressgov/services/async_api/hearing.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
AsyncHouseCommunication ¶
AsyncHouseCommunication(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
HouseCommunication service provides API access for House communication data.
Source code in src/congressgov/services/async_api/house_communication.py
24 25 26 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, communication_type: str, communication_number: int, format_: str = None) -> HouseCommunicationModel
Get detailed information about a specific House communication.
Source code in src/congressgov/services/async_api/house_communication.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, communication_type: str = None, format_: str = None, offset: int = None, limit: int = None) -> HouseCommunicationsModel
Search for House communications using the universal search system.
Source code in src/congressgov/services/async_api/house_communication.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
AsyncHouseRequirement ¶
AsyncHouseRequirement(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
HouseRequirement service provides API access for House requirement data.
Source code in src/congressgov/services/async_api/house_requirement.py
27 28 29 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, requirement_number: int, format_: str = None) -> HouseRequirementModel
Get detailed information about a specific House requirement.
Source code in src/congressgov/services/async_api/house_requirement.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, format_: str = None, offset: int = None, limit: int = None) -> HouseRequirementsModel
Search for House requirements using the universal search system.
Source code in src/congressgov/services/async_api/house_requirement.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
AsyncHouseVote ¶
AsyncHouseVote(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
HouseVote service provides API access for House vote data.
Source code in src/congressgov/services/async_api/house_vote.py
38 39 40 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, session: int, vote_number: int, format_: str = None) -> HouseVoteModel
Get detailed information about a specific House vote.
Source code in src/congressgov/services/async_api/house_vote.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, format_: str = None, offset: int = None, limit: int = None) -> HouseVotesModel
Search for House votes using the universal search system.
Source code in src/congressgov/services/async_api/house_vote.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
list_by_congress_session
async
¶
list_by_congress_session(*, client: AuthenticatedClient | None = None, congress: int, session: int, format_: str = None, offset: int = None, limit: int = None) -> HouseVotesModel
List House votes for a Congress and session.
Source code in src/congressgov/services/async_api/house_vote.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
members
async
¶
members(*, client: AuthenticatedClient | None = None, congress: int, session: int, vote_number: int, format_: str = None, offset: int = None, limit: int = None) -> MemberVotesModel
Return per-member vote positions for a House roll call vote (beta endpoint).
Source code in src/congressgov/services/async_api/house_vote.py
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 | |
AsyncMember ¶
AsyncMember(client: 'AuthenticatedClient | None' = None)
Bases: AsyncApiService
Member service provides API access for fetching Congressional member data.
This service class handles API interactions for fetching member information from the Congress.gov API. Once a member is fetched, instance methods on the Member model (registered in congressgov.services.extensions.members) provide additional functionality like fetching sponsored/cosponsored legislation.
Separation of Concerns: - This service class: Fetches data from API (get, search, get_current_roster) - Member model extensions: Operate on fetched data (get_sponsored_legislation, etc.) - Members model extensions: Query and filter collections (filter, by_state, etc.)
USAGE EXAMPLES
Basic usage - fetch a member¶
member_service = Member(client=my_client) member = member_service.get(bioguide_id="A000374")
Now use extension methods on the member instance¶
sponsored = member.get_sponsored_legislation() cosponsored = member.get_cosponsored_legislation()
Search for members¶
members = member_service.search(state="CA", limit=10)
Use extension methods on Members collection¶
democrats = members.democrats() by_state = members.group_by("state")
Get current roster¶
roster = member_service.get_current_roster() house_members = roster['house_members'] senate_members = roster['senate_members']
Initialize Member service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
Optional API client instance. Can also be provided per-method. |
None
|
Source code in src/congressgov/services/async_api/member.py
87 88 89 90 91 92 93 94 95 | |
get
async
¶
get(*, client: 'AuthenticatedClient | None' = None, bioguide_id: str, format_: str | None = None) -> 'MemberModel'
Get detailed information about a specific member from the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. If None, will use self.client if available. |
None
|
bioguide_id
|
str
|
The member's Bioguide ID (e.g., "A000374"). |
required |
format_
|
str | None
|
Response format (default: json). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Member |
'MemberModel'
|
The member details with client attached. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If parameters are invalid (includes suggestions) |
APIError
|
If API request fails |
ClientNotFoundError
|
If no client is available |
Example
member_service = Member(client=my_client) member = member_service.get(bioguide_id="A000374")
Now use extension methods¶
sponsored = member.get_sponsored_legislation()
Source code in src/congressgov/services/async_api/member.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 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 | |
search
async
¶
search(*, client: 'AuthenticatedClient | None' = None, congress: int | None = None, state: str | None = None, district: int | None = None, format_: str | None = None, offset: int | None = None, limit: int | None = None, from_date_time: str | None = None, to_date_time: str | None = None, current_member: str | None = None) -> 'MembersModel'
Search for members with optional filters using the universal search system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
'AuthenticatedClient | None'
|
The API client instance. If None, will use self.client if available. |
None
|
congress
|
int | None
|
The Congress number (e.g., 117, 118). Optional. |
None
|
state
|
str | None
|
The state abbreviation (e.g., "CA", "NY"). Optional. |
None
|
district
|
int | None
|
The district number. Optional. |
None
|
format_
|
str | None
|
Response format (default: json). |
None
|
offset
|
int | None
|
Number of records to skip. Optional. |
None
|
limit
|
int | None
|
Maximum number of records to return. Optional. |
None
|
from_date_time
|
str | None
|
Return members updated after this datetime (ISO format). Optional. |
None
|
to_date_time
|
str | None
|
Return members updated before this datetime (ISO format). Optional. |
None
|
current_member
|
str | None
|
Filter for current members ("true" or "false"). Optional. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Members |
'MembersModel'
|
List of members matching the search criteria. |
Example
member_service = Member(client=my_client) members = member_service.search(state="CA", current_member="true")
Now use collection extension methods¶
democrats = members.democrats() by_party = members.group_by("partyName")
Source code in src/congressgov/services/async_api/member.py
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 | |
list_by_congress
async
¶
list_by_congress(*, client: 'AuthenticatedClient | None' = None, congress: int, format_: str | None = None, offset: int | None = None, limit: int | None = None, current_member: bool | None = None, fetch_all: bool = False) -> 'MembersModel'
List members who served in a specific Congress.
When fetch_all is True, requests pages of up to 250 members until the
API returns a short or empty page. offset is ignored in that mode;
limit sets the per-request page size (default 250).
Source code in src/congressgov/services/async_api/member.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
get_current_roster
async
¶
get_current_roster(*, client: Any = None) -> dict[str, MembersModel]
Get the current roster of members, separated by House and Senate.
This method fetches all current members and separates them into House and Senate based on their most recent term.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Any
|
The API client instance. If None, will use self.client if available. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Members]
|
Dictionary with keys 'house_members' and 'senate_members', each containing a Members model with the respective members. |
Example
member_service = Member(client=my_client) roster = member_service.get_current_roster() house = roster['house_members'] # Members object senate = roster['senate_members'] # Members object print(f"House: {len(house)}, Senate: {len(senate)}")
Source code in src/congressgov/services/async_api/member.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
AsyncNomination ¶
AsyncNomination(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
Nomination service provides API access for Congressional nomination data.
Source code in src/congressgov/services/async_api/nomination.py
44 45 46 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, nomination_number: int, format_: str = None) -> NominationModel
Get detailed information about a specific nomination.
Source code in src/congressgov/services/async_api/nomination.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
get_nominees
async
¶
get_nominees(*, client: AuthenticatedClient | None = None, congress: int, nomination_number: int, ordinal: int, format_: str = None, offset: int = None, limit: int = None) -> NomineesModel
Get nominees for a nomination at a specific ordinal.
Source code in src/congressgov/services/async_api/nomination.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, format_: str = None, offset: int = None, limit: int = None) -> NominationsModel
Search for nominations using the universal search system.
Source code in src/congressgov/services/async_api/nomination.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
AsyncSenateCommunication ¶
AsyncSenateCommunication(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
SenateCommunication service provides API access for Senate communication data.
Source code in src/congressgov/services/async_api/senate_communication.py
24 25 26 | |
get
async
¶
get(*, client: AuthenticatedClient | None = None, congress: int, communication_type: str, communication_number: int, format_: str = None) -> SenateCommunicationModel
Get detailed information about a specific Senate communication.
Source code in src/congressgov/services/async_api/senate_communication.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, congress: int = None, communication_type: str = None, format_: str = None, offset: int = None, limit: int = None) -> SenateCommunicationsModel
Search for Senate communications using the universal search system.
Source code in src/congressgov/services/async_api/senate_communication.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
AsyncSummaries ¶
AsyncSummaries(client: AuthenticatedClient | None = None)
Bases: AsyncApiService
Summaries service provides API access for bill summaries data.
Source code in src/congressgov/services/async_api/summaries.py
20 21 | |
search
async
¶
search(*, client: AuthenticatedClient | None = None, format_: str = None, offset: int = None, limit: int = None) -> SummariesModel
Search for bill summaries using the universal search system.
Source code in src/congressgov/services/async_api/summaries.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
AsyncTreaty ¶
AsyncTreaty(client: 'AuthenticatedClient | None' = None)
Bases: AsyncApiService
Treaty service provides API access for treaty data.
Source code in src/congressgov/services/async_api/treaty.py
42 43 44 | |
get
async
¶
get(*, client: 'AuthenticatedClient | None' = None, congress: int, treaty_number: int, treaty_suffix: str | None = None, format_: str | None = None) -> TreatyModel
Get detailed information about a specific treaty.
Raises:
| Type | Description |
|---|---|
ClientNotFoundError
|
If no API client is available. |
Source code in src/congressgov/services/async_api/treaty.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
search
async
¶
search(*, client: 'AuthenticatedClient | None' = None, congress: int | None = None, format_: str | None = None, offset: int | None = None, limit: int | None = None) -> TreatiesModel
Search for treaties using the universal search system.
Source code in src/congressgov/services/async_api/treaty.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
get_actions
async
¶
get_actions(*, client: 'AuthenticatedClient | None' = None, congress: int, treaty_number: int, format_: str | None = None) -> ActionsModel
Return actions for a treaty.
Source code in src/congressgov/services/async_api/treaty.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |