langchain-xtikapi 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.
@@ -0,0 +1,90 @@
1
+ """LangChain & LangGraph tools for XTikAPI (https://xtikapi.com)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from typing import Any, Dict, List, Optional, Type
7
+
8
+ from langchain_core.tools import BaseTool
9
+ from pydantic import BaseModel, Field
10
+ from xtikapi import XTikClient
11
+
12
+
13
+ class _FindInput(BaseModel):
14
+ query: str = Field(..., description='Natural-language search query, e.g. "douyin video comments" or "tiktok search"')
15
+ platform: Optional[str] = Field(None, description="Optional platform filter, e.g. douyin, xiaohongshu, tiktok, wechat_mp, x, reddit")
16
+ limit: int = Field(5, ge=1, le=10)
17
+
18
+
19
+ class _DescribeInput(BaseModel):
20
+ endpoint_id: str = Field(..., description="Exact endpoint ID from xtikapi_find, e.g. douyin.videos.search")
21
+
22
+
23
+ class _CallInput(BaseModel):
24
+ endpoint_id: str = Field(..., description="Exact endpoint ID, e.g. tiktok.videos.search")
25
+ params: Dict[str, Any] = Field(default_factory=dict, description="Query or JSON body parameters")
26
+ max_price_usd: Optional[float] = Field(None, description="Optional safety budget cap in USD")
27
+
28
+
29
+ class XTikFindTool(BaseTool):
30
+ name: str = "xtikapi_find"
31
+ description: str = "Search XTikAPI's 229 social media endpoints across 19 platforms (free)."
32
+ args_schema: Type[BaseModel] = _FindInput
33
+ client: XTikClient
34
+
35
+ def _run(self, query: str, platform: Optional[str] = None, limit: int = 5) -> str:
36
+ matches = self.client.search_catalog(query, platform=platform, limit=limit)
37
+ summary = [
38
+ {
39
+ "id": m["id"],
40
+ "method": m["method"],
41
+ "price_usd": m["price"],
42
+ "summary": m["summary"],
43
+ "required_params": [p["name"] for p in m.get("params", []) if p.get("required")],
44
+ }
45
+ for m in matches
46
+ ]
47
+ return json.dumps({"results": summary}, ensure_ascii=False)
48
+
49
+
50
+ class XTikDescribeTool(BaseTool):
51
+ name: str = "xtikapi_describe"
52
+ description: str = "Get full parameters, HTTP method, and USD price for one XTikAPI endpoint ID (free)."
53
+ args_schema: Type[BaseModel] = _DescribeInput
54
+ client: XTikClient
55
+
56
+ def _run(self, endpoint_id: str) -> str:
57
+ return json.dumps(self.client.endpoint(endpoint_id), ensure_ascii=False)
58
+
59
+
60
+ class XTikCallTool(BaseTool):
61
+ name: str = "xtikapi_call"
62
+ description: str = "Execute an XTikAPI social media endpoint and return normalized JSON ($0.002-$0.04 per call; errors are free)."
63
+ args_schema: Type[BaseModel] = _CallInput
64
+ client: XTikClient
65
+
66
+ def _run(
67
+ self,
68
+ endpoint_id: str,
69
+ params: Optional[Dict[str, Any]] = None,
70
+ max_price_usd: Optional[float] = None,
71
+ ) -> str:
72
+ res = self.client.call(endpoint_id, params or {}, max_price_usd=max_price_usd)
73
+ return json.dumps(res, ensure_ascii=False)
74
+
75
+
76
+ class XTikAPIToolkit:
77
+ """Provides find, describe, and call tools for LangChain / LangGraph agents."""
78
+
79
+ def __init__(self, api_key: Optional[str] = None, base_url: str = "https://xtikapi.com") -> None:
80
+ self.client = XTikClient(api_key=api_key, base_url=base_url)
81
+
82
+ def get_tools(self) -> List[BaseTool]:
83
+ return [
84
+ XTikFindTool(client=self.client),
85
+ XTikDescribeTool(client=self.client),
86
+ XTikCallTool(client=self.client),
87
+ ]
88
+
89
+
90
+ __all__ = ["XTikAPIToolkit", "XTikFindTool", "XTikDescribeTool", "XTikCallTool"]
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.5
2
+ Name: langchain-xtikapi
3
+ Version: 0.1.0
4
+ Summary: LangChain & LangGraph toolkit for XTikAPI — query 19 social media platforms (Douyin, Xiaohongshu, WeChat, TikTok, YouTube, Instagram, X, Reddit).
5
+ Project-URL: Homepage, https://xtikapi.com
6
+ Project-URL: Repository, https://github.com/xtikapi/xtikapi-python
7
+ Author-email: XTikAPI <support@xtikapi.com>
8
+ License-Expression: MIT
9
+ Keywords: ai-agent,langchain,langgraph,social-media-api,xtikapi
10
+ Requires-Python: >=3.9
11
+ Requires-Dist: langchain-core>=0.3.0
12
+ Requires-Dist: pydantic>=2.0.0
13
+ Requires-Dist: xtikapi>=0.1.0
14
+ Description-Content-Type: text/markdown
15
+
16
+ # langchain-xtikapi
17
+
18
+ LangChain / LangGraph tools for [XTikAPI](https://xtikapi.com) — discover and call 229 social media endpoints across 19 platforms.
19
+
20
+ ```bash
21
+ pip install langchain-xtikapi
22
+ ```
23
+
24
+ ```python
25
+ from langchain_xtikapi import XTikAPIToolkit
26
+
27
+ toolkit = XTikAPIToolkit(api_key="dk_your_key")
28
+ tools = toolkit.get_tools()
29
+ ```
@@ -0,0 +1,4 @@
1
+ langchain_xtikapi/__init__.py,sha256=3wo51UK5IbaLLRMX4BbigpGvAPQTG7PlAcSw4TFfdXg,3415
2
+ langchain_xtikapi-0.1.0.dist-info/METADATA,sha256=pXrv_-F3W_xDHs8bQm7X7SaUy34Fw5T9Jmbs2iK7YmU,956
3
+ langchain_xtikapi-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
4
+ langchain_xtikapi-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any