folio-sdk 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.
- folio/__init__.py +79 -0
- folio_sdk-0.1.0.dist-info/METADATA +67 -0
- folio_sdk-0.1.0.dist-info/RECORD +4 -0
- folio_sdk-0.1.0.dist-info/WHEEL +4 -0
folio/__init__.py
ADDED
|
@@ -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,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,4 @@
|
|
|
1
|
+
folio/__init__.py,sha256=dmG3TFmR6_8eqe-2Jxkr0GzDuVObG07V-a3n-x6u21M,2519
|
|
2
|
+
folio_sdk-0.1.0.dist-info/METADATA,sha256=Q3uuIYCOdVfOEbWOLSNUJAy31ZJqMmE5Q9PtNl_XTwQ,1510
|
|
3
|
+
folio_sdk-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
4
|
+
folio_sdk-0.1.0.dist-info/RECORD,,
|