llama-index-tools-tikdataapi 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llama_index_tools_tikdataapi-0.1.0/.gitignore +9 -0
- llama_index_tools_tikdataapi-0.1.0/LICENSE +9 -0
- llama_index_tools_tikdataapi-0.1.0/PKG-INFO +160 -0
- llama_index_tools_tikdataapi-0.1.0/README.md +139 -0
- llama_index_tools_tikdataapi-0.1.0/llama_index/tools/tikdataapi/__init__.py +8 -0
- llama_index_tools_tikdataapi-0.1.0/llama_index/tools/tikdataapi/base.py +614 -0
- llama_index_tools_tikdataapi-0.1.0/llama_index/tools/tikdataapi/client.py +149 -0
- llama_index_tools_tikdataapi-0.1.0/pyproject.toml +47 -0
- llama_index_tools_tikdataapi-0.1.0/tests/test_tools.py +401 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tikdataapi.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: llama-index-tools-tikdataapi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LlamaIndex tool spec for tikdataapi.com: read-only public TikTok profiles, videos, comments, replies, hashtags, sounds, playlists, reposts, related and trending videos, transcripts, live state, video, account, sound, live and hashtag search and follower lists.
|
|
5
|
+
Project-URL: Homepage, https://tikdataapi.com
|
|
6
|
+
Project-URL: Documentation, https://tikdataapi.com/docs
|
|
7
|
+
Project-URL: API reference, https://tikdataapi.com/reference
|
|
8
|
+
Project-URL: Source code, https://github.com/tikdataapi/tikdataapi
|
|
9
|
+
Project-URL: Issue tracker, https://github.com/tikdataapi/tikdataapi/issues
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,comments,followers,hashtags,live,llama-index,llamahub,llamaindex,llm,music,playlists,search,tikdataapi,tiktok,tiktok-api,tools,transcripts,trending,videos
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: <4.0,>=3.9
|
|
18
|
+
Requires-Dist: httpx<0.29.0,>=0.27.0
|
|
19
|
+
Requires-Dist: llama-index-core<0.15,>=0.12.0
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# llama-index-tools-tikdataapi
|
|
23
|
+
|
|
24
|
+
LlamaIndex tool spec for [tikdataapi.com](https://tikdataapi.com): read-only public TikTok data.
|
|
25
|
+
Profiles, the videos of an account, its reposts, playlists, followers and following, videos, comments,
|
|
26
|
+
replies, transcripts, related and trending videos, hashtags, sounds and their videos, the videos of a
|
|
27
|
+
playlist, whether an account is live, and video, account, sound, live and hashtag search.
|
|
28
|
+
|
|
29
|
+
Read-only by design. No posting, no likes, no direct messages, no private data, and no TikTok login: the
|
|
30
|
+
tools read what a logged-out visitor of tiktok.com sees. That includes the general ("Top") search of TikTok,
|
|
31
|
+
videos only, its account search (the "Users" tab), its sound and live search (the "Sounds" and "LIVE" tabs),
|
|
32
|
+
and the follower and following lists of an account. TikTok gives a logged-out visitor no hashtag search, so
|
|
33
|
+
hashtag search ranks the hashtags of the videos of the general search. It does not include the filters and
|
|
34
|
+
sorting of the Videos tab of search (TikTok ignores them for a logged-out visitor), liked videos, video files or
|
|
35
|
+
the streams of live rooms.
|
|
36
|
+
Not affiliated with TikTok or ByteDance.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install llama-index-tools-tikdataapi
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Use
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from llama_index.tools.tikdataapi import TikdataapiToolSpec
|
|
46
|
+
|
|
47
|
+
# Reads TIKDATAAPI_KEY from the environment.
|
|
48
|
+
tool_spec = TikdataapiToolSpec()
|
|
49
|
+
tools = tool_spec.to_tool_list()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
With an agent:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from llama_index.core.agent.workflow import FunctionAgent
|
|
56
|
+
from llama_index.llms.anthropic import Anthropic
|
|
57
|
+
from llama_index.tools.tikdataapi import TikdataapiToolSpec
|
|
58
|
+
|
|
59
|
+
agent = FunctionAgent(
|
|
60
|
+
tools=TikdataapiToolSpec(max_results=25).to_tool_list(),
|
|
61
|
+
llm=Anthropic(model="claude-opus-5"),
|
|
62
|
+
)
|
|
63
|
+
print(await agent.run("What did @nba post this week, and how did people react?"))
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
One call on its own:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
TikdataapiToolSpec().get_user_videos("nba", count=10)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Tools
|
|
73
|
+
|
|
74
|
+
The names are the names of the tools of the hosted MCP server.
|
|
75
|
+
|
|
76
|
+
| Tool | Reads | Credits |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `get_user` | One profile, by username or `sec_uid` | 1 |
|
|
79
|
+
| `get_users` | Up to 100 profiles in one call, by username | 1 per profile |
|
|
80
|
+
| `get_user_videos` | The videos of an account: pinned first, then newest first | 1 per video |
|
|
81
|
+
| `get_users_videos` | The newest 1 to 16 videos of up to 20 accounts in one call | 1 per video |
|
|
82
|
+
| `get_user_followers` | The accounts that follow an account, newest first | 1 per profile |
|
|
83
|
+
| `get_user_following` | The accounts an account follows, newest first | 1 per profile |
|
|
84
|
+
| `get_user_reposts` | The videos an account reposted | 1 per video |
|
|
85
|
+
| `get_user_playlists` | The playlists an account made | 1 per playlist |
|
|
86
|
+
| `get_user_live` | Whether an account is live now, with its room | 1, live or not |
|
|
87
|
+
| `get_video` | One video, with its author, sound and counts | 1 |
|
|
88
|
+
| `get_videos` | Up to 100 videos in one call | 1 per video |
|
|
89
|
+
| `get_related_videos` | The videos TikTok shows next to a video: one page of up to 16, no cursor | 1 per video |
|
|
90
|
+
| `get_trending_videos` | The explore feed of a logged-out visitor: up to 50, no cursor | 1 per video |
|
|
91
|
+
| `get_video_transcript` | The transcript of a video from its subtitles: timed segments and text | 1 |
|
|
92
|
+
| `get_comments` | The comments of a video: pinned first, then the most relevant | 1 per comment |
|
|
93
|
+
| `get_comment_replies` | The replies to one comment, oldest first | 1 per reply |
|
|
94
|
+
| `get_hashtag` | One hashtag with its counts of videos and views | 1 |
|
|
95
|
+
| `get_hashtag_videos` | The videos of a hashtag, in the order of the hashtag page | 1 per video |
|
|
96
|
+
| `get_music` | One sound (music) by id, with the number of videos that use it | 1 |
|
|
97
|
+
| `get_music_videos` | The videos that use a sound, in the order of the sound page | 1 per video |
|
|
98
|
+
| `get_playlist_videos` | The videos of a playlist, in its order | 1 per video |
|
|
99
|
+
| `search_videos` | The videos that the general ("Top") search of TikTok finds for a query | 1 per video |
|
|
100
|
+
| `search_users` | The accounts that the account search of TikTok finds for a query, as short profiles | 1 per profile |
|
|
101
|
+
| `search_music` | The sounds that the sound search of TikTok finds for a query, as short sounds | 1 per sound |
|
|
102
|
+
| `search_live` | The live rooms that the live search of TikTok finds for a query | 1 per room |
|
|
103
|
+
| `search_hashtags` | The hashtags of the videos of the general search for a query, most used first: up to 30, no cursor | 1 per hashtag |
|
|
104
|
+
| `get_balance` | Credits left and rate limit | free |
|
|
105
|
+
|
|
106
|
+
Empty results and failed requests cost nothing: a private account, a video with comments turned off, a deleted
|
|
107
|
+
video, a search with no result. A repeated read inside the cache window costs half.
|
|
108
|
+
Every response carries `credits_charged` and `balance_remaining`, so the model can watch the budget
|
|
109
|
+
and stop on its own.
|
|
110
|
+
|
|
111
|
+
In an entry of a follower or following list the counts may be rounded; `get_user` gives the exact ones.
|
|
112
|
+
An entry of `search_users` is a short profile: the follower count is rounded, and there is no following count,
|
|
113
|
+
video count or private flag; `get_user` or `get_users` gives the full profile.
|
|
114
|
+
A sound and a playlist are read by their numeric id (up to 25 digits): the number at the end of the address
|
|
115
|
+
of the sound, `music.id` of a video, or the `id` of an entry of `get_user_playlists`. The count of videos
|
|
116
|
+
of a sound is rounded by TikTok. `get_related_videos` and `get_trending_videos` have no next page.
|
|
117
|
+
`get_user_live` costs 1 credit whether the account is live or not; when it is not, `live` is false and the
|
|
118
|
+
room fields are absent. `get_video_transcript` takes an optional `lang` (`eng-US` or `eng`); a video with no
|
|
119
|
+
subtitles is a `not_found` with reason `unavailable`, free.
|
|
120
|
+
`search_hashtags` reads about 24 videos of the general search and ranks their hashtags by `result_videos`
|
|
121
|
+
(how many of those videos use the hashtag), then `result_plays` (the sum of their plays). These counts are of
|
|
122
|
+
those videos only, not the totals of TikTok: `get_hashtag` gives those. `count` is 1 to 30, default 10, and
|
|
123
|
+
there is no next page.
|
|
124
|
+
Not known yet: how deep TikTok lets a follower list or a search be read, and what it gives for a private
|
|
125
|
+
account or a hidden following list.
|
|
126
|
+
|
|
127
|
+
## Spending guards
|
|
128
|
+
|
|
129
|
+
`max_results` caps the page size of every paging tool, and the videos for each account in
|
|
130
|
+
`get_users_videos`:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
tool_spec = TikdataapiToolSpec(max_results=25)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Narrow the surface with the LlamaIndex argument:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
tools = TikdataapiToolSpec().to_tool_list(spec_functions=["get_user", "get_user_videos", "get_balance"])
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Errors
|
|
143
|
+
|
|
144
|
+
A failure the model can act on — no credits, not found (with a `reason`: nonexistent, banned, private,
|
|
145
|
+
removed, unavailable), a bad argument — comes back as a dict with `error.code`, so the model can change plan.
|
|
146
|
+
None of those are charged.
|
|
147
|
+
A missing or revoked key raises `TikdataapiAuthError`, because no model can repair it.
|
|
148
|
+
Rate limits and upstream faults raise `TikdataapiError`.
|
|
149
|
+
|
|
150
|
+
## MCP instead
|
|
151
|
+
|
|
152
|
+
An agent that speaks MCP needs no package. The hosted server is at `https://api.tikdataapi.com/mcp`
|
|
153
|
+
(Streamable HTTP, OAuth or `x-api-key`), with the registry name `com.tikdataapi/tikdataapi`.
|
|
154
|
+
|
|
155
|
+
## Keys and pricing
|
|
156
|
+
|
|
157
|
+
Get a key at [tikdataapi.com/dashboard](https://tikdataapi.com/dashboard). 1,000 credits to start, no card.
|
|
158
|
+
Prepaid packs from $10; credits never expire. Live status: [tikdataapi.com/status](https://tikdataapi.com/status).
|
|
159
|
+
|
|
160
|
+
MIT licensed.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# llama-index-tools-tikdataapi
|
|
2
|
+
|
|
3
|
+
LlamaIndex tool spec for [tikdataapi.com](https://tikdataapi.com): read-only public TikTok data.
|
|
4
|
+
Profiles, the videos of an account, its reposts, playlists, followers and following, videos, comments,
|
|
5
|
+
replies, transcripts, related and trending videos, hashtags, sounds and their videos, the videos of a
|
|
6
|
+
playlist, whether an account is live, and video, account, sound, live and hashtag search.
|
|
7
|
+
|
|
8
|
+
Read-only by design. No posting, no likes, no direct messages, no private data, and no TikTok login: the
|
|
9
|
+
tools read what a logged-out visitor of tiktok.com sees. That includes the general ("Top") search of TikTok,
|
|
10
|
+
videos only, its account search (the "Users" tab), its sound and live search (the "Sounds" and "LIVE" tabs),
|
|
11
|
+
and the follower and following lists of an account. TikTok gives a logged-out visitor no hashtag search, so
|
|
12
|
+
hashtag search ranks the hashtags of the videos of the general search. It does not include the filters and
|
|
13
|
+
sorting of the Videos tab of search (TikTok ignores them for a logged-out visitor), liked videos, video files or
|
|
14
|
+
the streams of live rooms.
|
|
15
|
+
Not affiliated with TikTok or ByteDance.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install llama-index-tools-tikdataapi
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Use
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from llama_index.tools.tikdataapi import TikdataapiToolSpec
|
|
25
|
+
|
|
26
|
+
# Reads TIKDATAAPI_KEY from the environment.
|
|
27
|
+
tool_spec = TikdataapiToolSpec()
|
|
28
|
+
tools = tool_spec.to_tool_list()
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
With an agent:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from llama_index.core.agent.workflow import FunctionAgent
|
|
35
|
+
from llama_index.llms.anthropic import Anthropic
|
|
36
|
+
from llama_index.tools.tikdataapi import TikdataapiToolSpec
|
|
37
|
+
|
|
38
|
+
agent = FunctionAgent(
|
|
39
|
+
tools=TikdataapiToolSpec(max_results=25).to_tool_list(),
|
|
40
|
+
llm=Anthropic(model="claude-opus-5"),
|
|
41
|
+
)
|
|
42
|
+
print(await agent.run("What did @nba post this week, and how did people react?"))
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
One call on its own:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
TikdataapiToolSpec().get_user_videos("nba", count=10)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Tools
|
|
52
|
+
|
|
53
|
+
The names are the names of the tools of the hosted MCP server.
|
|
54
|
+
|
|
55
|
+
| Tool | Reads | Credits |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `get_user` | One profile, by username or `sec_uid` | 1 |
|
|
58
|
+
| `get_users` | Up to 100 profiles in one call, by username | 1 per profile |
|
|
59
|
+
| `get_user_videos` | The videos of an account: pinned first, then newest first | 1 per video |
|
|
60
|
+
| `get_users_videos` | The newest 1 to 16 videos of up to 20 accounts in one call | 1 per video |
|
|
61
|
+
| `get_user_followers` | The accounts that follow an account, newest first | 1 per profile |
|
|
62
|
+
| `get_user_following` | The accounts an account follows, newest first | 1 per profile |
|
|
63
|
+
| `get_user_reposts` | The videos an account reposted | 1 per video |
|
|
64
|
+
| `get_user_playlists` | The playlists an account made | 1 per playlist |
|
|
65
|
+
| `get_user_live` | Whether an account is live now, with its room | 1, live or not |
|
|
66
|
+
| `get_video` | One video, with its author, sound and counts | 1 |
|
|
67
|
+
| `get_videos` | Up to 100 videos in one call | 1 per video |
|
|
68
|
+
| `get_related_videos` | The videos TikTok shows next to a video: one page of up to 16, no cursor | 1 per video |
|
|
69
|
+
| `get_trending_videos` | The explore feed of a logged-out visitor: up to 50, no cursor | 1 per video |
|
|
70
|
+
| `get_video_transcript` | The transcript of a video from its subtitles: timed segments and text | 1 |
|
|
71
|
+
| `get_comments` | The comments of a video: pinned first, then the most relevant | 1 per comment |
|
|
72
|
+
| `get_comment_replies` | The replies to one comment, oldest first | 1 per reply |
|
|
73
|
+
| `get_hashtag` | One hashtag with its counts of videos and views | 1 |
|
|
74
|
+
| `get_hashtag_videos` | The videos of a hashtag, in the order of the hashtag page | 1 per video |
|
|
75
|
+
| `get_music` | One sound (music) by id, with the number of videos that use it | 1 |
|
|
76
|
+
| `get_music_videos` | The videos that use a sound, in the order of the sound page | 1 per video |
|
|
77
|
+
| `get_playlist_videos` | The videos of a playlist, in its order | 1 per video |
|
|
78
|
+
| `search_videos` | The videos that the general ("Top") search of TikTok finds for a query | 1 per video |
|
|
79
|
+
| `search_users` | The accounts that the account search of TikTok finds for a query, as short profiles | 1 per profile |
|
|
80
|
+
| `search_music` | The sounds that the sound search of TikTok finds for a query, as short sounds | 1 per sound |
|
|
81
|
+
| `search_live` | The live rooms that the live search of TikTok finds for a query | 1 per room |
|
|
82
|
+
| `search_hashtags` | The hashtags of the videos of the general search for a query, most used first: up to 30, no cursor | 1 per hashtag |
|
|
83
|
+
| `get_balance` | Credits left and rate limit | free |
|
|
84
|
+
|
|
85
|
+
Empty results and failed requests cost nothing: a private account, a video with comments turned off, a deleted
|
|
86
|
+
video, a search with no result. A repeated read inside the cache window costs half.
|
|
87
|
+
Every response carries `credits_charged` and `balance_remaining`, so the model can watch the budget
|
|
88
|
+
and stop on its own.
|
|
89
|
+
|
|
90
|
+
In an entry of a follower or following list the counts may be rounded; `get_user` gives the exact ones.
|
|
91
|
+
An entry of `search_users` is a short profile: the follower count is rounded, and there is no following count,
|
|
92
|
+
video count or private flag; `get_user` or `get_users` gives the full profile.
|
|
93
|
+
A sound and a playlist are read by their numeric id (up to 25 digits): the number at the end of the address
|
|
94
|
+
of the sound, `music.id` of a video, or the `id` of an entry of `get_user_playlists`. The count of videos
|
|
95
|
+
of a sound is rounded by TikTok. `get_related_videos` and `get_trending_videos` have no next page.
|
|
96
|
+
`get_user_live` costs 1 credit whether the account is live or not; when it is not, `live` is false and the
|
|
97
|
+
room fields are absent. `get_video_transcript` takes an optional `lang` (`eng-US` or `eng`); a video with no
|
|
98
|
+
subtitles is a `not_found` with reason `unavailable`, free.
|
|
99
|
+
`search_hashtags` reads about 24 videos of the general search and ranks their hashtags by `result_videos`
|
|
100
|
+
(how many of those videos use the hashtag), then `result_plays` (the sum of their plays). These counts are of
|
|
101
|
+
those videos only, not the totals of TikTok: `get_hashtag` gives those. `count` is 1 to 30, default 10, and
|
|
102
|
+
there is no next page.
|
|
103
|
+
Not known yet: how deep TikTok lets a follower list or a search be read, and what it gives for a private
|
|
104
|
+
account or a hidden following list.
|
|
105
|
+
|
|
106
|
+
## Spending guards
|
|
107
|
+
|
|
108
|
+
`max_results` caps the page size of every paging tool, and the videos for each account in
|
|
109
|
+
`get_users_videos`:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
tool_spec = TikdataapiToolSpec(max_results=25)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Narrow the surface with the LlamaIndex argument:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
tools = TikdataapiToolSpec().to_tool_list(spec_functions=["get_user", "get_user_videos", "get_balance"])
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Errors
|
|
122
|
+
|
|
123
|
+
A failure the model can act on — no credits, not found (with a `reason`: nonexistent, banned, private,
|
|
124
|
+
removed, unavailable), a bad argument — comes back as a dict with `error.code`, so the model can change plan.
|
|
125
|
+
None of those are charged.
|
|
126
|
+
A missing or revoked key raises `TikdataapiAuthError`, because no model can repair it.
|
|
127
|
+
Rate limits and upstream faults raise `TikdataapiError`.
|
|
128
|
+
|
|
129
|
+
## MCP instead
|
|
130
|
+
|
|
131
|
+
An agent that speaks MCP needs no package. The hosted server is at `https://api.tikdataapi.com/mcp`
|
|
132
|
+
(Streamable HTTP, OAuth or `x-api-key`), with the registry name `com.tikdataapi/tikdataapi`.
|
|
133
|
+
|
|
134
|
+
## Keys and pricing
|
|
135
|
+
|
|
136
|
+
Get a key at [tikdataapi.com/dashboard](https://tikdataapi.com/dashboard). 1,000 credits to start, no card.
|
|
137
|
+
Prepaid packs from $10; credits never expire. Live status: [tikdataapi.com/status](https://tikdataapi.com/status).
|
|
138
|
+
|
|
139
|
+
MIT licensed.
|