freelawproject / courtlistener

A fully-searchable and accessible archive of court data including growing repositories of opinions, oral arguments, judges, judicial financial records, and federal filings.
https://www.courtlistener.com
Other
550 stars 151 forks source link

feat(api): Add 'count' parameter to return total item count in API v4 #4715

Open elisa-a-v opened 1 day ago

elisa-a-v commented 1 day ago

Resolves #4506

This PR introduces a new count=on query parameter to our paginated API endpoints. When this parameter is included in a request, the API returns only the total count of items matching the query filters, without including any result data.

If no count=on is added to the request, a count key is now included in the response just like in v3, but instead of providing the count immediately, it provides a URL that points to the count endpoint for the current query parameters to guide users on how to obtain the total count if needed.

V4 removed the count due to the overhead of counting huge querysets in each request, which is why we're adding this tweaked version of the count in the response so the users have access to the information if needed without reintroducing the overhead.

Also updated docs to reflect these changes: image

mlissner commented 1 day ago

Process notes:

Thank you!