filoo-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,21 @@
1
+ node_modules/
2
+ dist/
3
+ .wrangler/
4
+ .env
5
+ .env.local
6
+ .env.*.local
7
+ *.log
8
+ .DS_Store
9
+ public/app.css
10
+ .idea/
11
+ .vscode/
12
+ coverage/
13
+ # SDK build artifacts
14
+ sdk/typescript/dist/
15
+ sdk/typescript/node_modules/
16
+ sdk/typescript/package-lock.json
17
+ sdk/python/dist/
18
+ sdk/python/build/
19
+ sdk/python/*.egg-info/
20
+ sdk/python/__pycache__/
21
+ sdk/python/filoo/__pycache__/
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: filoo-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the Filoo URL shortener API.
5
+ Project-URL: Homepage, https://filoo.app/api
6
+ Project-URL: Repository, https://github.com/jrlprost/filooapp
7
+ Author: Filoo
8
+ License: MIT
9
+ Keywords: filoo,qr-code,url-shortener
10
+ Requires-Python: >=3.9
11
+ Requires-Dist: httpx>=0.27
12
+ Description-Content-Type: text/markdown
13
+
14
+ # filoo-sdk
15
+
16
+ Official Python SDK for the [Filoo](https://filoo.app) URL shortener API.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ pip install filoo-sdk
22
+ ```
23
+
24
+ ## Quick start
25
+
26
+ ```python
27
+ from filoo import Filoo
28
+ import os
29
+
30
+ with Filoo(api_key=os.environ["FILOO_KEY"]) as filoo:
31
+ link = filoo.links.create(
32
+ destination="https://example.com/long-url",
33
+ username="myname",
34
+ slug="campaign-1",
35
+ )
36
+ print(link["short_url"]) # → https://filoo.app/myname/campaign-1
37
+ ```
38
+
39
+ ## Available methods
40
+
41
+ - `filoo.me()`
42
+ - `filoo.usage()`
43
+ - `filoo.usernames()`
44
+ - `filoo.links.create(destination, ...)`
45
+ - `filoo.links.list(limit=, cursor=)`
46
+ - `filoo.links.get(code)`
47
+ - `filoo.links.update(code, **fields)`
48
+ - `filoo.links.delete(code)`
49
+ - `filoo.links.stats(code)`
50
+
51
+ ## Tier requirement
52
+
53
+ The Filoo API is available on **Pro** (€9/month, 100 req/min) and **Agents** (€29/month, 1000 req/min) plans. Get a key at [filoo.app/dashboard/api-keys](https://filoo.app/dashboard/api-keys).
54
+
55
+ ## Errors
56
+
57
+ `FilooError` is raised on non-2xx responses. Check `error.status` and `error.body`.
58
+
59
+ ```python
60
+ from filoo import Filoo, FilooError
61
+
62
+ try:
63
+ filoo.links.create(destination="...")
64
+ except FilooError as e:
65
+ if e.status == 429:
66
+ print("Rate limited, retry later")
67
+ ```
68
+
69
+ ## License
70
+
71
+ MIT
@@ -0,0 +1,58 @@
1
+ # filoo-sdk
2
+
3
+ Official Python SDK for the [Filoo](https://filoo.app) URL shortener API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install filoo-sdk
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```python
14
+ from filoo import Filoo
15
+ import os
16
+
17
+ with Filoo(api_key=os.environ["FILOO_KEY"]) as filoo:
18
+ link = filoo.links.create(
19
+ destination="https://example.com/long-url",
20
+ username="myname",
21
+ slug="campaign-1",
22
+ )
23
+ print(link["short_url"]) # → https://filoo.app/myname/campaign-1
24
+ ```
25
+
26
+ ## Available methods
27
+
28
+ - `filoo.me()`
29
+ - `filoo.usage()`
30
+ - `filoo.usernames()`
31
+ - `filoo.links.create(destination, ...)`
32
+ - `filoo.links.list(limit=, cursor=)`
33
+ - `filoo.links.get(code)`
34
+ - `filoo.links.update(code, **fields)`
35
+ - `filoo.links.delete(code)`
36
+ - `filoo.links.stats(code)`
37
+
38
+ ## Tier requirement
39
+
40
+ The Filoo API is available on **Pro** (€9/month, 100 req/min) and **Agents** (€29/month, 1000 req/min) plans. Get a key at [filoo.app/dashboard/api-keys](https://filoo.app/dashboard/api-keys).
41
+
42
+ ## Errors
43
+
44
+ `FilooError` is raised on non-2xx responses. Check `error.status` and `error.body`.
45
+
46
+ ```python
47
+ from filoo import Filoo, FilooError
48
+
49
+ try:
50
+ filoo.links.create(destination="...")
51
+ except FilooError as e:
52
+ if e.status == 429:
53
+ print("Rate limited, retry later")
54
+ ```
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1,144 @@
1
+ """Official Python SDK for the Filoo URL shortener API.
2
+
3
+ Usage:
4
+ from filoo import Filoo
5
+ import os
6
+
7
+ filoo = Filoo(api_key=os.environ["FILOO_KEY"])
8
+ link = filoo.links.create(
9
+ destination="https://example.com",
10
+ username="myname",
11
+ slug="campaign-1",
12
+ )
13
+ print(link["short_url"])
14
+ """
15
+
16
+ from typing import Any, Optional
17
+
18
+ import httpx
19
+
20
+
21
+ __version__ = "0.1.0"
22
+
23
+
24
+ class FilooError(Exception):
25
+ """Raised on non-2xx HTTP responses from the Filoo API."""
26
+
27
+ def __init__(self, status: int, body: str):
28
+ self.status = status
29
+ self.body = body
30
+ super().__init__(f"Filoo API {status}: {body}")
31
+
32
+
33
+ class Filoo:
34
+ """Filoo API client.
35
+
36
+ Args:
37
+ api_key: A Filoo API key with prefix `flo_live_`. Get one at
38
+ https://filoo.app/dashboard/api-keys (Pro or Agents tier required).
39
+ base_url: Override for testing.
40
+ timeout: HTTPX timeout in seconds (default 30).
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ api_key: str,
46
+ base_url: str = "https://filoo.app",
47
+ timeout: float = 30.0,
48
+ ):
49
+ if not api_key:
50
+ raise ValueError("api_key is required")
51
+ self._client = httpx.Client(
52
+ base_url=base_url,
53
+ headers={"Authorization": f"Bearer {api_key}"},
54
+ timeout=timeout,
55
+ )
56
+ self.links = LinksAPI(self._client)
57
+
58
+ def me(self) -> dict[str, Any]:
59
+ return self._get("/api/v1/me")
60
+
61
+ def usage(self) -> dict[str, Any]:
62
+ return self._get("/api/v1/usage")
63
+
64
+ def usernames(self) -> dict[str, Any]:
65
+ return self._get("/api/v1/usernames")
66
+
67
+ def close(self) -> None:
68
+ self._client.close()
69
+
70
+ def __enter__(self) -> "Filoo":
71
+ return self
72
+
73
+ def __exit__(self, *_: Any) -> None:
74
+ self.close()
75
+
76
+ def _get(self, path: str) -> dict[str, Any]:
77
+ r = self._client.get(path)
78
+ if not r.is_success:
79
+ raise FilooError(r.status_code, r.text)
80
+ return r.json()
81
+
82
+
83
+ class LinksAPI:
84
+ def __init__(self, client: httpx.Client):
85
+ self._c = client
86
+
87
+ def create(
88
+ self,
89
+ destination: str,
90
+ *,
91
+ username: Optional[str] = None,
92
+ slug: Optional[str] = None,
93
+ label: Optional[str] = None,
94
+ show_on_profile: bool = False,
95
+ ) -> dict[str, Any]:
96
+ body: dict[str, Any] = {"destination": destination}
97
+ if username is not None:
98
+ body["username"] = username
99
+ if slug is not None:
100
+ body["slug"] = slug
101
+ if label is not None:
102
+ body["label"] = label
103
+ if show_on_profile:
104
+ body["show_on_profile"] = True
105
+ r = self._c.post("/api/v1/links", json=body)
106
+ if not r.is_success:
107
+ raise FilooError(r.status_code, r.text)
108
+ return r.json()
109
+
110
+ def list(self, *, limit: int = 20, cursor: Optional[str] = None) -> dict[str, Any]:
111
+ params: dict[str, Any] = {"limit": limit}
112
+ if cursor:
113
+ params["cursor"] = cursor
114
+ r = self._c.get("/api/v1/links", params=params)
115
+ if not r.is_success:
116
+ raise FilooError(r.status_code, r.text)
117
+ return r.json()
118
+
119
+ def get(self, code: str) -> dict[str, Any]:
120
+ r = self._c.get(f"/api/v1/links/{code}")
121
+ if not r.is_success:
122
+ raise FilooError(r.status_code, r.text)
123
+ return r.json()
124
+
125
+ def update(self, code: str, **fields: Any) -> dict[str, Any]:
126
+ r = self._c.patch(f"/api/v1/links/{code}", json=fields)
127
+ if not r.is_success:
128
+ raise FilooError(r.status_code, r.text)
129
+ return r.json()
130
+
131
+ def delete(self, code: str) -> dict[str, Any]:
132
+ r = self._c.delete(f"/api/v1/links/{code}")
133
+ if not r.is_success:
134
+ raise FilooError(r.status_code, r.text)
135
+ return r.json()
136
+
137
+ def stats(self, code: str) -> dict[str, Any]:
138
+ r = self._c.get(f"/api/v1/links/{code}/stats")
139
+ if not r.is_success:
140
+ raise FilooError(r.status_code, r.text)
141
+ return r.json()
142
+
143
+
144
+ __all__ = ["Filoo", "FilooError"]
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "filoo-sdk"
3
+ version = "0.1.0"
4
+ description = "Official Python SDK for the Filoo URL shortener API."
5
+ authors = [{ name = "Filoo" }]
6
+ license = { text = "MIT" }
7
+ readme = "README.md"
8
+ requires-python = ">=3.9"
9
+ dependencies = ["httpx>=0.27"]
10
+ keywords = ["filoo", "url-shortener", "qr-code"]
11
+
12
+ [project.urls]
13
+ Homepage = "https://filoo.app/api"
14
+ Repository = "https://github.com/jrlprost/filooapp"
15
+
16
+ [build-system]
17
+ requires = ["hatchling"]
18
+ build-backend = "hatchling.build"
19
+
20
+ [tool.hatch.build.targets.wheel]
21
+ packages = ["filoo"]