This is a simple command line interface client and associated Python library to access the Translator Knowledge Beacon Aggregator ("KBA") web service.
KBA provides integrated access to a pool of Translator Knowledge Beacon API wrapped knowledge sources publishing concepts and relationship statements. KBA is similar to that of the latter mentioned API with the addition of some extra informative endpoints plus session identifier and beacon indices. These latter identifiers are locally assigned numeric indices provided to track the use of specific registered beacons within the aggregator API itself. Most of the endpoints of the KBA API are designed for asynchronous management of long running queries.
This Python package is automatically generated by the Swagger Codegen project:
- API version: 1.1.3
- Package version: 1.0.0
- Build package: io.swagger.codegen.languages.PythonClientCodegen
Python 2.7 and 3.5+
You can install from PyPI:
python3 -m pip install kba
Then import the package:
import kba
This package comes with a CLI that can be used to query the Beacon Aggregator. The --help
flag can be used with any command to see documentation.
$ kba --help
Usage: kba [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
beacons Retrieves all beacons
categories Retrieves all categories
concept Initiates a concept query with the given search parameters
dump Retrieves the results of a query (by default the last query)
kmap Retrieves the knowledge map
ping Retrieves the status of a query (by default the last query)
predicates Retrieves all predicates
statement Initiates a statement query with the given search parameters
Initiate a concept query:
$ kba concept --keywords caffeine --categories "chemical substance" --categories pathway
Query ID: eyUiFRZWVN5dD01VMQS1
Get the status of the last query posted:
$ kba ping
Last query: eyUiFRZWVN5dD01VMQS1
Beacon 1 finished with 0 records
Beacon 2 finished with 204 records
Beacon 3 finished with 15 records
Beacon 4 has not yet returned
Beacon 5 finished with 43 records
Beacon 6 has not yet returned
Beacon 7 has not yet returned
Beacon 8 finished with 9 records
Get pages of records from the last query, saving it to file:
$ kba dump --page 1 --size 500 --out caffeine.json
Last query: eyUiFRZWVN5dD01VMQS1
Saved response to caffeine.json
Please follow the installation procedure and then run the following:
from __future__ import print_function
import time
import kba
from kba.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = kba.ConceptsApi()
query_id = 'query_id_example' # str | the query identifier of a concepts query previously posted by the /cliques endpoint
try:
api_response = api_instance.get_cliques(query_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling ConceptsApi->get_cliques: %s\n" % e)
All URIs are relative to https://kba.ncats.io
Class | Method | HTTP request | Description |
---|---|---|---|
ConceptsApi | get_cliques | GET /cliques/data/{queryId} | |
ConceptsApi | get_cliques_query_status | GET /cliques/status/{queryId} | |
ConceptsApi | get_concept_details | GET /concepts/details/{cliqueId} | |
ConceptsApi | get_concepts | GET /concepts/data/{queryId} | |
ConceptsApi | get_concepts_query_status | GET /concepts/status/{queryId} | |
ConceptsApi | post_cliques_query | POST /cliques | |
ConceptsApi | post_concepts_query | POST /concepts | |
MetadataApi | get_beacons | GET /beacons | |
MetadataApi | get_concept_categories | GET /categories | |
MetadataApi | get_error_log | GET /errorlog | |
MetadataApi | get_knowledge_map | GET /kmap | |
MetadataApi | get_predicates | GET /predicates | |
StatementsApi | get_statement_details | GET /statements/details/{statementId} | |
StatementsApi | get_statements | GET /statements/data/{queryId} | |
StatementsApi | get_statements_query_status | GET /statements/status/{queryId} | |
StatementsApi | post_statements_query | POST /statements |
- ServerBeaconConceptCategory
- ServerBeaconPredicate
- ServerClique
- ServerCliquesQuery
- ServerCliquesQueryBeaconStatus
- ServerCliquesQueryResult
- ServerCliquesQueryStatus
- ServerConcept
- ServerConceptCategoriesByBeacon
- ServerConceptCategory
- ServerConceptDetail
- ServerConceptWithDetails
- ServerConceptWithDetailsBeaconEntry
- ServerConceptsQuery
- ServerConceptsQueryBeaconStatus
- ServerConceptsQueryResult
- ServerConceptsQueryStatus
- ServerKnowledgeBeacon
- ServerKnowledgeMap
- ServerKnowledgeMapObject
- ServerKnowledgeMapPredicate
- ServerKnowledgeMapStatement
- ServerKnowledgeMapSubject
- ServerLogEntry
- ServerPredicate
- ServerPredicatesByBeacon
- ServerStatement
- ServerStatementAnnotation
- ServerStatementCitation
- ServerStatementDetails
- ServerStatementObject
- ServerStatementPredicate
- ServerStatementSubject
- ServerStatementsQuery
- ServerStatementsQueryBeaconStatus
- ServerStatementsQueryResult
- ServerStatementsQueryStatus
All endpoints do not require authorization.