-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_citation_lookup.py
More file actions
63 lines (53 loc) · 2.03 KB
/
test_citation_lookup.py
File metadata and controls
63 lines (53 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
import requests
import os
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv('COURTLISTENER_API_KEY')
def test_citation_endpoints():
headers = {'Authorization': f'Token {api_key}'}
# Test 1: Try the citations endpoint directly
print("=== Testing Citations Endpoint ===")
url = 'https://www.courtlistener.com/api/rest/v4/citations/'
params = {
'volume': '410',
'reporter': 'US',
'page': '113'
}
response = requests.get(url, params=params, headers=headers)
print(f'Status: {response.status_code}')
print(f'URL: {response.url}')
if response.status_code == 200:
data = response.json()
print(f'Count: {data.get("count", 0)}')
for result in data.get('results', [])[:3]:
print(f'Citation ID: {result.get("id")}')
print(f'Citation: {result.get("volume")} {result.get("reporter")} {result.get("page")}')
print(f'Cluster: {result.get("cluster")}')
print()
else:
print(f"Error: {response.text}")
# Test 2: Try clusters endpoint
print("=== Testing Clusters Endpoint ===")
url = 'https://www.courtlistener.com/api/rest/v4/clusters/'
params = {
'citation__volume': '410',
'citation__reporter': 'US',
'citation__page': '113'
}
response = requests.get(url, params=params, headers=headers)
print(f'Status: {response.status_code}')
print(f'URL: {response.url}')
if response.status_code == 200:
data = response.json()
print(f'Count: {data.get("count", 0)}')
for result in data.get('results', [])[:3]:
print(f'Case: {result.get("case_name", "N/A")}')
print(f'Court: {result.get("docket", {}).get("court", "N/A")}')
print(f'Date: {result.get("date_filed", "N/A")}')
print(f'Citations: {result.get("citations", [])}')
print()
else:
print(f"Error: {response.text}")
if __name__ == "__main__":
test_citation_endpoints()