一个用于与 Vika 维格表 API 交互的 Python 库。
Project description
Vika for Astrabot
这是基于兼容性更强的依赖项对Vika交互工具库的重构项目,用于与 Vika 维格表(apitable.com)的 API 进行交互。
Installation
通过 pip 可以轻松安装本库:
pip install astral_vika
Usage
本项目重构过程严格遵守Vika官方文档的操作指引,目标是与原Vika库完全兼容 以下是一个基本的使用示例,展示了如何初始化客户端、获取数据表以及查询记录:
from astral_vika import Vika
# 1. 初始化 Vika 客户端
# 建议从环境变量或安全配置中读取 API Token
vika = Vika(token="YOUR_API_TOKEN")
# 2. 获取指定的数据表
# 可以通过数据表 URL 或 ID 获取
datasheet = vika.datasheet("dstxxxxxxxxxxxxxx") # 替换为你的数据表ID
# 3. 查询所有记录
# records 是一个 Record 对象的列表
try:
records = datasheet.records.all()
for record in records:
# 假设你的表中有“标题”字段
print(f"记录ID: {record.id}, 标题: {record.get('标题')}")
except Exception as e:
print(f"查询记录时出错: {e}")
# 4. 创建一条新记录
try:
new_record = datasheet.records.create({
"标题": "这是一条来自 Astrabot 的新记录",
"备注": "通过 vika-for-astrabot SDK 创建"
})
print(f"成功创建记录: {new_record.id}")
except Exception as e:
print(f"创建记录失败: {e}")
下面是一个在初始化时指定自定义 API 地址的示例,适用于私有化部署的 Vika 实例:
# 使用自定义的 base URL 来初始化,适用于私有化部署
vika = Vika(
token="YOUR_API_TOKEN",
api_base="https://your-private-vika.com/fusion/v1"
)
License
本项目根据 MIT License 授权。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
astral_vika-0.9.2.tar.gz
(31.8 kB
view details)
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 astral_vika-0.9.2.tar.gz.
File metadata
- Download URL: astral_vika-0.9.2.tar.gz
- Upload date:
- Size: 31.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9fac57487dfa30210ab331285bd51c237e71f68c292f90d5da1bbf16141ad7c
|
|
| MD5 |
f9f7b0df764f6727c50ffc8bb67d8478
|
|
| BLAKE2b-256 |
3eee86d171fd76a92531f5804fa3076cf21ea0fee9a763486d6fff5cc0e7f6e3
|
File details
Details for the file astral_vika-0.9.2-py3-none-any.whl.
File metadata
- Download URL: astral_vika-0.9.2-py3-none-any.whl
- Upload date:
- Size: 44.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e66eb963fee00515466dfd6c94571324524f70b9f51d9e23182552a4de9627a0
|
|
| MD5 |
c650bbb431e552c803447077ffad4e2e
|
|
| BLAKE2b-256 |
863012a3280feff20f6d1239d8f3ac87640426f7be3a1c86e3613486cd389d50
|