roast-api 1.4.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,243 @@
1
+ Metadata-Version: 2.4
2
+ Name: roast-api
3
+ Version: 1.4.0
4
+ Summary: A Python client for RaaS — Roast as a Service. CDN-served static JSON API for developer roasts.
5
+ Author-email: Maizied <mdshuvo40@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://maijied.github.io/roast-as-a-service/
8
+ Project-URL: Repository, https://github.com/Maijied/roast-as-a-service
9
+ Keywords: roast,api,developer,humor,fun,cdn
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: requests>=2.20.0
18
+
19
+ # 🥵 Roast as a Service (RaaS)
20
+
21
+ <p align="center">
22
+ <img src="https://maijied.github.io/roast-as-a-service/assets/logo.png" width="128" alt="RaaS Logo" />
23
+ </p>
24
+ <p align="center">
25
+ <img src="https://hits.sh/maijied.github.io/roast-as-a-service.svg?view=today-total&style=flat-square&label=visitors&color=ec4899&labelColor=020617" alt="Visitor Count" />
26
+ <a href="https://www.npmjs.com/package/roast-api"><img src="https://img.shields.io/npm/v/roast-api?style=flat-square&color=f97316&labelColor=020617" alt="npm version" /></a>
27
+ <a href="https://www.npmjs.com/package/roast-api"><img src="https://img.shields.io/npm/dm/roast-api?style=flat-square&color=ec4899&labelColor=020617" alt="npm downloads" /></a>
28
+ <a href="https://pypi.org/project/roast-api/"><img src="https://img.shields.io/pypi/v/roast-api?style=flat-square&color=3b82f6&labelColor=020617" alt="PyPI version" /></a>
29
+ <a href="https://packagist.org/packages/maizied/roast-api"><img src="https://img.shields.io/packagist/v/maizied/roast-api?style=flat-square&color=10b981&labelColor=020617" alt="Packagist version" /></a>
30
+ <a href="https://github.com/Maijied/roast-as-a-service/actions/workflows/deploy.yml"><img src="https://github.com/Maijied/roast-as-a-service/actions/workflows/deploy.yml/badge.svg" alt="Deploy to GitHub Pages" /></a>
31
+ </p>
32
+
33
+ Random developer roasts, delivered via a blazing‑fast static API on GitHub Pages. Plug it into your apps, bots, terminals, or CI logs when “nice error messages” just aren’t enough.
34
+
35
+ > **Part of the [Lorapok Ecosystem](https://github.com/Maijied/lorapok)** — Building the future of AI-driven developer tools. 🐛
36
+
37
+ ---
38
+
39
+ ## 🚀 What is RaaS?
40
+
41
+ Roast as a Service is a GitHub‑hosted, CDN‑backed JSON API that returns developer‑themed roasts in English and Bangla.
42
+ It’s completely static (no servers), but feels dynamic thanks to a smart client SDK that shards, caches, and randomly selects roasts on the fly.
43
+
44
+ Use it when you want your:
45
+
46
+ - CLI tools to roast the user on failure.
47
+ - CI pipeline to roast you when tests fail.
48
+ - Discord/Slack bots to respond with spicy dev insults.
49
+ - Portfolio or landing page to show random roasts on each visit.
50
+
51
+ ---
52
+
53
+ ## 🌐 Live Service
54
+
55
+ - **Website:** https://maijied.github.io/roast-as-a-service/
56
+ - **API Base Path:** https://maijied.github.io/roast-as-a-service/api/
57
+
58
+ ---
59
+
60
+ ## ⚡ Quick Start
61
+
62
+ ### 1. Install via npm
63
+ ```bash
64
+ npm install roast-api
65
+ # or
66
+ npm install @maizied/roast-as-a-service
67
+ ```
68
+
69
+ ```javascript
70
+ const RaaS = require('roast-api');
71
+
72
+ RaaS.getRandomRoast({ lang: 'en' })
73
+ .then(r => console.log(r.text));
74
+ ```
75
+
76
+ ### 2. Script Include (Browser)
77
+ Load the client SDK directly in your browser:
78
+
79
+ ```html
80
+ <script src="https://maijied.github.io/roast-as-a-service/api/client.js"></script>
81
+
82
+ <script>
83
+ // Fetch a random Bangla roast with intensity 2
84
+ RaaS.getRandomRoast({ lang: 'bn', intensity: 2 })
85
+ .then(r => console.log(r.text));
86
+ </script>
87
+ ```
88
+
89
+ ### 3. Install via Composer (PHP)
90
+ ```bash
91
+ composer require maizied/roast-api
92
+ ```
93
+
94
+ ```php
95
+ use Maizied\RoastApi\RaaS;
96
+
97
+ $roast = RaaS::getRandomRoast(['lang' => 'en']);
98
+ echo $roast['text'];
99
+ ```
100
+
101
+ ### 4. Install via pip (Python)
102
+ ```bash
103
+ pip install roast-api
104
+ ```
105
+
106
+ ```python
107
+ from roast_api import get_random_roast
108
+
109
+ roast = get_random_roast(lang='en')
110
+ print(roast['text'])
111
+ ```
112
+
113
+ ### 5. Direct Fetch
114
+ Or just fetch the JSON files directly:
115
+
116
+ ```javascript
117
+ fetch('https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json')
118
+ .then(res => res.json())
119
+ .then(data => {
120
+ const list = data.roasts;
121
+ const pick = list[Math.floor(Math.random() * list.length)];
122
+ console.log(pick.text);
123
+ });
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 🛠 How it works
129
+
130
+ RaaS exposes sharded JSON datasets over GitHub Pages, then a tiny client SDK picks, filters, and caches roasts in the browser, giving you an API‑like experience with pure static hosting.
131
+
132
+ - **Static API**: Roasts are stored in language‑specific shards (`en`, `bn`) and served as JSON over GitHub Pages’ global CDN for low TTFB.
133
+ - **Smart client**: The bundled client fetches a small shard, caches it, and returns random roasts with optional intensity and length filters.
134
+ - **Zero ops**: No servers, no cold starts, no scaling issues. Push to main, let Pages deploy and cache everything at the edge.
135
+
136
+ ---
137
+
138
+ ## 📦 API Overview
139
+
140
+ This is a **static** API: data comes from versioned JSON files served over CDN, and a lightweight JS client handles randomness, filtering and caching in the browser.
141
+
142
+ ### Endpoints (static JSON)
143
+
144
+ - **Manifest:**
145
+ `GET https://maijied.github.io/roast-as-a-service/api/manifest.json`
146
+
147
+ - **English Shard #1:**
148
+ `GET https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json`
149
+
150
+ - **Bangla Shard #1:**
151
+ `GET https://maijied.github.io/roast-as-a-service/api/bn/roasts-bn-1.json`
152
+
153
+ ### Example Response Structure
154
+ Each shard looks like:
155
+
156
+ ```json
157
+ {
158
+ "language": "en",
159
+ "shard": 1,
160
+ "total_shards": 5,
161
+ "count": 300,
162
+ "tags": ["dev", "general"],
163
+ "roasts": [
164
+ {
165
+ "id": "en-1-1",
166
+ "text": "Your codebase looks like it was written during a live outage.",
167
+ "intensity": 2,
168
+ "length": 61
169
+ }
170
+ ]
171
+ }
172
+ ```
173
+
174
+ ### Usage Example (curl + jq)
175
+ ```bash
176
+ curl -s https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json \
177
+ | jq '.roasts[0].text'
178
+ ```
179
+
180
+ ---
181
+
182
+ ## 🧬 Why this architecture is “state of the art”
183
+
184
+ Roast as a Service is intentionally built as a **static API** on top of GitHub Pages and a CDN, instead of a traditional backend. For this use case (serving pre‑made content), this gives you the same “API experience” with less cost, less complexity, and better global latency.
185
+
186
+ Key points:
187
+
188
+ - **Static JSON over CDN**
189
+ All responses are just versioned JSON files served by GitHub Pages’ global edge network, which is highly cache‑friendly and extremely fast for read‑heavy traffic.
190
+
191
+ - **Zero backend, zero cold starts**
192
+ There is no application server to boot, scale, or warm up. Every request hits static content that can be served from edge cache with minimal TTFB.
193
+
194
+ - **Sharded data layout**
195
+ Roasts are split into language‑specific shards (e.g. `en/roasts-en-1.json`) so each response stays small and cacheable even if the total dataset becomes large.
196
+
197
+ - **Client‑side selection and filtering**
198
+ A tiny SDK handles randomness, intensity filters, and length limits in the client, so the “API” stays read‑only and ultra fast instead of computing on every request.
199
+
200
+ - **Edge‑friendly cache behavior**
201
+ Because the content is static and not personalized, CDN nodes can cache responses aggressively without worrying about user‑specific data. That’s exactly what CDNs are optimized for.
202
+
203
+ - **Version‑controlled API**
204
+ All JSON lives in Git; you can roll back, branch, and review changes like any other codebase while GitHub Pages redeploys and re‑caches automatically.
205
+
206
+ This combination (static JSON + sharding + client‑side logic + CDN caching) is effectively the “fast path” that many dynamic APIs end up approximating with layers of caching—here it’s the default.
207
+
208
+ ## ⚡ Performance & Benchmarks
209
+
210
+ RaaS is built for extreme speed and low overhead. By sharding data and relying on CDN edge caching + local browser caching, it achieves massive throughput.
211
+
212
+ **Latest Benchmark Results:**
213
+ - **Requests/sec**: ~2,000 (Tested with 5,000 total requests)
214
+ - **Success Rate**: 100% (Zero failures under high concurrency)
215
+ - **Avg Latency**: ~58ms
216
+ - **P95 Latency**: ~159ms
217
+ - **Cache Efficiency**: 90%+ (Manifest and shard reuse)
218
+
219
+ > [!TIP]
220
+ > This "Static API" approach beats the latency of traditional dynamic APIs by removing backend processing, cold starts, and database queries from the request path.
221
+
222
+ ---
223
+
224
+ ## 🐛 More from Lorapok
225
+
226
+ RaaS is a proud member of the **Lorapok** family. Check out our other tools:
227
+
228
+ - **[Lorapok CLI](https://github.com/Maijied/lorapok):** The intelligent AI agent framework for developers.
229
+ - **[Lorapok Media Player](https://github.com/Maijied/Lorapok_Media_Player):** A modern, feature-rich media player built for power users.
230
+
231
+ ---
232
+
233
+ ## 👤 Author
234
+
235
+ **Maizied**
236
+ 📧 [mdshuvo40@gmail.com](mailto:mdshuvo40@gmail.com)
237
+ 🔗 [GitHub](https://github.com/Maijied) · [npm](https://www.npmjs.com/~maizied)
238
+
239
+ ---
240
+
241
+ ## 📄 License
242
+
243
+ MIT © Maizied
@@ -0,0 +1,225 @@
1
+ # 🥵 Roast as a Service (RaaS)
2
+
3
+ <p align="center">
4
+ <img src="https://maijied.github.io/roast-as-a-service/assets/logo.png" width="128" alt="RaaS Logo" />
5
+ </p>
6
+ <p align="center">
7
+ <img src="https://hits.sh/maijied.github.io/roast-as-a-service.svg?view=today-total&style=flat-square&label=visitors&color=ec4899&labelColor=020617" alt="Visitor Count" />
8
+ <a href="https://www.npmjs.com/package/roast-api"><img src="https://img.shields.io/npm/v/roast-api?style=flat-square&color=f97316&labelColor=020617" alt="npm version" /></a>
9
+ <a href="https://www.npmjs.com/package/roast-api"><img src="https://img.shields.io/npm/dm/roast-api?style=flat-square&color=ec4899&labelColor=020617" alt="npm downloads" /></a>
10
+ <a href="https://pypi.org/project/roast-api/"><img src="https://img.shields.io/pypi/v/roast-api?style=flat-square&color=3b82f6&labelColor=020617" alt="PyPI version" /></a>
11
+ <a href="https://packagist.org/packages/maizied/roast-api"><img src="https://img.shields.io/packagist/v/maizied/roast-api?style=flat-square&color=10b981&labelColor=020617" alt="Packagist version" /></a>
12
+ <a href="https://github.com/Maijied/roast-as-a-service/actions/workflows/deploy.yml"><img src="https://github.com/Maijied/roast-as-a-service/actions/workflows/deploy.yml/badge.svg" alt="Deploy to GitHub Pages" /></a>
13
+ </p>
14
+
15
+ Random developer roasts, delivered via a blazing‑fast static API on GitHub Pages. Plug it into your apps, bots, terminals, or CI logs when “nice error messages” just aren’t enough.
16
+
17
+ > **Part of the [Lorapok Ecosystem](https://github.com/Maijied/lorapok)** — Building the future of AI-driven developer tools. 🐛
18
+
19
+ ---
20
+
21
+ ## 🚀 What is RaaS?
22
+
23
+ Roast as a Service is a GitHub‑hosted, CDN‑backed JSON API that returns developer‑themed roasts in English and Bangla.
24
+ It’s completely static (no servers), but feels dynamic thanks to a smart client SDK that shards, caches, and randomly selects roasts on the fly.
25
+
26
+ Use it when you want your:
27
+
28
+ - CLI tools to roast the user on failure.
29
+ - CI pipeline to roast you when tests fail.
30
+ - Discord/Slack bots to respond with spicy dev insults.
31
+ - Portfolio or landing page to show random roasts on each visit.
32
+
33
+ ---
34
+
35
+ ## 🌐 Live Service
36
+
37
+ - **Website:** https://maijied.github.io/roast-as-a-service/
38
+ - **API Base Path:** https://maijied.github.io/roast-as-a-service/api/
39
+
40
+ ---
41
+
42
+ ## ⚡ Quick Start
43
+
44
+ ### 1. Install via npm
45
+ ```bash
46
+ npm install roast-api
47
+ # or
48
+ npm install @maizied/roast-as-a-service
49
+ ```
50
+
51
+ ```javascript
52
+ const RaaS = require('roast-api');
53
+
54
+ RaaS.getRandomRoast({ lang: 'en' })
55
+ .then(r => console.log(r.text));
56
+ ```
57
+
58
+ ### 2. Script Include (Browser)
59
+ Load the client SDK directly in your browser:
60
+
61
+ ```html
62
+ <script src="https://maijied.github.io/roast-as-a-service/api/client.js"></script>
63
+
64
+ <script>
65
+ // Fetch a random Bangla roast with intensity 2
66
+ RaaS.getRandomRoast({ lang: 'bn', intensity: 2 })
67
+ .then(r => console.log(r.text));
68
+ </script>
69
+ ```
70
+
71
+ ### 3. Install via Composer (PHP)
72
+ ```bash
73
+ composer require maizied/roast-api
74
+ ```
75
+
76
+ ```php
77
+ use Maizied\RoastApi\RaaS;
78
+
79
+ $roast = RaaS::getRandomRoast(['lang' => 'en']);
80
+ echo $roast['text'];
81
+ ```
82
+
83
+ ### 4. Install via pip (Python)
84
+ ```bash
85
+ pip install roast-api
86
+ ```
87
+
88
+ ```python
89
+ from roast_api import get_random_roast
90
+
91
+ roast = get_random_roast(lang='en')
92
+ print(roast['text'])
93
+ ```
94
+
95
+ ### 5. Direct Fetch
96
+ Or just fetch the JSON files directly:
97
+
98
+ ```javascript
99
+ fetch('https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json')
100
+ .then(res => res.json())
101
+ .then(data => {
102
+ const list = data.roasts;
103
+ const pick = list[Math.floor(Math.random() * list.length)];
104
+ console.log(pick.text);
105
+ });
106
+ ```
107
+
108
+ ---
109
+
110
+ ## 🛠 How it works
111
+
112
+ RaaS exposes sharded JSON datasets over GitHub Pages, then a tiny client SDK picks, filters, and caches roasts in the browser, giving you an API‑like experience with pure static hosting.
113
+
114
+ - **Static API**: Roasts are stored in language‑specific shards (`en`, `bn`) and served as JSON over GitHub Pages’ global CDN for low TTFB.
115
+ - **Smart client**: The bundled client fetches a small shard, caches it, and returns random roasts with optional intensity and length filters.
116
+ - **Zero ops**: No servers, no cold starts, no scaling issues. Push to main, let Pages deploy and cache everything at the edge.
117
+
118
+ ---
119
+
120
+ ## 📦 API Overview
121
+
122
+ This is a **static** API: data comes from versioned JSON files served over CDN, and a lightweight JS client handles randomness, filtering and caching in the browser.
123
+
124
+ ### Endpoints (static JSON)
125
+
126
+ - **Manifest:**
127
+ `GET https://maijied.github.io/roast-as-a-service/api/manifest.json`
128
+
129
+ - **English Shard #1:**
130
+ `GET https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json`
131
+
132
+ - **Bangla Shard #1:**
133
+ `GET https://maijied.github.io/roast-as-a-service/api/bn/roasts-bn-1.json`
134
+
135
+ ### Example Response Structure
136
+ Each shard looks like:
137
+
138
+ ```json
139
+ {
140
+ "language": "en",
141
+ "shard": 1,
142
+ "total_shards": 5,
143
+ "count": 300,
144
+ "tags": ["dev", "general"],
145
+ "roasts": [
146
+ {
147
+ "id": "en-1-1",
148
+ "text": "Your codebase looks like it was written during a live outage.",
149
+ "intensity": 2,
150
+ "length": 61
151
+ }
152
+ ]
153
+ }
154
+ ```
155
+
156
+ ### Usage Example (curl + jq)
157
+ ```bash
158
+ curl -s https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json \
159
+ | jq '.roasts[0].text'
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 🧬 Why this architecture is “state of the art”
165
+
166
+ Roast as a Service is intentionally built as a **static API** on top of GitHub Pages and a CDN, instead of a traditional backend. For this use case (serving pre‑made content), this gives you the same “API experience” with less cost, less complexity, and better global latency.
167
+
168
+ Key points:
169
+
170
+ - **Static JSON over CDN**
171
+ All responses are just versioned JSON files served by GitHub Pages’ global edge network, which is highly cache‑friendly and extremely fast for read‑heavy traffic.
172
+
173
+ - **Zero backend, zero cold starts**
174
+ There is no application server to boot, scale, or warm up. Every request hits static content that can be served from edge cache with minimal TTFB.
175
+
176
+ - **Sharded data layout**
177
+ Roasts are split into language‑specific shards (e.g. `en/roasts-en-1.json`) so each response stays small and cacheable even if the total dataset becomes large.
178
+
179
+ - **Client‑side selection and filtering**
180
+ A tiny SDK handles randomness, intensity filters, and length limits in the client, so the “API” stays read‑only and ultra fast instead of computing on every request.
181
+
182
+ - **Edge‑friendly cache behavior**
183
+ Because the content is static and not personalized, CDN nodes can cache responses aggressively without worrying about user‑specific data. That’s exactly what CDNs are optimized for.
184
+
185
+ - **Version‑controlled API**
186
+ All JSON lives in Git; you can roll back, branch, and review changes like any other codebase while GitHub Pages redeploys and re‑caches automatically.
187
+
188
+ This combination (static JSON + sharding + client‑side logic + CDN caching) is effectively the “fast path” that many dynamic APIs end up approximating with layers of caching—here it’s the default.
189
+
190
+ ## ⚡ Performance & Benchmarks
191
+
192
+ RaaS is built for extreme speed and low overhead. By sharding data and relying on CDN edge caching + local browser caching, it achieves massive throughput.
193
+
194
+ **Latest Benchmark Results:**
195
+ - **Requests/sec**: ~2,000 (Tested with 5,000 total requests)
196
+ - **Success Rate**: 100% (Zero failures under high concurrency)
197
+ - **Avg Latency**: ~58ms
198
+ - **P95 Latency**: ~159ms
199
+ - **Cache Efficiency**: 90%+ (Manifest and shard reuse)
200
+
201
+ > [!TIP]
202
+ > This "Static API" approach beats the latency of traditional dynamic APIs by removing backend processing, cold starts, and database queries from the request path.
203
+
204
+ ---
205
+
206
+ ## 🐛 More from Lorapok
207
+
208
+ RaaS is a proud member of the **Lorapok** family. Check out our other tools:
209
+
210
+ - **[Lorapok CLI](https://github.com/Maijied/lorapok):** The intelligent AI agent framework for developers.
211
+ - **[Lorapok Media Player](https://github.com/Maijied/Lorapok_Media_Player):** A modern, feature-rich media player built for power users.
212
+
213
+ ---
214
+
215
+ ## 👤 Author
216
+
217
+ **Maizied**
218
+ 📧 [mdshuvo40@gmail.com](mailto:mdshuvo40@gmail.com)
219
+ 🔗 [GitHub](https://github.com/Maijied) · [npm](https://www.npmjs.com/~maizied)
220
+
221
+ ---
222
+
223
+ ## 📄 License
224
+
225
+ MIT © Maizied
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "roast-api"
7
+ version = "1.4.0"
8
+ description = "A Python client for RaaS — Roast as a Service. CDN-served static JSON API for developer roasts."
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.7"
12
+ authors = [
13
+ {name = "Maizied", email = "mdshuvo40@gmail.com"}
14
+ ]
15
+ keywords = ["roast", "api", "developer", "humor", "fun", "cdn"]
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ ]
23
+ dependencies = [
24
+ "requests>=2.20.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://maijied.github.io/roast-as-a-service/"
29
+ Repository = "https://github.com/Maijied/roast-as-a-service"
30
+
31
+ [tool.setuptools.packages.find]
32
+ include = ["roast_api*"]
@@ -0,0 +1,29 @@
1
+ """
2
+ RaaS — Roast as a Service Python Client
3
+
4
+ A lightweight Python client for fetching developer roasts from the
5
+ RaaS static JSON API hosted on GitHub Pages.
6
+
7
+ Usage:
8
+ from roast_api import get_random_roast, get_all_roasts
9
+
10
+ roast = get_random_roast(lang='en')
11
+ print(roast['text'])
12
+ """
13
+
14
+ from roast_api.client import (
15
+ get_random_roast,
16
+ get_all_roasts,
17
+ get_manifest,
18
+ get_shard,
19
+ clear_cache,
20
+ )
21
+
22
+ __version__ = "1.4.0"
23
+ __all__ = [
24
+ "get_random_roast",
25
+ "get_all_roasts",
26
+ "get_manifest",
27
+ "get_shard",
28
+ "clear_cache",
29
+ ]
@@ -0,0 +1,89 @@
1
+ """
2
+ RaaS Python Client — core logic.
3
+
4
+ Fetches roasts from the static JSON API on GitHub Pages,
5
+ with in-memory caching and optional filtering.
6
+ """
7
+
8
+ import random
9
+ from typing import Any, Dict, List, Optional
10
+
11
+ import requests
12
+
13
+ BASE_URL = "https://maijied.github.io/roast-as-a-service/api"
14
+
15
+ # In-memory caches
16
+ _manifest_cache: Optional[Dict[str, Any]] = None
17
+ _shard_cache: Dict[str, Dict[str, Any]] = {}
18
+
19
+
20
+ def get_manifest() -> Dict[str, Any]:
21
+ """Fetch and cache the API manifest."""
22
+ global _manifest_cache
23
+ if _manifest_cache is not None:
24
+ return _manifest_cache
25
+
26
+ url = f"{BASE_URL}/manifest.json"
27
+ resp = requests.get(url, timeout=10)
28
+ resp.raise_for_status()
29
+ _manifest_cache = resp.json()
30
+ return _manifest_cache
31
+
32
+
33
+ def get_shard(lang: str = "en", shard: int = 1) -> Dict[str, Any]:
34
+ """Fetch and cache a specific language shard."""
35
+ key = f"{lang}-{shard}"
36
+ if key in _shard_cache:
37
+ return _shard_cache[key]
38
+
39
+ url = f"{BASE_URL}/{lang}/roasts-{lang}-{shard}.json"
40
+ resp = requests.get(url, timeout=10)
41
+ resp.raise_for_status()
42
+ _shard_cache[key] = resp.json()
43
+ return _shard_cache[key]
44
+
45
+
46
+ def get_random_roast(
47
+ lang: str = "en",
48
+ intensity: Optional[int] = None,
49
+ max_length: Optional[int] = None,
50
+ ) -> Dict[str, Any]:
51
+ """
52
+ Get a random roast.
53
+
54
+ Args:
55
+ lang: Language code ('en' or 'bn'). Default: 'en'.
56
+ intensity: Filter by intensity (1–3). Default: None (any).
57
+ max_length: Maximum text length. Default: None (any).
58
+
59
+ Returns:
60
+ A dict with keys: id, text, intensity, length.
61
+
62
+ Raises:
63
+ ValueError: If no roasts match the given filters.
64
+ """
65
+ data = get_shard(lang)
66
+ roasts: List[Dict[str, Any]] = data.get("roasts", [])
67
+
68
+ if intensity is not None:
69
+ roasts = [r for r in roasts if r.get("intensity") == intensity]
70
+ if max_length is not None:
71
+ roasts = [r for r in roasts if r.get("length", 0) <= max_length]
72
+
73
+ if not roasts:
74
+ raise ValueError("No roasts match the given filters.")
75
+
76
+ return random.choice(roasts)
77
+
78
+
79
+ def get_all_roasts(lang: str = "en") -> List[Dict[str, Any]]:
80
+ """Get all roasts for a language."""
81
+ data = get_shard(lang)
82
+ return data.get("roasts", [])
83
+
84
+
85
+ def clear_cache() -> None:
86
+ """Clear the in-memory caches."""
87
+ global _manifest_cache, _shard_cache
88
+ _manifest_cache = None
89
+ _shard_cache = {}
@@ -0,0 +1,243 @@
1
+ Metadata-Version: 2.4
2
+ Name: roast-api
3
+ Version: 1.4.0
4
+ Summary: A Python client for RaaS — Roast as a Service. CDN-served static JSON API for developer roasts.
5
+ Author-email: Maizied <mdshuvo40@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://maijied.github.io/roast-as-a-service/
8
+ Project-URL: Repository, https://github.com/Maijied/roast-as-a-service
9
+ Keywords: roast,api,developer,humor,fun,cdn
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: requests>=2.20.0
18
+
19
+ # 🥵 Roast as a Service (RaaS)
20
+
21
+ <p align="center">
22
+ <img src="https://maijied.github.io/roast-as-a-service/assets/logo.png" width="128" alt="RaaS Logo" />
23
+ </p>
24
+ <p align="center">
25
+ <img src="https://hits.sh/maijied.github.io/roast-as-a-service.svg?view=today-total&style=flat-square&label=visitors&color=ec4899&labelColor=020617" alt="Visitor Count" />
26
+ <a href="https://www.npmjs.com/package/roast-api"><img src="https://img.shields.io/npm/v/roast-api?style=flat-square&color=f97316&labelColor=020617" alt="npm version" /></a>
27
+ <a href="https://www.npmjs.com/package/roast-api"><img src="https://img.shields.io/npm/dm/roast-api?style=flat-square&color=ec4899&labelColor=020617" alt="npm downloads" /></a>
28
+ <a href="https://pypi.org/project/roast-api/"><img src="https://img.shields.io/pypi/v/roast-api?style=flat-square&color=3b82f6&labelColor=020617" alt="PyPI version" /></a>
29
+ <a href="https://packagist.org/packages/maizied/roast-api"><img src="https://img.shields.io/packagist/v/maizied/roast-api?style=flat-square&color=10b981&labelColor=020617" alt="Packagist version" /></a>
30
+ <a href="https://github.com/Maijied/roast-as-a-service/actions/workflows/deploy.yml"><img src="https://github.com/Maijied/roast-as-a-service/actions/workflows/deploy.yml/badge.svg" alt="Deploy to GitHub Pages" /></a>
31
+ </p>
32
+
33
+ Random developer roasts, delivered via a blazing‑fast static API on GitHub Pages. Plug it into your apps, bots, terminals, or CI logs when “nice error messages” just aren’t enough.
34
+
35
+ > **Part of the [Lorapok Ecosystem](https://github.com/Maijied/lorapok)** — Building the future of AI-driven developer tools. 🐛
36
+
37
+ ---
38
+
39
+ ## 🚀 What is RaaS?
40
+
41
+ Roast as a Service is a GitHub‑hosted, CDN‑backed JSON API that returns developer‑themed roasts in English and Bangla.
42
+ It’s completely static (no servers), but feels dynamic thanks to a smart client SDK that shards, caches, and randomly selects roasts on the fly.
43
+
44
+ Use it when you want your:
45
+
46
+ - CLI tools to roast the user on failure.
47
+ - CI pipeline to roast you when tests fail.
48
+ - Discord/Slack bots to respond with spicy dev insults.
49
+ - Portfolio or landing page to show random roasts on each visit.
50
+
51
+ ---
52
+
53
+ ## 🌐 Live Service
54
+
55
+ - **Website:** https://maijied.github.io/roast-as-a-service/
56
+ - **API Base Path:** https://maijied.github.io/roast-as-a-service/api/
57
+
58
+ ---
59
+
60
+ ## ⚡ Quick Start
61
+
62
+ ### 1. Install via npm
63
+ ```bash
64
+ npm install roast-api
65
+ # or
66
+ npm install @maizied/roast-as-a-service
67
+ ```
68
+
69
+ ```javascript
70
+ const RaaS = require('roast-api');
71
+
72
+ RaaS.getRandomRoast({ lang: 'en' })
73
+ .then(r => console.log(r.text));
74
+ ```
75
+
76
+ ### 2. Script Include (Browser)
77
+ Load the client SDK directly in your browser:
78
+
79
+ ```html
80
+ <script src="https://maijied.github.io/roast-as-a-service/api/client.js"></script>
81
+
82
+ <script>
83
+ // Fetch a random Bangla roast with intensity 2
84
+ RaaS.getRandomRoast({ lang: 'bn', intensity: 2 })
85
+ .then(r => console.log(r.text));
86
+ </script>
87
+ ```
88
+
89
+ ### 3. Install via Composer (PHP)
90
+ ```bash
91
+ composer require maizied/roast-api
92
+ ```
93
+
94
+ ```php
95
+ use Maizied\RoastApi\RaaS;
96
+
97
+ $roast = RaaS::getRandomRoast(['lang' => 'en']);
98
+ echo $roast['text'];
99
+ ```
100
+
101
+ ### 4. Install via pip (Python)
102
+ ```bash
103
+ pip install roast-api
104
+ ```
105
+
106
+ ```python
107
+ from roast_api import get_random_roast
108
+
109
+ roast = get_random_roast(lang='en')
110
+ print(roast['text'])
111
+ ```
112
+
113
+ ### 5. Direct Fetch
114
+ Or just fetch the JSON files directly:
115
+
116
+ ```javascript
117
+ fetch('https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json')
118
+ .then(res => res.json())
119
+ .then(data => {
120
+ const list = data.roasts;
121
+ const pick = list[Math.floor(Math.random() * list.length)];
122
+ console.log(pick.text);
123
+ });
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 🛠 How it works
129
+
130
+ RaaS exposes sharded JSON datasets over GitHub Pages, then a tiny client SDK picks, filters, and caches roasts in the browser, giving you an API‑like experience with pure static hosting.
131
+
132
+ - **Static API**: Roasts are stored in language‑specific shards (`en`, `bn`) and served as JSON over GitHub Pages’ global CDN for low TTFB.
133
+ - **Smart client**: The bundled client fetches a small shard, caches it, and returns random roasts with optional intensity and length filters.
134
+ - **Zero ops**: No servers, no cold starts, no scaling issues. Push to main, let Pages deploy and cache everything at the edge.
135
+
136
+ ---
137
+
138
+ ## 📦 API Overview
139
+
140
+ This is a **static** API: data comes from versioned JSON files served over CDN, and a lightweight JS client handles randomness, filtering and caching in the browser.
141
+
142
+ ### Endpoints (static JSON)
143
+
144
+ - **Manifest:**
145
+ `GET https://maijied.github.io/roast-as-a-service/api/manifest.json`
146
+
147
+ - **English Shard #1:**
148
+ `GET https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json`
149
+
150
+ - **Bangla Shard #1:**
151
+ `GET https://maijied.github.io/roast-as-a-service/api/bn/roasts-bn-1.json`
152
+
153
+ ### Example Response Structure
154
+ Each shard looks like:
155
+
156
+ ```json
157
+ {
158
+ "language": "en",
159
+ "shard": 1,
160
+ "total_shards": 5,
161
+ "count": 300,
162
+ "tags": ["dev", "general"],
163
+ "roasts": [
164
+ {
165
+ "id": "en-1-1",
166
+ "text": "Your codebase looks like it was written during a live outage.",
167
+ "intensity": 2,
168
+ "length": 61
169
+ }
170
+ ]
171
+ }
172
+ ```
173
+
174
+ ### Usage Example (curl + jq)
175
+ ```bash
176
+ curl -s https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json \
177
+ | jq '.roasts[0].text'
178
+ ```
179
+
180
+ ---
181
+
182
+ ## 🧬 Why this architecture is “state of the art”
183
+
184
+ Roast as a Service is intentionally built as a **static API** on top of GitHub Pages and a CDN, instead of a traditional backend. For this use case (serving pre‑made content), this gives you the same “API experience” with less cost, less complexity, and better global latency.
185
+
186
+ Key points:
187
+
188
+ - **Static JSON over CDN**
189
+ All responses are just versioned JSON files served by GitHub Pages’ global edge network, which is highly cache‑friendly and extremely fast for read‑heavy traffic.
190
+
191
+ - **Zero backend, zero cold starts**
192
+ There is no application server to boot, scale, or warm up. Every request hits static content that can be served from edge cache with minimal TTFB.
193
+
194
+ - **Sharded data layout**
195
+ Roasts are split into language‑specific shards (e.g. `en/roasts-en-1.json`) so each response stays small and cacheable even if the total dataset becomes large.
196
+
197
+ - **Client‑side selection and filtering**
198
+ A tiny SDK handles randomness, intensity filters, and length limits in the client, so the “API” stays read‑only and ultra fast instead of computing on every request.
199
+
200
+ - **Edge‑friendly cache behavior**
201
+ Because the content is static and not personalized, CDN nodes can cache responses aggressively without worrying about user‑specific data. That’s exactly what CDNs are optimized for.
202
+
203
+ - **Version‑controlled API**
204
+ All JSON lives in Git; you can roll back, branch, and review changes like any other codebase while GitHub Pages redeploys and re‑caches automatically.
205
+
206
+ This combination (static JSON + sharding + client‑side logic + CDN caching) is effectively the “fast path” that many dynamic APIs end up approximating with layers of caching—here it’s the default.
207
+
208
+ ## ⚡ Performance & Benchmarks
209
+
210
+ RaaS is built for extreme speed and low overhead. By sharding data and relying on CDN edge caching + local browser caching, it achieves massive throughput.
211
+
212
+ **Latest Benchmark Results:**
213
+ - **Requests/sec**: ~2,000 (Tested with 5,000 total requests)
214
+ - **Success Rate**: 100% (Zero failures under high concurrency)
215
+ - **Avg Latency**: ~58ms
216
+ - **P95 Latency**: ~159ms
217
+ - **Cache Efficiency**: 90%+ (Manifest and shard reuse)
218
+
219
+ > [!TIP]
220
+ > This "Static API" approach beats the latency of traditional dynamic APIs by removing backend processing, cold starts, and database queries from the request path.
221
+
222
+ ---
223
+
224
+ ## 🐛 More from Lorapok
225
+
226
+ RaaS is a proud member of the **Lorapok** family. Check out our other tools:
227
+
228
+ - **[Lorapok CLI](https://github.com/Maijied/lorapok):** The intelligent AI agent framework for developers.
229
+ - **[Lorapok Media Player](https://github.com/Maijied/Lorapok_Media_Player):** A modern, feature-rich media player built for power users.
230
+
231
+ ---
232
+
233
+ ## 👤 Author
234
+
235
+ **Maizied**
236
+ 📧 [mdshuvo40@gmail.com](mailto:mdshuvo40@gmail.com)
237
+ 🔗 [GitHub](https://github.com/Maijied) · [npm](https://www.npmjs.com/~maizied)
238
+
239
+ ---
240
+
241
+ ## 📄 License
242
+
243
+ MIT © Maizied
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ roast_api/__init__.py
4
+ roast_api/client.py
5
+ roast_api.egg-info/PKG-INFO
6
+ roast_api.egg-info/SOURCES.txt
7
+ roast_api.egg-info/dependency_links.txt
8
+ roast_api.egg-info/requires.txt
9
+ roast_api.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.20.0
@@ -0,0 +1 @@
1
+ roast_api
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+