Skip to main content

Timbr REST API Connector

This sample is of a pure Python connector to Timbr without any dependencies required.

Dependencies

  • Access to a Timbr Server service
  • Python version 3.9.13 or newer

Installation

Sample usage

  • For an example of how to use the REST API connector for Timbr, follow this Example file

Connection parameters examples

Generic example and explanation for each parameter

  pytimbr_api.run_query(
url = "<TIMBR_URL>",
ontology = "<ONTOLOGY_NAME>",
token = "<USER_TOKEN>",
query = "<TIMBR_QUERY>",
datasource = "<DATASOURCE_NAME>",
nested = "<true/false>",
verify_ssl = <True/False>,
enable_IPv6 = <True/False>,
)

# url - Required - String - The IP / Hostname of the Timbr platform.
# ontology - Required - String - The ontology / knowledge graph to connect to.
# token - Required - String - Timbr token value or JWT token value. Note: If you are using JWT token, you need to set the is_jwt parameter to True.
# query - Required - String - The query that you want to execute.
# datasource - Optional - String - Add the specific datasource name that you want to query from, the default value is the current active datasource of your ontology.
# nested - Optional - String - Change to 'true' if nested flag needs to be enabled. make sure this flag contains string value not bool value.
# verify_ssl - Optional - Boolean - Verifying the target server's SSL Certificate, use False to disable this process.
# enable_IPv6 - Optional - Boolean - Change to 'true' if you are using IPv6 connection.
# is_jwt - Optional - Boolean - Set to True if you are using JWT token, otherwise set to False.
# jwt_tenant_id - Optional - String - The tenant ID for JWT authentication

Using Timbr Token

HTTP Example

  pytimbr_api.run_query(
url = "http://mytimbrenv.com:11000",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = False,
enable_IPv6 = False,
)

HTTPS Example

  pytimbr_api.run_query(
url = "https://mytimbrenv.com:443",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = True,
enable_IPv6 = False,
)

Using JWT

HTTP Example

  pytimbr_api.run_query(
url = "http://mytimbrenv.com:11000",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = False,
enable_IPv6 = False,
is_jwt = True,
jwt_tenant_id = "my_tenant_id",
)

HTTPS Example

  pytimbr_api.run_query(
url = "https://mytimbrenv.com:11000",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = True,
enable_IPv6 = False,
is_jwt = True,
jwt_tenant_id = "my_tenant_id",
)

Execute Query Examples

Using Timbr Token

HTTP Connection

  response = pytimbr_api.run_query(
url = "http://mytimbrenv.com:11000",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = False,
enable_IPv6 = False,
)
print(response)

HTTPS Connection

  response = pytimbr_api.run_query(
url = "https://mytimbrenv.com:443",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = True,
enable_IPv6 = False,
)
print(response)

Using JWT

HTTP Example

  response = pytimbr_api.run_query(
url = "http://mytimbrenv.com:11000",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = False,
enable_IPv6 = False,
is_jwt = True,
jwt_tenant_id = "my_tenant_id",
)
print(response)

HTTPS Example

  response = pytimbr_api.run_query(
url = "https://mytimbrenv.com:11000",
ontology = "my_ontology",
token = "tk_mytimbrtoken",
query = "SELECT * FROM timbr.sys_concepts",
datasource = "my_datasource",
nested = "false",
verify_ssl = True,
enable_IPv6 = False,
is_jwt = True,
jwt_tenant_id = "my_tenant_id",
)
print(response)