Skip to main content

Python SDK

Overview

The Anansi Python SDK offers a convenient interface for interacting with Anansi, a visual data lineage tool. With this SDK, users can easily post and retrieve data from Anansi using Python. The documentation includes API endpoints for posting and fetching data from Anansi.

Installation

To install the Python SDK for Anansi, execute the following pip command

pip install anansi-sdk

Example Usage

1. Post Data to Anansi

To post data to Anansi, follow these steps:

  1. Import Modules - Import the necessary modules and classes from the Anansi SDK
import anansi_sdk
from anansi_sdk.rest import ApiException
  1. Configure API Key - Set up API key authorization.
# Configure API key **authorization: JWT
configuration = anansi_sdk.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
configuration.api_key_prefix['Authorization'] = 'Bearer'
configuration.host='YOUR_API_CLIENT'
  • Replace 'YOUR_API_Key' with your API key.
  • Replace "YOUR_API_CLIENT" with the appropriate value for your API client
  1. Creating an Instance - Initialize an instance of the API class.
api_instance = anansi_sdk.DefaultApi(anansi_sdk.ApiClient(configuration))
  1. Prepare Data - Define the table name and the data to be posted.
table_name = 'table_name_example' # str | Also can be called Node Name interchangeably.
body = [
{
"System ID": "123",
"System Name": "Test",
"System Description": "System Desc",
"Issue Status": "null",
"System Type": "Context"
}
]

Replace 'table_name_example' with the name of the table where data is to be posted. In this example table, we have columns such as System ID, System Name, System Description, Issue Status, and System Type.

  1. Post Data - Use the post_api_catalog_table_name method to post data to the specified table.
try:
# Create New Entries in the Table
api_instance.post_api_catalog_table_name(table_name, body=body)
except ApiException as e:
print("Exception when calling DefaultApi->post_api_catalog_table_name: %s\n" % e)

The process involves writing to Anansi through an API call to the post_api_catalog_table_name() function, passing parameters such as table_name and body to create new entries in the designated table.