The official python client for the connected papers API.
Project description
connectedpapers-py
The official python client for the connected papers API.
Installation
pip install connectedpapers-py
Usage
from connectedpapers import ConnectedPapersClient
DEEPFRUITS_PAPER_ID = "9397e7acd062245d37350f5c05faf56e9cfae0d6"
client = ConnectedPapersClient()
remaining_uses_count = client.get_remaining_usages_sync()
print(f"Remaining uses count: {remaining_uses_count}")
free_access_papers = client.get_free_access_papers_sync()
print(f"Free access papers: {free_access_papers}")
graph = client.get_graph_sync(DEEPFRUITS_PAPER_ID)
assert graph.graph_json.start_id == DEEPFRUITS_PAPER_ID
See more on the usage samples directory.
See graph structure at graph.py.
Configuring server address and API key
There are multiple ways to configure the server address and API key:
- Set the environment variables
CONNECTED_PAPERS_SERVER_ADDRESS
andCONNECTED_PAPERS_API_KEY
:export CONNECTED_PAPERS_REST_API="https://api.connectedpapers.com" export CONNECTED_PAPERS_API_KEY="YOUR_API_KEY"
(You do not need to configure the server address, uses the correct one by default). Then you can use the client without parameters:from connectedpapers import ConnectedPapersClient client = ConnectedPapersClient()
- Send parameters to the client's constructur:
from connectedpapers import ConnectedPapersClient client = ConnectedPapersClient(access_token="YOUR_API_KEY", server_addr="https://api.connectedpapers.com")
API
Most functions offer a synchronous and an asynchronous version.
API structure
We have the following API calls available:
- Fetching a graph
- Getting the remaining usages count for your API key
- Getting the list of papers that are free to access
Free re-access to papers
If you have fetched a paper, it remains free to access for a month after the first access without counting towards your usages count.
Synchronous API
from connectedpapers import ConnectedPapersClient
client = ConnectedPapersClient()
client.get_graph_sync("YOUR_PAPER_ID") # Fetch a graph for a single paper
client.get_remaining_usages_sync() # Get the remaining usages count for your API key
client.get_free_access_papers_sync() # Get the list of papers that are free to access
Asynchronous API
from connectedpapers import ConnectedPapersClient
client = ConnectedPapersClient()
async def usage_sample() -> None:
await client.get_graph_async("YOUR_PAPER_ID") # Fetch a graph for a single paper
await client.get_remaining_usages_async() # Get the remaining usages count for your API key
await client.get_free_access_papers_async() # Get the list of papers that are free to access
usage_sample()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for connectedpapers_py-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf8eaf61178d17b00f28be878732e7857a0763345e06b101c3f77f0c3f782881 |
|
MD5 | 8639868de2fec333c89151a98312d653 |
|
BLAKE2b-256 | 536be77009646c0d2fa250c9b2794337c5393840e3e1b2a236410f17ca9555f0 |