Py-TwelveLabs
Copyright © 2024 Minura Punchihewa
Py-TwelveLabs is a Python library for interacting with the TwelveLabs API.
Installation
With pip
pip install py_twelvelabs
Usage
First, sign up for a TwelveLabs account here and get your API key.
The API key can either be passed to the constructor directly or through the environment variable TWELVE_LABS_API_KEY like so:
export TWELVE_LABS_API_KEY=tlk_...
Then, import the library and create a client object:
from py_twelvelabs import TwelveLabsAPIClient
client = TwelveLabsAPIClient()
# OR
client = TwelveLabsAPIClient(api_key='tlk_...')
Indexes
Create an Index
index_id = client.index.create(
index_name='my_index',
index_options=["visual", "conversation", "text_in_video", "logo"]
)
Get an Index
index = client.index.get(index_id)
index will be an instance of the Index class.
List Indexes
indexes = client.index.list()
indexes will be a list of Index objects.
Update an Index
client.index.update(
index_id=index_id,
index_name='my_index_updated'
)
Delete an Index
client.index.delete(index_id)
Tasks
Create a Video Indexing Task
Create a task asynchronously:
task_id = client.task.create_async(
index_id=index_id,
video_file='path/to/my/video.mp4'
)
task_id will be a string representing the ID of the task.
Create a task synchronously:
task = client.task.create_sync(
index_id=index_id,
video_file='path/to/my/video.mp4'
)
task will be an instance of the Task class.
Get a Video Indexing Task
task = client.task.get(task_id)
task will be an instance of the Task class.
List Video Indexing Tasks
tasks = client.task.list()
tasks will be a list of Task objects.
Delete a Video Indexing Task
client.task.delete(task_id)
Search
Run a Search Query
results = client.search.query(
index_id=index_id,
query='my search query',
search_options=["visual", "conversation", "text_in_video", "logo"]
)
Release files for py-twelvelabs 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_twelvelabs-0.1.0.tar.gz | 20.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_twelvelabs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.2 kB
Release files / py_twelvelabs-0.1.0.tar.gz
| Download URL | py_twelvelabs-0.1.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dffe10ad1758fd886b9df97c84254ebf03dc736c84edcfc6deda60ee072c89f5
|
|
BLAKE2b-256 checksum How to use checksums |
7944efc00b971b70d346196d51434a849059face2bb24bd109d904e4191c7cca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.4 Linux/6.2.0-39-generic
|
Release files / py_twelvelabs-0.1.0-py3-none-any.whl
| Download URL | py_twelvelabs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0575a5cca3520499416040018d40622b1702ce585ceac627e5cf3538cc448b01
|
|
BLAKE2b-256 checksum How to use checksums |
a29c114da47f520f30c4492eae8a46fe01fde4aa96047c83c7b5099a5ed04b2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.4 Linux/6.2.0-39-generic
|