On this page, we will walk through the process of creating a Python application that uses the OSDK. The example below can be used with many Python frameworks, such as Flask©, Streamlit©, and Jupyter™ (external links).
Follow the steps listed in the create a new Developer Console application page.
Export your token in your local environment. Below is an example using a sample personal access token, but you can generate a longer-lived one in the Developer Console. This token should not be checked into source control because it is your personal access token.
Copied!1export FOUNDRY_TOKEN=<YOUR-TOKEN-FROM-GETTING-STARTED-PAGE>
The Python SDK requires a Python version between 3.9 and 3.11. To check what version of Python you are using, enter the command below:
Copied!1python3 --version
If your organization requires certificates for network traffic, you may need to tell Python where that certificate lives.
Copied!1export SSL_CERT_FILE="/path/to/my.crt" 2export REQUESTS_CA_BUNDLE="/path/to/my.crt"
Run the following command to install the latest version of the SDK, replacing any < >
with your application-specific value that can be found on your application Overview page.
Copied!1pip install <YOUR-PACKAGE-NAME> --upgrade --extra-index-url "https://:$FOUNDRY_TOKEN@<INDEX-URL>"
In your application, initialize the Foundry client and start developing.
Copied!1import os 2from <PACKAGE-NAME> import FoundryClient 3from <PACKAGE-NAME>.core.api import UserTokenAuth 4 5auth = UserTokenAuth(hostname="<YOUR-FOUNDRY-URL>", token=os.environ["FOUNDRY_TOKEN"]) 6 7client = FoundryClient(auth=auth, hostname="<YOUR-FOUNDRY-URL>") 8 9object = client.ontology.objects.<ANY-OBJECT> 10print(object.take(1))