From c631467dd272c73d193f0236bd19b2d2a14d29d6 Mon Sep 17 00:00:00 2001 From: Ebru Yucesar Date: Mon, 30 Sep 2024 15:05:00 -0400 Subject: [PATCH] switch to using cl api v4 --- web/config/settings/settings_base.py | 1 + web/main/legal_document_sources.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/web/config/settings/settings_base.py b/web/config/settings/settings_base.py index 83d371a0c..e15db98af 100644 --- a/web/config/settings/settings_base.py +++ b/web/config/settings/settings_base.py @@ -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" diff --git a/web/main/legal_document_sources.py b/web/main/legal_document_sources.py index 2ef11c84c..863e506b7 100644 --- a/web/main/legal_document_sources.py +++ b/web/main/legal_document_sources.py @@ -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": [], } @@ -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}"}, ) @@ -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() @@ -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}"}, ) @@ -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}"}, )