Repository navigation
Expand file tree
/
Copy pathquery_paper_info.py
More file actions
55 lines (43 loc) · 2.25 KB
/
Copy pathquery_paper_info.py
File metadata and controls
55 lines (43 loc) · 2.25 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
"""Example: query a single paper from the Parallel ArXiv API.
Usage:
python paper_python.py # uses default PX ID
python paper_python.py 2604.00003 # specify a PX ID
Requires: pip install httpx
"""
import sys
import httpx
API = "https://parallel-science-api-689836870161.us-central1.run.app/api/v1"
# Uncomment the line below to use a local server instead of the remote API
#API="http://localhost:8080/api/v1"
def main():
px_id = sys.argv[1] if len(sys.argv) > 1 else "2604.00017"
# ── Paper details ───────────────────────────────────────────────────
paper = httpx.get(f"{API}/papers/{px_id}").json()
print(f"Paper: PX:{px_id}")
print(f"Title: {paper['title']}")
print(f"Author: {paper['author']}")
print(f"Date: {paper['date']}")
print(f"Category: {paper['primary_category']}")
if paper["secondary_categories"]:
print(f"Also in: {', '.join(paper['secondary_categories'])}")
print(f"PDF: {paper['pdf_url']}")
print(f"Pages: {paper['pages_url']}")
print(f"GitHub: {paper['github_url']}")
print()
# ── Version history ─────────────────────────────────────────────────
versions = httpx.get(f"{API}/papers/{px_id}/versions").json()
print(f"Versions ({len(versions)} total):")
for v in versions:
tag = " <- current" if v["is_current"] else ""
print(f" v{v['version']} {v['date']} (scraped {v['scraped_at']}){tag}")
print()
# ── Specific version ────────────────────────────────────────────────
v1 = httpx.get(f"{API}/papers/{px_id}/versions/1").json()
print(f"Version 1 title: {v1['title']}")
print()
# ── BibTeX ──────────────────────────────────────────────────────────
bibtex = httpx.get(f"{API}/papers/{px_id}/bibtex").text
print("BibTeX:")
print(bibtex)
if __name__ == "__main__":
main()