Skip to content

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
def __init__(self, client: 'AuthenticatedClient | None' = None) -> None:
    """Initialize Amendment service."""
    self.client = client
    self._last_result: 'AmendmentModel | None' = None

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
async def get(
    self,
    *,
    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.

    Args:
        client: The API client instance.
        congress: Congress number.
        amendment_type: Amendment type (e.g., 'hamdt', 'samdt').
        amendment_number: Amendment number.
        format_: Response format.

    Returns:
        Amendment: Parsed Amendment model with client attached.

    Raises:
        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()
    """
    # --- <VALIDATE PARAMETERS> ---
    validate_congress(congress)
    validate_amendment_type(amendment_type)

    resolved_client = await AsyncApiService._resolve_client(self, client)

    resp = await amendment_details_async(
        client=resolved_client,
        congress=congress,
        amendment_type=amendment_type,
        amendment_number=amendment_number,
        format_=format_,
    )

    api_env = ApiEnvelope.model_validate(json.loads(resp.content))
    result = AmendmentModel.model_validate(api_env.data)

    # Attach client for extension methods
    result.client = resolved_client
    self._last_result = result

    return result

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
async def search(
    self,
    *,
    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.

    Args:
        client: The API client instance.
        congress: Congress number (optional).
        amendment_type: Amendment type (optional).
        format_: Response format.
        offset: Offset for pagination.
        limit: Limit for pagination.
        from_date_time: Start date/time filter.
        to_date_time: End date/time filter.
        sort: Sort order.

    Returns:
        Amendments: Parsed Amendments collection model.

    Example:
        >>> amendment_service = Amendment(client=my_client)
        >>> amendments = amendment_service.search(congress=118, limit=50)
        >>> house_amdts = amendments.house_amendments()
    """
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'amendment',
        self,
        client=client,
        congress=congress,
        amendment_type=amendment_type,
        format_=format_,
        offset=offset,
        limit=limit,
        from_date_time=from_date_time,
        to_date_time=to_date_time,
        sort=sort
    )

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
def __init__(self, client: 'AuthenticatedClient | None' = None) -> None:
    """
    Initialize AsyncBill service.

    Args:
        client: Optional API client instance. Can also be provided per-method.
    """
    self.client = client
    self._last_result: 'BillModel | None' = None  # Store last fetched bill

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
async def get(
    self,
    *,
    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.

    Args:
        client: The API client instance. If None, will use self.client if available.
        congress: Congress number (e.g., 118 for 118th Congress).
        bill_type: Bill type (e.g., 'hr', 's', 'hjres', 'sjres').
        bill_number: Bill number.
        format_: Response format (default: json).

    Returns:
        Bill: Parsed Bill model instance from API response with client attached.

    Raises:
        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()
    """
    # --- <VALIDATE PARAMETERS> ---
    validate_congress(congress)
    validate_bill_type(bill_type)

    # --- <RESOLVE CLIENT PARAMETER> ---
    resolved_client = await AsyncApiService._resolve_client(self, client)

    # --- <CALL ASYNC API> ---
    resp = await bill_details_async(
        congress=congress,
        bill_type=bill_type,
        bill_number=bill_number,
        client=resolved_client,
        format_=format_ or 'json'
    )

    # --- <PARSE AND RETURN> ---
    api_env = ApiEnvelope.model_validate(json.loads(resp.content))
    bill = BillModel.model_validate(api_env.data)

    # Attach client for extension methods
    bill.client = resolved_client

    # Store last result
    self._last_result = bill

    return bill

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
async def search(
    self,
    *,
    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.

    Args:
        client: The API client instance. If None, will use self.client if available.
        congress: Congress number to filter by (e.g., 118 for 118th Congress).
        bill_type: 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
        format_: Response format (default: json).
        offset: Pagination offset (number of records to skip).
        limit: Maximum number of results to return (default: 20).
        from_date_time: Start date/time for filtering (ISO 8601 format).
        to_date_time: End date/time for filtering (ISO 8601 format).
        sort: Sort order (e.g., 'updateDate+desc').

    Returns:
        Bills: Collection of bills matching the search criteria with attached client
        for extension methods.

    Raises:
        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
        ... )
    """
    # --- <VALIDATE PARAMETERS> ---
    if congress is not None:
        validate_congress(congress)
    if bill_type is not None:
        validate_bill_type(bill_type)

    # --- <RESOLVE CLIENT PARAMETER> ---
    resolved_client = await AsyncApiService._resolve_client(self, client)

    # --- <DETERMINE WHICH SEARCH FUNCTION TO USE> ---
    if congress and bill_type:
        # Search by both congress and type
        resp = await bill_list_by_type_async(
            congress=congress,
            bill_type=bill_type,
            client=resolved_client,
            format_=format_ or 'json',
            offset=offset,
            limit=limit,
            from_date_time=from_date_time,
            to_date_time=to_date_time,
            sort=sort
        )
    elif congress:
        # Search by congress only
        resp = await bill_list_by_congress_async(
            congress=congress,
            client=resolved_client,
            format_=format_ or 'json',
            offset=offset,
            limit=limit,
            from_date_time=from_date_time,
            to_date_time=to_date_time,
            sort=sort
        )
    else:
        # Search all bills
        resp = await bill_list_all_async(
            client=resolved_client,
            format_=format_ or 'json',
            offset=offset,
            limit=limit,
            from_date_time=from_date_time,
            to_date_time=to_date_time,
            sort=sort
        )

    # --- <PARSE AND RETURN> ---
    api_env = ApiEnvelope.model_validate(json.loads(resp.content))
    bills = BillsModel.model_validate(api_env.data)

    # Attach client for extension methods
    bills.client = resolved_client
    propagate_client_to_items(bills, "bills", resolved_client)

    return bills

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
async def search_stream(
    self,
    *,
    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.

    Args:
        congress: Congress number to filter by.
        bill_type: Bill type to filter by.
        batch_size: Number of bills per batch (default: 100).
        **kwargs: Additional search parameters (from_date_time, to_date_time, etc.)

    Yields:
        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")
    """
    offset = 0
    stream_kwargs = dict(kwargs)
    stream_kwargs.pop("limit", None)
    while True:
        batch = await self.search(
            congress=congress,
            bill_type=bill_type,
            offset=offset,
            limit=batch_size,
            **stream_kwargs,
        )

        if not batch.bills or len(batch.bills) == 0:
            break

        yield batch
        if len(batch.bills) < batch_size:
            break
        offset += batch_size

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
async def search_by_laws(
    self,
    *,
    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.

    Args:
        client: The API client instance.
        congress: Congress number.
        law_type: Law type ('pub' or 'priv').
        law_number: Specific law number.
        format_: Response format.
        offset: Pagination offset.
        limit: Maximum results.

    Returns:
        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
        ... )
    """
    # --- <VALIDATE PARAMETERS> ---
    if congress is not None:
        validate_congress(congress)

    # --- <RESOLVE CLIENT> ---
    resolved_client = await AsyncApiService._resolve_client(self, client)

    # --- <CALL ASYNC API> ---
    if congress and law_type and law_number:
        # Specific law
        resp = await law_list_by_congress_law_type_and_law_number_async(
            congress=congress,
            law_type=law_type,
            law_number=law_number,
            client=resolved_client,
            format_=format_ or 'json'
        )
        api_env = ApiEnvelope.model_validate(json.loads(resp.content))
        bill = BillModel.model_validate(api_env.data)
        bill.client = resolved_client
        return bill
    elif congress and law_type:
        # By congress and law type
        resp = await law_list_by_congress_and_law_type_async(
            congress=congress,
            law_type=law_type,
            client=resolved_client,
            format_=format_ or 'json',
            offset=offset,
            limit=limit
        )
    elif congress:
        # By congress only
        resp = await law_list_by_congress_async(
            congress=congress,
            client=resolved_client,
            format_=format_ or 'json',
            offset=offset,
            limit=limit
        )
    else:
        raise ValueError("At least 'congress' parameter must be provided")

    # --- <PARSE AND RETURN> ---
    api_env = ApiEnvelope.model_validate(json.loads(resp.content))
    bills = BillsModel.model_validate(api_env.data)
    bills.client = resolved_client
    propagate_client_to_items(bills, "bills", resolved_client)
    return bills

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'bound-congressional-record',
        self,
        client=client,
        year=year,
        month=month,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def search(
    self,
    *,
    client: AuthenticatedClient | None = None,
    format_: str = None,
    offset: int = None,
    limit: int = None
):
    """Search for CRS reports using the universal search system."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'crs-report',
        self,
        client=client,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: 'AuthenticatedClient | None' = None) -> None:
    self.client = client
    self._last_result: 'CommitteeModel | None' = None

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
async def get(
    self,
    *,
    client: 'AuthenticatedClient | None' = None,
    chamber: str,
    committee_code: str,
    format_: str | None = None
) -> 'CommitteeModel':
    """Get detailed information about a specific committee."""
    # --- <VALIDATE PARAMETERS> ---
    validate_chamber(chamber)
    validate_committee_code(committee_code)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    chamber_param = GetCommitteeChamberCommitteeCodeChamber(chamber.lower())

    response = await committee_details_async(
        client=resolved_client,
        chamber=chamber_param,
        committee_code=committee_code,
        format_=resolve_response_format(format_, GetCommitteeChamberCommitteeCodeFormat),
    )
    response_json = json.loads(response.content)

    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CommitteeModel.model_validate(api_envelope.data)

    result.client = resolved_client
    self._last_result = result

    return result

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
async def get_by_congress(
    self,
    *,
    client: 'AuthenticatedClient | None' = None,
    congress: int,
    chamber: str,
    committee_code: str,
    format_: str | None = None,
) -> 'CommitteeModel':
    """Get committee detail scoped to a specific Congress."""
    validate_congress(congress)
    validate_chamber(chamber)
    validate_committee_code(committee_code)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    chamber_param = GetCommitteeCongressChamberCommitteeCodeChamber(chamber)
    response = await committee_by_congress_detailed(
        client=resolved_client,
        congress=congress,
        chamber=chamber_param,
        committee_code=committee_code,
        format_=resolve_response_format(
            format_, GetCommitteeCongressChamberCommitteeCodeFormat
        ),
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CommitteeModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'committee',
        self,
        client=client,
        congress=congress,
        chamber=chamber,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    chamber: str,
    event_id: str,
    format_: str = None
) -> CommitteeMeetingModel:
    """Get detailed information about a specific committee meeting."""
    validate_congress(congress)
    validate_chamber(chamber)
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await committee_meeting_detail_async(
        client=resolved_client,
        congress=congress,
        chamber=resolve_chamber(chamber, GetCommitteeMeetingCongressChamberEventIdChamber),
        event_id=event_id,
        format_=resolve_response_format(
            format_, GetCommitteeMeetingCongressChamberEventIdFormat
        ),
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    raise_for_envelope_detail_response(
        response,
        response_json,
        api_envelope,
        resource_label="Committee meeting",
        identifiers={
            "congress": congress,
            "chamber": chamber,
            "event_id": event_id,
        },
    )
    result = CommitteeMeetingModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'committee-meeting',
        self,
        client=client,
        congress=congress,
        chamber=chamber,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    jacket_number: int,
    chamber: str,
    format_: str = None
) -> CommitteePrintModel:
    """Get detailed information about a specific committee print."""
    validate_congress(congress)
    validate_chamber(chamber)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await committee_print_detail_async(
        client=resolved_client,
        congress=congress,
        jacket_number=jacket_number,
        chamber=chamber,
        format_=format_
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CommitteePrintModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def get_text(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    chamber: str,
    jacket_number: int,
    format_: str = None,
):
    """Return text versions for a committee print."""
    validate_congress(congress)
    validate_chamber(chamber)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await committee_print_text_async(
        client=resolved_client,
        congress=congress,
        chamber=chamber,
        jacket_number=jacket_number,
        format_=format_,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    payload = response_json.get("data", api_envelope.data)
    if isinstance(payload, list):
        return [CommitteePrintTextModel.model_validate(item) for item in payload]
    return CommitteePrintTextModel.model_validate(payload)

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'committee-print',
        self,
        client=client,
        congress=congress,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    report_type: str,
    report_number: int,
    format_: str = None
) -> CommitteeReportModel:
    """Get detailed information about a specific committee report."""
    validate_congress(congress)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await committee_report_details_async(
        client=resolved_client,
        congress=congress,
        report_type=report_type,
        report_number=report_number,
        format_=format_
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CommitteeReportModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def get_text(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    report_type: str,
    report_number: int,
    format_: str = None,
):
    """Return text versions for a committee report."""
    validate_congress(congress)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await committee_report_id_text_async(
        client=resolved_client,
        congress=congress,
        report_type=report_type,
        report_number=report_number,
        format_=format_,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    payload = response_json.get("data", api_envelope.data)
    if isinstance(payload, list):
        return [CommitteeReportTextModel.model_validate(item) for item in payload]
    return CommitteeReportTextModel.model_validate(payload)

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'committee-report',
        self,
        client=client,
        congress=congress,
        report_type=report_type,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def current(
    self,
    *,
    client: AuthenticatedClient | None = None,
    format_: str = None
) -> CongressModel:
    """Get the current Congress session information."""
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await congress_current_list_async(
        client=resolved_client,
        format_=resolve_response_format(format_, GetCongressCurrentFormat),
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CongressModel.model_validate(api_envelope.data)
    result.client = resolved_client
    return result

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    format_: str = None
) -> CongressModel:
    """Get detailed information about a specific Congress session."""
    validate_congress(congress)
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await congress_details_async(
        client=resolved_client,
        congress=congress,
        format_=resolve_response_format(format_, GetCongressCongressFormat),
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CongressModel.model_validate(api_envelope.data)
    _ensure_congress_number(result, congress)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    client: AuthenticatedClient | None = None,
    format_: str = None,
    offset: int = None,
    limit: int = None
) -> CongressesModel:
    """List all Congress sessions."""
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await congress_list_async(
        client=resolved_client,
        format_=resolve_response_format(format_, GetCongressFormat),
        offset=offset,
        limit=limit,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = CongressesModel.model_validate(api_envelope.data)
    result.client = resolved_client
    propagate_client_to_items(result, "congresses", resolved_client)
    return result

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'congressional-record',
        self,
        client=client,
        year=year,
        month=month,
        day=day,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    chamber: str,
    jacket_number: int,
    format_: str = None
) -> HearingModel:
    """Get detailed information about a specific hearing."""
    resolved_client = await AsyncApiService._resolve_client(self, client)

    response = await hearing_detail_async(
        client=resolved_client,
        congress=congress,
        chamber=chamber,
        jacket_number=jacket_number,
        format_=format_,
    )
    response_json = json.loads(response.content)

    api_envelope = ApiEnvelope.model_validate(response_json)
    result = HearingModel.model_validate(api_envelope.data)

    result.client = resolved_client
    self._last_result = result

    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'hearing',
        self,
        client=client,
        congress=congress,
        chamber=chamber,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    communication_type: str,
    communication_number: int,
    format_: str = None
) -> HouseCommunicationModel:
    """Get detailed information about a specific House communication."""
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await house_communication_detail_async(
        client=resolved_client,
        congress=congress,
        communication_type=communication_type,
        communication_number=communication_number,
        format_=format_
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = HouseCommunicationModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'house-communication',
        self,
        client=client,
        congress=congress,
        communication_type=communication_type,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    requirement_number: int,
    format_: str = None
) -> HouseRequirementModel:
    """Get detailed information about a specific House requirement."""
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await house_requirement_detail_async(
        client=resolved_client,
        requirement_number=requirement_number,
        format_=format_
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = HouseRequirementModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    client: AuthenticatedClient | None = None,
    format_: str = None,
    offset: int = None,
    limit: int = None
) -> HouseRequirementsModel:
    """Search for House requirements using the universal search system."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'house-requirement',
        self,
        client=client,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    session: int,
    vote_number: int,
    format_: str = None
) -> HouseVoteModel:
    """Get detailed information about a specific House vote."""
    validate_congress(congress)
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await house_vote_details_async(
        client=resolved_client,
        congress=congress,
        session=session,
        vote_number=vote_number,
        format_=format_,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = HouseVoteModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'house-vote',
        self,
        client=client,
        congress=congress,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
async def list_by_congress_session(
    self,
    *,
    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."""
    validate_congress(congress)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    session_param = GetHouseVoteCongressSessionSession(session)
    response = await house_vote_list_congress_session_async(
        client=resolved_client,
        congress=congress,
        session=session_param,
        format_=format_,
        offset=offset,
        limit=limit,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = HouseVotesModel.model_validate(api_envelope.data)
    result.client = resolved_client
    return result

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
async def members(
    self,
    *,
    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)."""
    validate_congress(congress)
    resolved_client = await AsyncApiService._resolve_client(self, client)
    session_param = GetHouseVoteCongressSessionVoteNumberMembersSession(session)
    response = await house_vote_members_detailed(
        client=resolved_client,
        congress=congress,
        session=session_param,
        vote_number=vote_number,
        format_=format_,
        offset=offset,
        limit=limit,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    payload = api_envelope.data if api_envelope.data is not None else response_json
    result = MemberVotesModel.model_validate(payload)
    result.client = resolved_client
    return result

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
def __init__(self, client: 'AuthenticatedClient | None' = None) -> None:
    """
    Initialize Member service.

    Args:
        client: Optional API client instance. Can also be provided per-method.
    """
    self.client = client
    self._last_result: 'MemberModel | None' = None  # Store last fetched member

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
async def get(
    self,
    *,
    client: 'AuthenticatedClient | None' = None,
    bioguide_id: str,
    format_: str | None = None
) -> 'MemberModel':
    """
    Get detailed information about a specific member from the API.

    Args:
        client: The API client instance. If None, will use self.client if available.
        bioguide_id: The member's Bioguide ID (e.g., "A000374").
        format_: Response format (default: json).

    Returns:
        Member: The member details with client attached.

    Raises:
        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()
    """
    # --- <VALIDATE PARAMETERS> ---
    validate_bioguide_id(bioguide_id)

    # --- <RESOLVE CLIENT> ---
    resolved_client = await AsyncApiService._resolve_client(self, client)
    resolved_format = resolve_response_format(format_, GetMemberFormat)

    # --- <MAKE API CALL> ---
    response = await member_details_async(
        client=resolved_client, bioguide_id=bioguide_id, format_=resolved_format
    )
    response_json = json.loads(response.content)

    # --- <VALIDATE AND PARSE RESPONSE> ---
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = MemberModel.model_validate(api_envelope.data)

    # --- <ATTACH CLIENT TO RESULT> ---
    # NOTE: This allows extension methods to access the client without explicitly passing it
    result.client = resolved_client

    # --- <STORE FOR POTENTIAL CONVENIENCE> ---
    self._last_result = result

    return result

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
async def search(
    self,
    *,
    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.

    Args:
        client: The API client instance. If None, will use self.client if available.
        congress: The Congress number (e.g., 117, 118). Optional.
        state: The state abbreviation (e.g., "CA", "NY"). Optional.
        district: The district number. Optional.
        format_: Response format (default: json).
        offset: Number of records to skip. Optional.
        limit: Maximum number of records to return. Optional.
        from_date_time: Return members updated after this datetime (ISO format). Optional.
        to_date_time: Return members updated before this datetime (ISO format). Optional.
        current_member: Filter for current members ("true" or "false"). Optional.

    Returns:
        Members: 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")
    """
    return await self._fetch_members(
        client=client,
        congress=congress,
        state=state,
        district=district,
        format_=format_,
        offset=offset,
        limit=limit,
        from_date_time=from_date_time,
        to_date_time=to_date_time,
        current_member=current_member,
    )

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
async def list_by_congress(
    self,
    *,
    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).
    """
    validate_congress(congress)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    if not fetch_all:
        return await self._list_by_congress_page(
            client=resolved_client,
            congress=congress,
            format_=format_,
            offset=offset,
            limit=limit,
            current_member=current_member,
        )

    page_size = limit if limit is not None else MAX_PAGINATION_LIMIT
    return await paginate_members_async(
        lambda off, lim: self._list_by_congress_page(
            client=resolved_client,
            congress=congress,
            format_=format_,
            offset=off,
            limit=lim,
            current_member=current_member,
        ),
        page_size=page_size,
    )

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
async def get_current_roster(
    self,
    *,
    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.

    Args:
        client: The API client instance. If None, will use self.client if available.

    Returns:
        dict: 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)}")
    """
    # --- <RESOLVE CLIENT> ---
    resolved_client = await AsyncApiService._resolve_client(self, client)

    house_members = []
    senate_members = []

    # --- <COLLECT ALL CURRENT MEMBERS> ---
    # NOTE: Paginate to completion (like list_by_congress(fetch_all=True))
    # instead of hard-capping at a fixed number of pages.
    all_members = await paginate_members_async(
        lambda off, lim: self._fetch_members(
            client=resolved_client,
            current_member="true",
            offset=off,
            limit=lim,
        ),
        page_size=MAX_PAGINATION_LIMIT,
    )
    member_list = all_members.members or []

    # --- <SEPARATE BY CHAMBER> ---
    for member in member_list:
        # Handle possible edge cases if terms or terms.item is missing
        if not member.terms or not getattr(member.terms, "item", None):
            continue

        # Defensive: handle if item is not a list
        terms_items = getattr(member.terms, "item", [])
        if not isinstance(terms_items, list):
            terms_items = [terms_items] if terms_items is not None else []
        if not terms_items:
            continue

        # Get latest term by startYear (fall back to -inf if not present)
        latest_term = max(terms_items, key=lambda t: getattr(t, "startYear", float('-inf')) or float('-inf'))
        chamber = getattr(latest_term, "chamber", None)

        if chamber == "House of Representatives":
            house_members.append(member)
        elif chamber == "Senate":
            senate_members.append(member)
        # If chamber is something else or None, skip

    # --- <RETURN SEPARATED ROSTERS> ---
    house = MembersModel.model_validate(dict(members=house_members))
    senate = MembersModel.model_validate(dict(members=senate_members))
    house.client = resolved_client
    senate.client = resolved_client
    propagate_client_to_items(house, "members", resolved_client)
    propagate_client_to_items(senate, "members", resolved_client)
    return dict(house_members=house, senate_members=senate)

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    nomination_number: int,
    format_: str = None
) -> NominationModel:
    """Get detailed information about a specific nomination."""
    resolved_client = await AsyncApiService._resolve_client(self, client)

    response = await nomination_detail_async(
        client=resolved_client, 
        congress=congress, 
        nomination_number=nomination_number,
        format_=format_
    )
    response_json = json.loads(response.content)

    api_envelope = ApiEnvelope.model_validate(response_json)
    result = NominationModel.model_validate(api_envelope.data)

    result.client = resolved_client
    self._last_result = result

    return result

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
async def get_nominees(
    self,
    *,
    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."""
    validate_congress(congress)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await nominees_async(
        client=resolved_client,
        congress=congress,
        nomination_number=nomination_number,
        ordinal=ordinal,
        format_=format_,
        offset=offset,
        limit=limit,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    payload = api_envelope.data if api_envelope.data is not None else response_json
    result = NomineesModel.model_validate(payload)
    result.client = resolved_client
    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'nomination',
        self,
        client=client,
        congress=congress,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client
    self._last_result = None

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
async def get(
    self,
    *,
    client: AuthenticatedClient | None = None,
    congress: int,
    communication_type: str,
    communication_number: int,
    format_: str = None
) -> SenateCommunicationModel:
    """Get detailed information about a specific Senate communication."""
    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await senate_communication_detail_async(
        client=resolved_client,
        congress=congress,
        communication_type=communication_type,
        communication_number=communication_number,
        format_=format_
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = SenateCommunicationModel.model_validate(api_envelope.data)
    result.client = resolved_client
    self._last_result = result
    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'senate-communication',
        self,
        client=client,
        congress=congress,
        communication_type=communication_type,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: AuthenticatedClient | None = None):
    self.client = client

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
async def search(
    self,
    *,
    client: AuthenticatedClient | None = None,
    format_: str = None,
    offset: int = None,
    limit: int = None
) -> SummariesModel:
    """Search for bill summaries using the universal search system."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'summary',
        self,
        client=client,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
def __init__(self, client: "AuthenticatedClient | None" = None) -> None:
    self.client = client
    self._last_result: TreatyModel | None = None

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
async def get(
    self,
    *,
    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:
        ClientNotFoundError: If no API client is available.
    """
    resolved_client = await AsyncApiService._resolve_client(self, client)

    if treaty_suffix:
        response = await treaty_details_async(
            client=resolved_client,
            congress=congress,
            treaty_number=treaty_number,
            treaty_suffix=treaty_suffix,
            format_=format_,
        )
    else:
        response = await treaty_detail_async(
            client=resolved_client,
            congress=congress,
            treaty_number=treaty_number,
            format_=format_,
        )
    response_json = json.loads(response.content)

    api_envelope = ApiEnvelope.model_validate(response_json)
    result = TreatyModel.model_validate(api_envelope.data)

    result.client = resolved_client
    self._last_result = result

    return result

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
async def search(
    self,
    *,
    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."""
    from congressgov.services.core.search import search_async as universal_search

    return await universal_search(
        'treaty',
        self,
        client=client,
        congress=congress,
        format_=format_,
        offset=offset,
        limit=limit
    )

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
async def get_actions(
    self,
    *,
    client: "AuthenticatedClient | None" = None,
    congress: int,
    treaty_number: int,
    format_: str | None = None,
) -> ActionsModel:
    """Return actions for a treaty."""
    validate_congress(congress)

    resolved_client = await AsyncApiService._resolve_client(self, client)
    response = await treaty_actions_async(
        client=resolved_client,
        congress=congress,
        treaty_number=treaty_number,
        format_=format_,
    )
    response_json = json.loads(response.content)
    api_envelope = ApiEnvelope.model_validate(response_json)
    result = ActionsModel.model_validate(api_envelope.data)
    result.client = resolved_client
    return result