This article will help you get started with building a data connector using Python to ingest data on your Curiosity instance.
To get started, you will need a few things:
Python 3.8 or newer installed on your machine
An IDE or Editor of your choice to help you write Python code
Create a Library Token
To get started, open the Data Sources Hub on your Curiosity instance:
Then select the External Connectors option on the list of available data connectors:
To create an API token, click on the Create API Token button:
Give the token a name:
And save the created API token:
Note: Remember this token gives access to all data on your system with the same access as a system administrator. Keep it secure!
Setup a Python project
After installing Python 3.8 or newer, head over to the command line and install the Curiosity Python library. Depending on your Python setup, you might need to run one of the following commands:
pip install curiosity
pip3 install curiosity
python3.8 -m pip install curiosity
The python library makes it easy to connect to your Curiosity application. Here is an example of a simple data-connector that uploads a single file using the Python API:
from curiosity import Graph
# The url to you curiosity instance
server = "http://localhost:8080/api"
# The library token you just created
lib_token = "eqJHbGci..."
# A descriptive name of your data connector
# This name identifies the connector in the curiosity instance
connector_name = "Python data connector"
with Graph.connect(server, lib_token, connector_name) as graph:
# The graph objects provides plenty of methods to interact with your
# Curiosity instance. E.g. a file can be uploaded like this:
fullpath = "./sample.pdf"
filename = "sample.pdf"
source = "Sample Files"
graph.upload_file_by_path(fullpath, filename, source)
if __name__ == '__main__':
The initial setup of a data connector using Python is now done. You can check here for all available methods provided by the graph object to interact with your Curiosity application.