Skip to content

Commit

Permalink
Merge pull request #4700 from freelawproject/api-docket-entry-ordering
Browse files Browse the repository at this point in the history
feat(api): Enable ordering docket entries by recap_sequence_number and entry_number
  • Loading branch information
mlissner authored Nov 18, 2024
2 parents 1f1fbc8 + e248606 commit cb3d8c4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cl/api/templates/pacer-api-docs-vlatest.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ <h3 id="docket-entry-endpoint">Docket Entries <small> — <code>{% url "docketen
"{% get_full_host %}{% url "docketentry-list" version=version %}?docket=4214664"</pre>
<p>Such a request will return up to 20 docket entries per page. Each docket entry returned can contain a number of nested documents in the <code>recap_document</code> key, including their full extracted text (see details in the next section below). As a result, this response can be quite large.
</p>
<p>You can also order the results using specific fields. To order results, use the <code>order_by</code> query parameter. For example, to order docket entries by their filing date in ascending order:
</p>
<pre class="pre-scrollable">curl -v \
--header 'Authorization: Token {% if user.is_authenticated %}{{ user.auth_token }}{% else %}&lt;your-token-here&gt;{% endif %}' \
"{% get_full_host %}{% url "docketentry-list" version=version %}?order_by=date_filed"</pre>
<p>To order in descending order, prepend a <code>-</code> to the field name. For example, <code>?order_by=-date_filed</code> will order by filing date in descending order.
</p>
<p>The following fields can be used for ordering:</p>
<ul>
<li><code>id</code></li>
<li><code>date_created</code></li>
<li><code>date_modified</code></li>
<li><code>date_filed</code></li>
<li><code>recap_sequence_number</code></li>
<li><code>entry_number</code></li>
</ul>
<p>To order using multiple fields simultaneously, separate the field names with commas. For example, <code>?order_by=recap_sequence_number,entry_number</code> will use the default website order for Docket Entries.</p>
<p>A few field-level notes:</p>
<table class="table">
<thead>
Expand Down
9 changes: 8 additions & 1 deletion cl/search/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ class DocketEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
permission_classes = (RECAPUsersReadOnly, V3APIPermission)
serializer_class = DocketEntrySerializer
filterset_class = DocketEntryFilter
ordering_fields = ("id", "date_created", "date_modified", "date_filed")
ordering_fields = (
"id",
"date_created",
"date_modified",
"date_filed",
"recap_sequence_number",
"entry_number",
)
# Default cursor ordering key
ordering = "-id"
# Additional cursor ordering fields
Expand Down

0 comments on commit cb3d8c4

Please sign in to comment.