Client library for integration with datagrok API
Project description
Datagrok python client library
This library can be used for integration with datagrok. It is a python wrapper for public API, that has OpenAPI specification available here.
Refer to Help for more information.
Installation
To install package, use pip.
pip install datagrok-api
Usage
Initialization
To use the API client, import DatagrokClient. It is recommended to use it as a context manager to ensure proper connection handling:
from datagrok_api import DatagrokClient
# Initialize with your server URL and API token
with DatagrokClient("https://public.datagrok.ai/api", "Bearer <your-token>") as grok:
me = grok.users.current()
print(f"Logged in as: {me.first_name} {me.last_name}")
Working with Data (Tables & Files)
The package uses Pandas for representation of tables and dataframes.
import pandas as pd
from sklearn.datasets import load_iris
# Upload a DataFrame as a table
iris_df = pd.DataFrame(load_iris()['data'])
iris_id = grok.tables.upload('iris', iris_df)['ID']
# Download a table by ID or Name
df = grok.tables.download(iris_id)
print(df.head())
# Upload a local file
uploaded_file = grok.files.upload("data.csv")
Functions & Connections
You can call server-side functions and manage data connections directly through their respective managers.
from datagrok_api.models import DataConnection, FileDataSourceType, Credentials
# Call a Datagrok function
result = grok.functions.call("JohnDoe:MyFunction", {"a": 1, "b": 2})
# Create and save a connection (e.g., S3)
creds = Credentials(accessKey="aws-key", secretKey="aws-secret")
conn = DataConnection(
name="My S3 Bucket",
data_source=FileDataSourceType.S3,
bucket="my-bucket",
region="us-east-1",
credentials=creds
)
saved_conn = grok.connections.save(conn)
Group Management
Manage user groups and metadata.
# Search for a group and update its properties
groups = grok.groups.find("Chemists")
if groups:
group = groups[0]
group.description = "Updated description for the team"
grok.groups.save(group)
License
See License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datagrok_api-0.1.0.tar.gz.
File metadata
- Download URL: datagrok_api-0.1.0.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f68b697eb7b938c631b6a77b13ad8bdafb622cfafcf24032b90302ec6ab5d31
|
|
| MD5 |
42898a52eadf874b7a0460db727b7f77
|
|
| BLAKE2b-256 |
c900ee12b86ce08eaa0ef6dea129afd5d5e323c99784c0c6d3ed574ba613b2cd
|
File details
Details for the file datagrok_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: datagrok_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d0aa81fe699a138e1e3a71289c53828ce8c767179bb4272a09e84973c672ec8
|
|
| MD5 |
1d3e0cfba2d0785937c675ba3c70775a
|
|
| BLAKE2b-256 |
60602ce18a2ef67e4e73bb81ac5fb73bffd7594fc3d0e5090170b739f51b3acb
|