Skip to content

[Py client] Implement Client.opportunities.search() #386

@widal001

Description

@widal001

Summary

Expand the Client to also support a Client.opportunities.search() method which makes calls to the POST /common-grants/opportunities/search/ endpoint. The first iteration can support only default fields and filters.

Acceptance criteria

  • SDK users can search opportunities with the following code:
from commongrants.client import Client, Auth
from commongrants.schemas.pydantic import Opportunity

client = Client(
    base_url="https://api.example.org",
    auth=Auth.bearer("YOUR_TOKEN"),
    timeout=10,         # seconds
)

# List opportunities with transparent pagination and typed results
# If `total=` exceeds max batch size (100) then paginate the results
for opp in client.opportunities.search(q="Education", status="open", paginate=True):
    print(opp.id, opp.title)

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions