folio-sdk 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,44 @@
1
+ # dependencies
2
+ /node_modules
3
+ /mcp/node_modules
4
+ /.pnp
5
+ .pnp.js
6
+ .yarn/install-state.gz
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # next.js
12
+ /.next/
13
+ /out/
14
+
15
+ # production
16
+ /build
17
+
18
+ # misc
19
+ .DS_Store
20
+ *.pem
21
+
22
+ # debug
23
+ npm-debug.log*
24
+ yarn-debug.log*
25
+ yarn-error.log*
26
+
27
+ # local env files
28
+ .env
29
+ .env.local
30
+ .env.development.local
31
+ .env.test.local
32
+ .env.production.local
33
+
34
+ # vercel
35
+ .vercel
36
+
37
+ # typescript
38
+ *.tsbuildinfo
39
+ next-env.d.ts
40
+
41
+ # prisma
42
+ *.db
43
+ *.db-journal
44
+ sdk/python/dist/
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: folio-sdk
3
+ Version: 0.1.0
4
+ Summary: Publish HTML reports as shareable, hosted URLs — Folio Python SDK
5
+ Project-URL: Homepage, https://folio.ac
6
+ Project-URL: Documentation, https://folio.ac/docs
7
+ License: MIT
8
+ Keywords: agents,ai,folio,html,publish,reports
9
+ Requires-Python: >=3.8
10
+ Requires-Dist: requests>=2.20
11
+ Description-Content-Type: text/markdown
12
+
13
+ # folio-sdk
14
+
15
+ Publish HTML reports as shareable, hosted URLs — [Folio](https://folio.ac) Python SDK.
16
+
17
+ ```bash
18
+ pip install folio-sdk
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```python
24
+ import folio
25
+
26
+ folio.configure("fol_your_key_here") # or set FOLIO_API_KEY env var
27
+
28
+ url = folio.publish(html, title="Q2 Analysis")
29
+ print(url) # → https://folio.ac/r/abc123
30
+ ```
31
+
32
+ Get your API key at [folio.ac/dashboard](https://folio.ac/dashboard).
33
+
34
+ ## Options
35
+
36
+ ```python
37
+ url = folio.publish(
38
+ html,
39
+ title="Q2 Revenue",
40
+ expires_in_days=30, # 7 | 14 | 30 | 90 (default: 7)
41
+ password="secret", # optional gate
42
+ custom_slug="q2-rev", # → folio.ac/you/r/q2-rev
43
+ )
44
+ ```
45
+
46
+ ## Agent / LLM usage
47
+
48
+ ```python
49
+ import anthropic, folio
50
+
51
+ folio.configure("fol_your_key_here")
52
+ client = anthropic.Anthropic()
53
+
54
+ msg = client.messages.create(
55
+ model="claude-opus-4-7",
56
+ max_tokens=8096,
57
+ messages=[{"role": "user", "content": "Analyse this data and return a full HTML report with charts."}],
58
+ )
59
+
60
+ url = folio.publish(msg.content[0].text, title="Analysis")
61
+ print(f"Report: {url}")
62
+ ```
63
+
64
+ ## Links
65
+
66
+ - [Docs](https://folio.ac/docs)
67
+ - [Dashboard](https://folio.ac/dashboard)
@@ -0,0 +1,55 @@
1
+ # folio-sdk
2
+
3
+ Publish HTML reports as shareable, hosted URLs — [Folio](https://folio.ac) Python SDK.
4
+
5
+ ```bash
6
+ pip install folio-sdk
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ ```python
12
+ import folio
13
+
14
+ folio.configure("fol_your_key_here") # or set FOLIO_API_KEY env var
15
+
16
+ url = folio.publish(html, title="Q2 Analysis")
17
+ print(url) # → https://folio.ac/r/abc123
18
+ ```
19
+
20
+ Get your API key at [folio.ac/dashboard](https://folio.ac/dashboard).
21
+
22
+ ## Options
23
+
24
+ ```python
25
+ url = folio.publish(
26
+ html,
27
+ title="Q2 Revenue",
28
+ expires_in_days=30, # 7 | 14 | 30 | 90 (default: 7)
29
+ password="secret", # optional gate
30
+ custom_slug="q2-rev", # → folio.ac/you/r/q2-rev
31
+ )
32
+ ```
33
+
34
+ ## Agent / LLM usage
35
+
36
+ ```python
37
+ import anthropic, folio
38
+
39
+ folio.configure("fol_your_key_here")
40
+ client = anthropic.Anthropic()
41
+
42
+ msg = client.messages.create(
43
+ model="claude-opus-4-7",
44
+ max_tokens=8096,
45
+ messages=[{"role": "user", "content": "Analyse this data and return a full HTML report with charts."}],
46
+ )
47
+
48
+ url = folio.publish(msg.content[0].text, title="Analysis")
49
+ print(f"Report: {url}")
50
+ ```
51
+
52
+ ## Links
53
+
54
+ - [Docs](https://folio.ac/docs)
55
+ - [Dashboard](https://folio.ac/dashboard)
@@ -0,0 +1,79 @@
1
+ """Folio SDK — publish HTML reports as shareable, hosted URLs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Optional
7
+
8
+ __version__ = "0.1.0"
9
+ __all__ = ["configure", "publish"]
10
+
11
+ _BASE_URL = "https://folio.ac"
12
+ _api_key: Optional[str] = None
13
+
14
+
15
+ def configure(api_key: str, *, base_url: str = _BASE_URL) -> None:
16
+ """Set the API key for all subsequent publish() calls.
17
+
18
+ Args:
19
+ api_key: Your Folio API key (starts with fol_). Copy from folio.ac/dashboard.
20
+ base_url: Override the Folio base URL (useful for self-hosted instances).
21
+ """
22
+ global _api_key, _BASE_URL
23
+ _api_key = api_key
24
+ _BASE_URL = base_url.rstrip("/")
25
+
26
+
27
+ def publish(
28
+ html: str,
29
+ *,
30
+ title: str = "",
31
+ expires_in_days: int = 7,
32
+ password: str = "",
33
+ custom_slug: str = "",
34
+ api_key: Optional[str] = None,
35
+ ) -> str:
36
+ """Publish an HTML report to Folio and return the shareable URL.
37
+
38
+ Args:
39
+ html: Complete HTML document to publish. Max 2 MB.
40
+ title: Human-readable title shown in the report header and dashboard.
41
+ expires_in_days: How long the report stays live. One of 7, 14, 30, 90.
42
+ password: Optional password to gate the report.
43
+ custom_slug: Custom URL path (e.g. "q2-revenue" → folio.ac/you/r/q2-revenue).
44
+ Requires a claimed username and a valid API key.
45
+ api_key: Override the key set by configure(). Also reads FOLIO_API_KEY env var.
46
+
47
+ Returns:
48
+ The shareable URL, e.g. "https://folio.ac/r/abc123".
49
+
50
+ Raises:
51
+ ImportError: If the 'requests' package is not installed.
52
+ requests.HTTPError: If the API returns a non-2xx response.
53
+ """
54
+ try:
55
+ import requests
56
+ except ImportError as exc:
57
+ raise ImportError(
58
+ "folio requires the 'requests' package. Install it with: pip install requests"
59
+ ) from exc
60
+
61
+ key = api_key or _api_key or os.environ.get("FOLIO_API_KEY")
62
+ headers: dict[str, str] = {"Content-Type": "application/json"}
63
+ if key:
64
+ headers["x-api-key"] = key
65
+
66
+ payload: dict[str, object] = {"html": html}
67
+ if title:
68
+ payload["title"] = title
69
+ if expires_in_days != 7:
70
+ payload["expiresInDays"] = expires_in_days
71
+ if password:
72
+ payload["password"] = password
73
+ if custom_slug:
74
+ payload["customSlug"] = custom_slug
75
+
76
+ base = _BASE_URL
77
+ r = requests.post(f"{base}/api/publish", json=payload, headers=headers, timeout=30)
78
+ r.raise_for_status()
79
+ return r.json()["url"]
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "folio-sdk"
7
+ version = "0.1.0"
8
+ description = "Publish HTML reports as shareable, hosted URLs — Folio Python SDK"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ keywords = ["folio", "reports", "publish", "html", "ai", "agents"]
13
+ dependencies = ["requests>=2.20"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://folio.ac"
17
+ Documentation = "https://folio.ac/docs"
18
+
19
+ [tool.hatch.build.targets.wheel]
20
+ packages = ["folio"]