langchain-snaprender 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.
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-snaprender
3
+ Version: 0.1.0
4
+ Summary: LangChain tools for SnapRender Screenshot API — capture websites as PNG, JPEG, WebP, or PDF
5
+ Author-email: SnapRender <support@snap-render.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://snap-render.com
8
+ Project-URL: Repository, https://github.com/User0856/snaprender-integrations/tree/main/langchain
9
+ Project-URL: Documentation, https://snap-render.com
10
+ Project-URL: Bug Tracker, https://github.com/User0856/snaprender-integrations/issues
11
+ Keywords: langchain,langchain-tool,screenshot,web-capture,snaprender,ai-agent,llm-tool
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: langchain-core>=0.2.0
25
+ Requires-Dist: snaprender>=0.2.0
26
+
27
+ # langchain-snaprender
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/langchain-snaprender)](https://pypi.org/project/langchain-snaprender/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../LICENSE)
31
+
32
+ LangChain / LangGraph tools for [SnapRender Screenshot API](https://snap-render.com). Lets your LangChain agents capture website screenshots as PNG, JPEG, WebP, or PDF.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install langchain-snaprender
38
+ ```
39
+
40
+ ## Setup
41
+
42
+ ```bash
43
+ export SNAPRENDER_API_KEY="sk_live_your_key_here"
44
+ ```
45
+
46
+ Get a free key at [app.snap-render.com](https://app.snap-render.com/auth/signup) — 50 screenshots/month, no credit card.
47
+
48
+ ## Usage
49
+
50
+ ```python
51
+ from langchain_snaprender import take_screenshot, check_cache, get_usage
52
+
53
+ # Use as standalone tools
54
+ result = take_screenshot.invoke({"url": "https://example.com"})
55
+ print(result)
56
+
57
+ # Or bind to a LangChain agent
58
+ from langchain_openai import ChatOpenAI
59
+ from langgraph.prebuilt import create_react_agent
60
+
61
+ llm = ChatOpenAI(model="gpt-4o")
62
+ tools = [take_screenshot, check_cache, get_usage]
63
+ agent = create_react_agent(llm, tools)
64
+
65
+ response = agent.invoke({"messages": [("user", "Take a screenshot of stripe.com")]})
66
+ ```
67
+
68
+ ## Tools
69
+
70
+ ### `take_screenshot`
71
+
72
+ Capture any website as PNG, JPEG, WebP, or PDF.
73
+
74
+ Parameters: `url`, `format`, `full_page`, `dark_mode`, `block_ads`, `block_cookie_banners`, `device`, `width`, `height`
75
+
76
+ ### `check_cache`
77
+
78
+ Check if a screenshot is cached (free, doesn't count against quota).
79
+
80
+ Parameters: `url`, `format`
81
+
82
+ ### `get_usage`
83
+
84
+ Get current month's usage stats.
85
+
86
+ ## License
87
+
88
+ MIT
@@ -0,0 +1,62 @@
1
+ # langchain-snaprender
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/langchain-snaprender)](https://pypi.org/project/langchain-snaprender/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../LICENSE)
5
+
6
+ LangChain / LangGraph tools for [SnapRender Screenshot API](https://snap-render.com). Lets your LangChain agents capture website screenshots as PNG, JPEG, WebP, or PDF.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ pip install langchain-snaprender
12
+ ```
13
+
14
+ ## Setup
15
+
16
+ ```bash
17
+ export SNAPRENDER_API_KEY="sk_live_your_key_here"
18
+ ```
19
+
20
+ Get a free key at [app.snap-render.com](https://app.snap-render.com/auth/signup) — 50 screenshots/month, no credit card.
21
+
22
+ ## Usage
23
+
24
+ ```python
25
+ from langchain_snaprender import take_screenshot, check_cache, get_usage
26
+
27
+ # Use as standalone tools
28
+ result = take_screenshot.invoke({"url": "https://example.com"})
29
+ print(result)
30
+
31
+ # Or bind to a LangChain agent
32
+ from langchain_openai import ChatOpenAI
33
+ from langgraph.prebuilt import create_react_agent
34
+
35
+ llm = ChatOpenAI(model="gpt-4o")
36
+ tools = [take_screenshot, check_cache, get_usage]
37
+ agent = create_react_agent(llm, tools)
38
+
39
+ response = agent.invoke({"messages": [("user", "Take a screenshot of stripe.com")]})
40
+ ```
41
+
42
+ ## Tools
43
+
44
+ ### `take_screenshot`
45
+
46
+ Capture any website as PNG, JPEG, WebP, or PDF.
47
+
48
+ Parameters: `url`, `format`, `full_page`, `dark_mode`, `block_ads`, `block_cookie_banners`, `device`, `width`, `height`
49
+
50
+ ### `check_cache`
51
+
52
+ Check if a screenshot is cached (free, doesn't count against quota).
53
+
54
+ Parameters: `url`, `format`
55
+
56
+ ### `get_usage`
57
+
58
+ Get current month's usage stats.
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,137 @@
1
+ """LangChain tools for SnapRender Screenshot API.
2
+
3
+ Usage:
4
+ from langchain_snaprender import take_screenshot, check_cache, get_usage
5
+
6
+ tools = [take_screenshot, check_cache, get_usage]
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import base64
12
+ import os
13
+ import tempfile
14
+ from typing import Optional
15
+
16
+ from langchain_core.tools import tool
17
+ from snaprender import SnapRender
18
+
19
+
20
+ def _client() -> SnapRender:
21
+ key = os.environ.get("SNAPRENDER_API_KEY")
22
+ if not key:
23
+ raise RuntimeError(
24
+ "SNAPRENDER_API_KEY environment variable is required. "
25
+ "Get a free key at https://app.snap-render.com/auth/signup"
26
+ )
27
+ return SnapRender(api_key=key)
28
+
29
+
30
+ @tool
31
+ def take_screenshot(
32
+ url: str,
33
+ format: str = "png",
34
+ full_page: bool = False,
35
+ dark_mode: bool = False,
36
+ block_ads: bool = True,
37
+ block_cookie_banners: bool = True,
38
+ device: Optional[str] = None,
39
+ width: Optional[int] = None,
40
+ height: Optional[int] = None,
41
+ ) -> str:
42
+ """Take a screenshot of a website. Returns the file path and metadata.
43
+
44
+ Args:
45
+ url: URL to capture (must start with http:// or https://)
46
+ format: Output format - png, jpeg, webp, or pdf (default: png)
47
+ full_page: Capture entire scrollable page (default: False)
48
+ dark_mode: Enable dark mode CSS emulation (default: False)
49
+ block_ads: Block advertisements (default: True)
50
+ block_cookie_banners: Remove cookie consent banners (default: True)
51
+ device: Device preset - iphone_14, iphone_15_pro, pixel_7, ipad_pro, macbook_pro
52
+ width: Viewport width in pixels, 320-3840
53
+ height: Viewport height in pixels, 200-10000
54
+ """
55
+ snap = _client()
56
+ try:
57
+ result = snap.capture(
58
+ url,
59
+ format=format,
60
+ full_page=full_page,
61
+ dark_mode=dark_mode,
62
+ block_ads=block_ads,
63
+ block_cookie_banners=block_cookie_banners,
64
+ device=device,
65
+ width=width,
66
+ height=height,
67
+ response_type="json",
68
+ )
69
+ finally:
70
+ snap.close()
71
+
72
+ ext = format if format != "jpeg" else "jpg"
73
+ fd, path = tempfile.mkstemp(suffix=f".{ext}", prefix="snaprender_")
74
+ os.close(fd)
75
+
76
+ image_data = result["image"]
77
+ if "," in image_data:
78
+ image_data = image_data.split(",", 1)[1]
79
+
80
+ with open(path, "wb") as f:
81
+ f.write(base64.b64decode(image_data))
82
+
83
+ file_size = os.path.getsize(path)
84
+ return (
85
+ f"Screenshot saved to {path} ({file_size:,} bytes)\n"
86
+ f"URL: {result.get('url', url)}\n"
87
+ f"Format: {result.get('format', format)}\n"
88
+ f"Cache: {result.get('cache', 'unknown')}\n"
89
+ f"Response time: {result.get('responseTime', 'unknown')}\n"
90
+ f"Remaining credits: {result.get('remainingCredits', 'unknown')}"
91
+ )
92
+
93
+
94
+ @tool
95
+ def check_cache(url: str, format: str = "png") -> str:
96
+ """Check if a screenshot is already cached without capturing a new one. Does not count against quota.
97
+
98
+ Args:
99
+ url: URL to check
100
+ format: Output format - png, jpeg, webp, or pdf (default: png)
101
+ """
102
+ snap = _client()
103
+ try:
104
+ info = snap.info(url, format=format)
105
+ finally:
106
+ snap.close()
107
+
108
+ if info["cached"]:
109
+ return (
110
+ f"Cached: YES\n"
111
+ f"URL: {info['url']}\n"
112
+ f"Cached at: {info.get('cached_at', 'unknown')}\n"
113
+ f"Expires at: {info.get('expires_at', 'unknown')}\n"
114
+ f"Content type: {info.get('content_type', 'unknown')}"
115
+ )
116
+ return f"Cached: NO\nURL: {info['url']}"
117
+
118
+
119
+ @tool
120
+ def get_usage() -> str:
121
+ """Get current month's screenshot usage statistics including plan, used, limit, and remaining credits."""
122
+ snap = _client()
123
+ try:
124
+ usage = snap.usage()
125
+ finally:
126
+ snap.close()
127
+
128
+ return (
129
+ f"Plan: {usage['plan']}\n"
130
+ f"Used: {usage['used']}\n"
131
+ f"Limit: {usage['limit']}\n"
132
+ f"Remaining: {usage['remaining']}\n"
133
+ f"Period: {usage['period']}"
134
+ )
135
+
136
+
137
+ __all__ = ["take_screenshot", "check_cache", "get_usage"]
@@ -0,0 +1,88 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-snaprender
3
+ Version: 0.1.0
4
+ Summary: LangChain tools for SnapRender Screenshot API — capture websites as PNG, JPEG, WebP, or PDF
5
+ Author-email: SnapRender <support@snap-render.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://snap-render.com
8
+ Project-URL: Repository, https://github.com/User0856/snaprender-integrations/tree/main/langchain
9
+ Project-URL: Documentation, https://snap-render.com
10
+ Project-URL: Bug Tracker, https://github.com/User0856/snaprender-integrations/issues
11
+ Keywords: langchain,langchain-tool,screenshot,web-capture,snaprender,ai-agent,llm-tool
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: langchain-core>=0.2.0
25
+ Requires-Dist: snaprender>=0.2.0
26
+
27
+ # langchain-snaprender
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/langchain-snaprender)](https://pypi.org/project/langchain-snaprender/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](../LICENSE)
31
+
32
+ LangChain / LangGraph tools for [SnapRender Screenshot API](https://snap-render.com). Lets your LangChain agents capture website screenshots as PNG, JPEG, WebP, or PDF.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install langchain-snaprender
38
+ ```
39
+
40
+ ## Setup
41
+
42
+ ```bash
43
+ export SNAPRENDER_API_KEY="sk_live_your_key_here"
44
+ ```
45
+
46
+ Get a free key at [app.snap-render.com](https://app.snap-render.com/auth/signup) — 50 screenshots/month, no credit card.
47
+
48
+ ## Usage
49
+
50
+ ```python
51
+ from langchain_snaprender import take_screenshot, check_cache, get_usage
52
+
53
+ # Use as standalone tools
54
+ result = take_screenshot.invoke({"url": "https://example.com"})
55
+ print(result)
56
+
57
+ # Or bind to a LangChain agent
58
+ from langchain_openai import ChatOpenAI
59
+ from langgraph.prebuilt import create_react_agent
60
+
61
+ llm = ChatOpenAI(model="gpt-4o")
62
+ tools = [take_screenshot, check_cache, get_usage]
63
+ agent = create_react_agent(llm, tools)
64
+
65
+ response = agent.invoke({"messages": [("user", "Take a screenshot of stripe.com")]})
66
+ ```
67
+
68
+ ## Tools
69
+
70
+ ### `take_screenshot`
71
+
72
+ Capture any website as PNG, JPEG, WebP, or PDF.
73
+
74
+ Parameters: `url`, `format`, `full_page`, `dark_mode`, `block_ads`, `block_cookie_banners`, `device`, `width`, `height`
75
+
76
+ ### `check_cache`
77
+
78
+ Check if a screenshot is cached (free, doesn't count against quota).
79
+
80
+ Parameters: `url`, `format`
81
+
82
+ ### `get_usage`
83
+
84
+ Get current month's usage stats.
85
+
86
+ ## License
87
+
88
+ MIT
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ langchain_snaprender/__init__.py
4
+ langchain_snaprender.egg-info/PKG-INFO
5
+ langchain_snaprender.egg-info/SOURCES.txt
6
+ langchain_snaprender.egg-info/dependency_links.txt
7
+ langchain_snaprender.egg-info/requires.txt
8
+ langchain_snaprender.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ langchain-core>=0.2.0
2
+ snaprender>=0.2.0
@@ -0,0 +1 @@
1
+ langchain_snaprender
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "langchain-snaprender"
7
+ version = "0.1.0"
8
+ description = "LangChain tools for SnapRender Screenshot API — capture websites as PNG, JPEG, WebP, or PDF"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "SnapRender", email = "support@snap-render.com" },
14
+ ]
15
+ keywords = [
16
+ "langchain",
17
+ "langchain-tool",
18
+ "screenshot",
19
+ "web-capture",
20
+ "snaprender",
21
+ "ai-agent",
22
+ "llm-tool",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Intended Audience :: Developers",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3.9",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Topic :: Software Development :: Libraries",
34
+ "Topic :: Internet :: WWW/HTTP",
35
+ ]
36
+ dependencies = [
37
+ "langchain-core>=0.2.0",
38
+ "snaprender>=0.2.0",
39
+ ]
40
+
41
+ [project.urls]
42
+ Homepage = "https://snap-render.com"
43
+ Repository = "https://github.com/User0856/snaprender-integrations/tree/main/langchain"
44
+ Documentation = "https://snap-render.com"
45
+ "Bug Tracker" = "https://github.com/User0856/snaprender-integrations/issues"
46
+
47
+ [tool.setuptools.packages.find]
48
+ include = ["langchain_snaprender*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+