Skip to content

Commit

Permalink
switch to using cl api v4
Browse files Browse the repository at this point in the history
  • Loading branch information
teovin committed Sep 30, 2024
1 parent d377650 commit c631467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions web/config/settings/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class LoggerConfig(TypedDict, total=False):
GPO_API_KEY = ""

COURTLISTENER_BASE_URL = "https://www.courtlistener.com"
COURTLISTENER_API_BASE_URL = "https://www.courtlistener.com/api/rest/v4/"
COURTLISTENER_API_KEY = ""

CRISPY_TEMPLATE_PACK = "bootstrap3"
Expand Down
10 changes: 5 additions & 5 deletions web/main/legal_document_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ class CourtListener:
"name": "CourtListener",
"short_description": "CourtListener contains millions of legal opinions.",
"long_description": "CourtListener searches millions of opinions across hundreds of jurisdictions.",
"link": settings.COURTLISTENER_BASE_URL,
"link": settings.COURTLISTENER_API_BASE_URL,
"search_regexes": [],
"footnote_regexes": [],
}
Expand All @@ -539,7 +539,7 @@ def search(search_params):
try:
params = CourtListener.get_search_params(search_params)
resp = requests.get(
f"{settings.COURTLISTENER_BASE_URL}/api/rest/v3/search",
f"{settings.COURTLISTENER_API_BASE_URL}search",
params,
headers={"Authorization": f"Token {settings.COURTLISTENER_API_KEY}"},
)
Expand Down Expand Up @@ -575,7 +575,7 @@ def pull(legal_doc_source, id):
raise APICommunicationError("A CourtListener API key is required")
try:
resp = requests.get(
f"{settings.COURTLISTENER_BASE_URL}/api/rest/v3/clusters/{id}/",
f"{settings.COURTLISTENER_API_BASE_URL}clusters/{id}/",
headers={"Authorization": f"Token {settings.COURTLISTENER_API_KEY}"},
)
resp.raise_for_status()
Expand Down Expand Up @@ -653,7 +653,7 @@ def header_template(legal_document):
def get_opinion_body(sub_opinion_url):
opinion_num = int(sub_opinion_url.split("/")[-2])
resp = requests.get(
f"{settings.COURTLISTENER_BASE_URL}/api/rest/v3/opinions/{opinion_num}/",
f"{settings.COURTLISTENER_API_BASE_URL}opinions/{opinion_num}/",
headers={"Authorization": f"Token {settings.COURTLISTENER_API_KEY}"},
)

Expand Down Expand Up @@ -701,7 +701,7 @@ def get_additional_cluster_metadata(cluster_id):
params = {"q": f"cluster_id:{cluster_id}"}

resp = requests.get(
f"{settings.COURTLISTENER_BASE_URL}/api/rest/v3/search",
f"{settings.COURTLISTENER_API_BASE_URL}search",
params,
headers={"Authorization": f"Token {settings.COURTLISTENER_API_KEY}"},
)
Expand Down

0 comments on commit c631467

Please sign in to comment.