Api references
pymedx
PyMedX package.
Classes
PubMed
Wrap around the PubMed API.
Functions
__init__(tool='my_tool', email='my_email@example.com', api_key='')
Initialize the PubMed object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool |
str
|
name of the tool that is executing the query. This parameter is not required but kindly requested by PMC (PubMed Central). |
'my_tool'
|
email |
str
|
email of the user of the tool. This parameter is not required but kindly requested by PMC (PubMed Central). |
'my_email@example.com'
|
api_key |
str
|
the NCBI API KEY |
''
|
Returns:
Type | Description |
---|---|
None
|
|
_exceededRateLimit()
Check if we've exceeded the rate limit.
Returns:
Name | Type | Description |
---|---|---|
exceeded |
Bool
|
Whether or not the rate limit is exceeded. |
_get(url, parameters=dict(), output='json')
Make a request to PubMed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
last part of the URL that is requested (will be combined with the base url) |
required |
parameters |
dict[Any, Any]
|
parameters to use for the request |
dict()
|
output |
str
|
type of output that is requested (defaults to JSON but can be used to retrieve XML) |
'json'
|
Returns:
Type | Description |
---|---|
- response Dict / str, if the response is valid JSON it will
|
be parsed before returning, otherwise a string is returend |
_getArticleIds(query, max_results)
_getArticles(article_ids)
Batch a list of article IDs and retrieves the content.
Returns:
Type | Description |
---|---|
- articles List, article objects.
|
|
_wait_to_retry(attempt)
Calculate and wait the appropriate amount of time before a retry.
Parameters.
getTotalResultsCount(query)
Return the total number of results that match the query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
the query to send to PubMed |
required |
Returns:
Name | Type | Description |
---|---|---|
total_results_count |
Int
|
total number of results for the query in PubMed |
query(query, max_results=100)
Execute a query agains the GraphQL schema.
Automatically inserting the PubMed data loader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
the GraphQL query to execute against the schema. |
required |
Returns:
Name | Type | Description |
---|---|---|
result |
ExecutionResult
|
GraphQL object that contains the result in the "data" attribute. |
PubMedCentral
Bases: PubMed
Warp around the PubMedCentral API.
Functions
__init__(tool='my_tool', email='my_email@example.com', api_key='')
Initialize the PubMedCentral object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool |
str
|
name of the tool that is executing the query. This parameter is not required but kindly requested by PMC (PubMed Central). |
'my_tool'
|
email |
str
|
email of the user of the tool. This parameter is not required but kindly requested by PMC (PubMed Central). |
'my_email@example.com'
|
api_key |
str
|
the NCBI API KEY |
''
|
Returns:
Type | Description |
---|---|
None
|
|
_getArticleIds(query, max_results)
_getArticles(article_ids)
Batch a list of article IDs and retrieves the content.
Returns:
Type | Description |
---|---|
- articles List, article objects.
|
|
query(query, max_results=100)
Execute a query agains the GraphQL schema.
Automatically inserting the PubMed data loader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
the GraphQL query to execute against the schema. |
required |
Returns:
Name | Type | Description |
---|---|---|
result |
ExecutionResult
|
GraphQL object that contains the result in the "data" attribute. |
Functions
get_version()
Return the program version.