-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_connection.py
More file actions
39 lines (30 loc) · 917 Bytes
/
test_connection.py
File metadata and controls
39 lines (30 loc) · 917 Bytes
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
"""Quick test of ADS API connection."""
import os
from dotenv import load_dotenv
import ads
load_dotenv()
# Test API token
token = os.getenv("ADS_API_TOKEN")
if not token:
print("❌ No ADS_API_TOKEN found in .env")
exit(1)
print(f"✓ Found API token: {token[:10]}...")
# Configure ADS
ads.config.token = token
# Test a simple search
print("\nTesting ADS search...")
try:
papers = ads.SearchQuery(
q="stellar populations",
fl=["bibcode", "title", "author", "year"],
rows=3
)
print("✓ Search successful! Found papers:")
for i, paper in enumerate(papers, 1):
print(f"\n{i}. {paper.title[0] if paper.title else 'No title'}")
print(f" Year: {paper.year}")
print(f" Bibcode: {paper.bibcode}")
print("\n✅ All tests passed! ADS API is working correctly.")
except Exception as e:
print(f"\n❌ Error: {e}")
exit(1)