crewai-transcriptapi 0.1.0__py3-none-any.whl
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.
- crewai_transcriptapi/__init__.py +21 -0
- crewai_transcriptapi/transcriptapi_tool.py +182 -0
- crewai_transcriptapi-0.1.0.dist-info/METADATA +132 -0
- crewai_transcriptapi-0.1.0.dist-info/RECORD +6 -0
- crewai_transcriptapi-0.1.0.dist-info/WHEEL +4 -0
- crewai_transcriptapi-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""crewai-transcriptapi: CrewAI tools for TranscriptAPI (transcriptapi.com)."""
|
|
2
|
+
|
|
3
|
+
from .transcriptapi_tool import (
|
|
4
|
+
TranscriptAPISearchToolSchema,
|
|
5
|
+
TranscriptAPIToolSchema,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from .transcriptapi_tool import TranscriptAPISearchTool, TranscriptAPITool
|
|
10
|
+
except ImportError: # pragma: no cover - crewai not installed
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"TranscriptAPITool",
|
|
17
|
+
"TranscriptAPISearchTool",
|
|
18
|
+
"TranscriptAPIToolSchema",
|
|
19
|
+
"TranscriptAPISearchToolSchema",
|
|
20
|
+
"__version__",
|
|
21
|
+
]
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""CrewAI tools for TranscriptAPI (transcriptapi.com).
|
|
2
|
+
|
|
3
|
+
Two tools following the crewai-tools BaseTool conventions:
|
|
4
|
+
|
|
5
|
+
- TranscriptAPITool: fetch the transcript of a YouTube video (the hero use case)
|
|
6
|
+
- TranscriptAPISearchTool: search YouTube for videos or channels
|
|
7
|
+
|
|
8
|
+
Both return a stable JSON string envelope and never leak exceptions:
|
|
9
|
+
{"success": true, "data": {...}}
|
|
10
|
+
{"success": false, "error": {"code": "...", "message": "..."}}
|
|
11
|
+
|
|
12
|
+
Auth: TRANSCRIPTAPI_API_KEY environment variable (Bearer key, "sk_..." format).
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
from typing import Any, Optional, Type
|
|
18
|
+
|
|
19
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
20
|
+
|
|
21
|
+
try: # crewai is the runtime host; keep the import lazy-friendly for tests
|
|
22
|
+
from crewai.tools import BaseTool, EnvVar
|
|
23
|
+
except ImportError: # pragma: no cover - exercised only without crewai installed
|
|
24
|
+
BaseTool = None # type: ignore[assignment,misc]
|
|
25
|
+
EnvVar = None # type: ignore[assignment,misc]
|
|
26
|
+
|
|
27
|
+
BASE_URL = "https://transcriptapi.com/api/v2"
|
|
28
|
+
USER_AGENT = "crewai-transcriptapi/0.1.0 (+https://github.com/ZeroPointRepo/crewai-transcriptapi)"
|
|
29
|
+
TIMEOUT_SECONDS = 60
|
|
30
|
+
|
|
31
|
+
_ENV_KEY = "TRANSCRIPTAPI_API_KEY"
|
|
32
|
+
|
|
33
|
+
_ENV_VARS = (
|
|
34
|
+
[
|
|
35
|
+
EnvVar(
|
|
36
|
+
name=_ENV_KEY,
|
|
37
|
+
description=(
|
|
38
|
+
"TranscriptAPI key (starts with sk_). Create one at "
|
|
39
|
+
"https://transcriptapi.com: 100 free credits, no card (one-time)."
|
|
40
|
+
),
|
|
41
|
+
required=True,
|
|
42
|
+
)
|
|
43
|
+
]
|
|
44
|
+
if EnvVar is not None
|
|
45
|
+
else []
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _envelope_error(code: str, message: str) -> str:
|
|
50
|
+
return json.dumps({"success": False, "error": {"code": code, "message": message}})
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _request(path: str, params: dict) -> str:
|
|
54
|
+
"""GET a TranscriptAPI endpoint and return the JSON string envelope."""
|
|
55
|
+
key = os.environ.get(_ENV_KEY, "").strip()
|
|
56
|
+
if not key:
|
|
57
|
+
return _envelope_error(
|
|
58
|
+
"missing_api_key",
|
|
59
|
+
f"{_ENV_KEY} is not set. Get a free key at https://transcriptapi.com "
|
|
60
|
+
"(100 free credits, no card, one-time).",
|
|
61
|
+
)
|
|
62
|
+
import requests # lazy import so tests can stub it
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
response = requests.get(
|
|
66
|
+
BASE_URL + path,
|
|
67
|
+
params={k: v for k, v in params.items() if v is not None},
|
|
68
|
+
headers={
|
|
69
|
+
"Authorization": f"Bearer {key}",
|
|
70
|
+
"User-Agent": USER_AGENT,
|
|
71
|
+
"Accept": "application/json",
|
|
72
|
+
},
|
|
73
|
+
timeout=TIMEOUT_SECONDS,
|
|
74
|
+
)
|
|
75
|
+
except requests.exceptions.RequestException as exc:
|
|
76
|
+
return _envelope_error("network", str(exc))
|
|
77
|
+
if response.status_code != 200:
|
|
78
|
+
code = {
|
|
79
|
+
401: "invalid_api_key",
|
|
80
|
+
402: "out_of_credits",
|
|
81
|
+
404: "not_found",
|
|
82
|
+
429: "rate_limited",
|
|
83
|
+
}.get(response.status_code, f"http_{response.status_code}")
|
|
84
|
+
message = {
|
|
85
|
+
401: "The API key was rejected. Check TRANSCRIPTAPI_API_KEY.",
|
|
86
|
+
402: "The account is out of credits. See https://transcriptapi.com/billing.",
|
|
87
|
+
404: "Not found: the video may not exist or has no captions.",
|
|
88
|
+
429: "Rate limited. Wait and retry, respecting the Retry-After header.",
|
|
89
|
+
}.get(response.status_code, response.text[:300])
|
|
90
|
+
return _envelope_error(code, message)
|
|
91
|
+
try:
|
|
92
|
+
data = response.json()
|
|
93
|
+
except ValueError:
|
|
94
|
+
return _envelope_error("bad_response", "The API returned a non-JSON response.")
|
|
95
|
+
return json.dumps({"success": True, "data": data})
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class TranscriptAPIToolSchema(BaseModel):
|
|
99
|
+
"""Input for TranscriptAPITool."""
|
|
100
|
+
|
|
101
|
+
video_url: str = Field(
|
|
102
|
+
...,
|
|
103
|
+
min_length=6,
|
|
104
|
+
description=(
|
|
105
|
+
"Full YouTube URL (watch, youtu.be, embed, or Shorts) or the bare "
|
|
106
|
+
"11-character video ID"
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
output_format: str = Field(
|
|
110
|
+
default="text",
|
|
111
|
+
pattern="^(text|json)$",
|
|
112
|
+
description='Transcript format: "text" (plain transcript) or "json" (timestamped segments)',
|
|
113
|
+
)
|
|
114
|
+
language: Optional[str] = Field(
|
|
115
|
+
default=None,
|
|
116
|
+
description="Optional preferred transcript language code, for example 'es'",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class TranscriptAPISearchToolSchema(BaseModel):
|
|
121
|
+
"""Input for TranscriptAPISearchTool."""
|
|
122
|
+
|
|
123
|
+
query: str = Field(..., min_length=1, max_length=200, description="Search query")
|
|
124
|
+
search_type: str = Field(
|
|
125
|
+
default="video",
|
|
126
|
+
pattern="^(video|channel)$",
|
|
127
|
+
description='What to search for: "video" or "channel"',
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
if BaseTool is not None:
|
|
132
|
+
|
|
133
|
+
class TranscriptAPITool(BaseTool):
|
|
134
|
+
"""Fetch the transcript of a YouTube video via TranscriptAPI."""
|
|
135
|
+
|
|
136
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
137
|
+
name: str = "TranscriptAPI YouTube Transcript"
|
|
138
|
+
description: str = (
|
|
139
|
+
"Fetches the transcript of a YouTube video, with metadata, via the "
|
|
140
|
+
"TranscriptAPI service. Accepts a full YouTube URL (watch, youtu.be, "
|
|
141
|
+
"embed, Shorts) or a bare 11-character video ID. Use when the task "
|
|
142
|
+
"needs the spoken content of a specific video: summarizing, quoting, "
|
|
143
|
+
"translating or analyzing it. Costs 1 credit per successful call."
|
|
144
|
+
)
|
|
145
|
+
args_schema: Type[BaseModel] = TranscriptAPIToolSchema
|
|
146
|
+
package_dependencies: list = Field(default_factory=lambda: ["requests"])
|
|
147
|
+
env_vars: list = Field(default_factory=lambda: list(_ENV_VARS))
|
|
148
|
+
|
|
149
|
+
def _run(self, **kwargs: Any) -> str:
|
|
150
|
+
args = TranscriptAPIToolSchema(**kwargs)
|
|
151
|
+
return _request(
|
|
152
|
+
"/youtube/transcript",
|
|
153
|
+
{
|
|
154
|
+
"video_url": args.video_url,
|
|
155
|
+
"format": args.output_format,
|
|
156
|
+
"send_metadata": "true",
|
|
157
|
+
"language": args.language,
|
|
158
|
+
},
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
class TranscriptAPISearchTool(BaseTool):
|
|
162
|
+
"""Search YouTube for videos or channels via TranscriptAPI."""
|
|
163
|
+
|
|
164
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
165
|
+
name: str = "TranscriptAPI YouTube Search"
|
|
166
|
+
description: str = (
|
|
167
|
+
"Searches YouTube for videos or channels via the TranscriptAPI "
|
|
168
|
+
"service and returns titles, IDs, thumbnails, view counts and "
|
|
169
|
+
"publish dates. Use when the task needs to discover videos or "
|
|
170
|
+
"channels about a topic before fetching transcripts. Costs 1 credit "
|
|
171
|
+
"per page of results."
|
|
172
|
+
)
|
|
173
|
+
args_schema: Type[BaseModel] = TranscriptAPISearchToolSchema
|
|
174
|
+
package_dependencies: list = Field(default_factory=lambda: ["requests"])
|
|
175
|
+
env_vars: list = Field(default_factory=lambda: list(_ENV_VARS))
|
|
176
|
+
|
|
177
|
+
def _run(self, **kwargs: Any) -> str:
|
|
178
|
+
args = TranscriptAPISearchToolSchema(**kwargs)
|
|
179
|
+
return _request(
|
|
180
|
+
"/youtube/search",
|
|
181
|
+
{"q": args.query, "type": args.search_type},
|
|
182
|
+
)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crewai-transcriptapi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CrewAI tools for TranscriptAPI: fetch YouTube transcripts and search YouTube videos and channels from CrewAI agents.
|
|
5
|
+
Project-URL: Homepage, https://transcriptapi.com
|
|
6
|
+
Project-URL: Documentation, https://transcriptapi.com/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/ZeroPointRepo/crewai-transcriptapi
|
|
8
|
+
Author-email: Zero Point Studio <hello@transcriptapi.com>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 TranscriptAPI (ZeroPointRepo)
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: ai-agent,crewai,crewai-tools,llm,transcript,transcriptapi,youtube,youtube-api,youtube-transcript
|
|
32
|
+
Classifier: Development Status :: 4 - Beta
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
40
|
+
Requires-Python: >=3.10
|
|
41
|
+
Requires-Dist: crewai>=0.80.0
|
|
42
|
+
Requires-Dist: pydantic>=2.0.0
|
|
43
|
+
Requires-Dist: requests>=2.31.0
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
# crewai-transcriptapi
|
|
47
|
+
|
|
48
|
+
**TranscriptAPI: hosted YouTube transcript + video-discovery API for AI agents.** CrewAI tools edition. Also available as an [n8n community node](https://github.com/ZeroPointRepo/n8n-nodes-transcriptapi), an [MCP server](https://github.com/ZeroPointRepo/youtube-mcp) and [agent skills](https://github.com/ZeroPointRepo/youtube-skills).
|
|
49
|
+
|
|
50
|
+
This package gives [CrewAI](https://www.crewai.com/) agents two tools over [TranscriptAPI](https://transcriptapi.com):
|
|
51
|
+
|
|
52
|
+
- **TranscriptAPITool**: fetch the transcript of any YouTube video (full URL, youtu.be, Shorts, or bare ID) as plain text or timestamped JSON, with metadata. The hero tool: 1 credit per call.
|
|
53
|
+
- **TranscriptAPISearchTool**: search YouTube for videos or channels to discover content before fetching transcripts. 1 credit per page.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install crewai-transcriptapi
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Credentials
|
|
62
|
+
|
|
63
|
+
You need a TranscriptAPI key (starts with `sk_`):
|
|
64
|
+
|
|
65
|
+
1. Create an account at [transcriptapi.com](https://transcriptapi.com): **100 free credits, no card (one-time)**; paid plans from **$5/mo (1,000 credits)**.
|
|
66
|
+
2. Create an API key on the dashboard.
|
|
67
|
+
3. Export it:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
export TRANSCRIPTAPI_API_KEY="sk_..."
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from crewai import Agent
|
|
77
|
+
from crewai_transcriptapi import TranscriptAPITool, TranscriptAPISearchTool
|
|
78
|
+
|
|
79
|
+
researcher = Agent(
|
|
80
|
+
role="Video researcher",
|
|
81
|
+
goal="Find and summarize YouTube content on a topic",
|
|
82
|
+
backstory="Researches spoken video content via transcripts.",
|
|
83
|
+
tools=[TranscriptAPISearchTool(), TranscriptAPITool()],
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The agent can then search for videos on a topic and fetch each transcript for summarizing, quoting, translating or analysis.
|
|
88
|
+
|
|
89
|
+
## Tool reference
|
|
90
|
+
|
|
91
|
+
### TranscriptAPITool
|
|
92
|
+
|
|
93
|
+
| Argument | Type | Default | Description |
|
|
94
|
+
|---|---|---|---|
|
|
95
|
+
| `video_url` | str | required | Full YouTube URL (watch, youtu.be, embed, Shorts) or bare 11-character video ID |
|
|
96
|
+
| `output_format` | str | `"text"` | `"text"` for plain transcript, `"json"` for timestamped segments |
|
|
97
|
+
| `language` | str | none | Optional preferred transcript language code, for example `"es"` |
|
|
98
|
+
|
|
99
|
+
### TranscriptAPISearchTool
|
|
100
|
+
|
|
101
|
+
| Argument | Type | Default | Description |
|
|
102
|
+
|---|---|---|---|
|
|
103
|
+
| `query` | str | required | Search query, 1 to 200 characters |
|
|
104
|
+
| `search_type` | str | `"video"` | `"video"` or `"channel"` |
|
|
105
|
+
|
|
106
|
+
## Response envelope
|
|
107
|
+
|
|
108
|
+
Both tools return a stable JSON string and never raise:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{"success": true, "data": {"transcript": "...", "metadata": {"title": "..."}}}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{"success": false, "error": {"code": "out_of_credits", "message": "The account is out of credits. See https://transcriptapi.com/billing."}}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Error codes: `missing_api_key`, `invalid_api_key`, `out_of_credits`, `not_found`, `rate_limited`, `network`, `bad_response`, `http_<status>`. Failed calls are never charged.
|
|
119
|
+
|
|
120
|
+
## Resources
|
|
121
|
+
|
|
122
|
+
- [TranscriptAPI documentation](https://transcriptapi.com/docs)
|
|
123
|
+
- [Pricing](https://transcriptapi.com)
|
|
124
|
+
- Family: [n8n node](https://github.com/ZeroPointRepo/n8n-nodes-transcriptapi) · [MCP server](https://github.com/ZeroPointRepo/youtube-mcp) · [agent skills](https://github.com/ZeroPointRepo/youtube-skills)
|
|
125
|
+
|
|
126
|
+
## Disclosure
|
|
127
|
+
|
|
128
|
+
TranscriptAPI is an independent product and is not affiliated with or endorsed by YouTube or Google. Use of these tools is subject to the [TranscriptAPI terms](https://transcriptapi.com/terms).
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
crewai_transcriptapi/__init__.py,sha256=O6IoZdJP4ej3chLOfzsUwtpdczMfvAD4Ndm-SFNaSD8,519
|
|
2
|
+
crewai_transcriptapi/transcriptapi_tool.py,sha256=1tOVQnV8ZLaSQ-l-2x-IGKo9Kvk76CMUTBzBWMqspX0,6869
|
|
3
|
+
crewai_transcriptapi-0.1.0.dist-info/METADATA,sha256=mSLCBU58Q6-GuFE5Er3-wY0OdvcF4fbdCQkRcEYLIKA,5780
|
|
4
|
+
crewai_transcriptapi-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
5
|
+
crewai_transcriptapi-0.1.0.dist-info/licenses/LICENSE,sha256=hnkYxWklrAxDTGpOqg-2GDcHI7mE3SJ1RP_djjLpoFM,1086
|
|
6
|
+
crewai_transcriptapi-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TranscriptAPI (ZeroPointRepo)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|