keatpy 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.
keatpy-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: keatpy
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Synapse by Keaton Technologies
5
+ License: MIT
6
+ Project-URL: Homepage, https://keatontechnologies.com/synapse
7
+ Project-URL: Repository, https://github.com/microphonicwire-blip/keatpy
8
+ Keywords: keaton,synapse,api,currency,weather,stocks,news
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+
15
+ # keatpy
16
+
17
+ Official Python SDK for [Synapse](https://keatontechnologies.com/synapse) by Keaton Technologies.
18
+
19
+ One API key. Currency, weather, stocks, news, and Wikipedia — unified.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install keatpy
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```python
30
+ from keatpy import Synapse
31
+
32
+ client = Synapse(api_key="syn_yourkey")
33
+
34
+ # Currency conversion
35
+ result = client.currency.convert("CAD", "USD", 100)
36
+ print(f"100 CAD = {result.result} USD")
37
+
38
+ # Weather
39
+ w = client.weather.current("Vancouver")
40
+ print(f"{w.city}: {w.temperature}°C, {w.description}")
41
+
42
+ # Stock quote
43
+ s = client.stocks.quote("NVDA")
44
+ print(f"NVDA: ${s.price} ({s.change_pct})")
45
+
46
+ # Wikipedia
47
+ wiki = client.wiki.search("quantum computing", sentences=2)
48
+ print(wiki.summary)
49
+
50
+ # News
51
+ news = client.news.search("PC hardware", limit=3)
52
+ for article in news.articles:
53
+ print(article.title, "—", article.source)
54
+ ```
55
+
56
+ ## Get an API Key
57
+
58
+ Visit [keatontechnologies.com/synapse](https://keatontechnologies.com/synapse)
59
+
60
+ ## License
61
+
62
+ MIT
keatpy-0.1.0/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # keatpy
2
+
3
+ Official Python SDK for [Synapse](https://keatontechnologies.com/synapse) by Keaton Technologies.
4
+
5
+ One API key. Currency, weather, stocks, news, and Wikipedia — unified.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install keatpy
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ from keatpy import Synapse
17
+
18
+ client = Synapse(api_key="syn_yourkey")
19
+
20
+ # Currency conversion
21
+ result = client.currency.convert("CAD", "USD", 100)
22
+ print(f"100 CAD = {result.result} USD")
23
+
24
+ # Weather
25
+ w = client.weather.current("Vancouver")
26
+ print(f"{w.city}: {w.temperature}°C, {w.description}")
27
+
28
+ # Stock quote
29
+ s = client.stocks.quote("NVDA")
30
+ print(f"NVDA: ${s.price} ({s.change_pct})")
31
+
32
+ # Wikipedia
33
+ wiki = client.wiki.search("quantum computing", sentences=2)
34
+ print(wiki.summary)
35
+
36
+ # News
37
+ news = client.news.search("PC hardware", limit=3)
38
+ for article in news.articles:
39
+ print(article.title, "—", article.source)
40
+ ```
41
+
42
+ ## Get an API Key
43
+
44
+ Visit [keatontechnologies.com/synapse](https://keatontechnologies.com/synapse)
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,350 @@
1
+ """
2
+ keatpy — Official Python SDK for Synapse by Keaton Technologies
3
+ pip install keatpy
4
+
5
+ Usage:
6
+ from keatpy import Synapse
7
+
8
+ client = Synapse(api_key="syn_yourkey")
9
+ result = client.currency.convert("CAD", "USD", 100)
10
+ print(result.rate)
11
+ """
12
+
13
+ import urllib.request
14
+ import urllib.parse
15
+ import json
16
+ from typing import Optional
17
+
18
+
19
+ BASE_URL = "https://keaton-api.microphonicwire.workers.dev"
20
+ VERSION = "0.1.0"
21
+
22
+
23
+ # ── RESPONSE OBJECTS ──────────────────────────────────────────
24
+
25
+ class SynapseResponse:
26
+ """Base response wrapper — access fields as attributes or dict."""
27
+ def __init__(self, data: dict):
28
+ self._data = data
29
+ for k, v in data.items():
30
+ setattr(self, k, v)
31
+
32
+ def __repr__(self):
33
+ return f"{self.__class__.__name__}({self._data})"
34
+
35
+ def to_dict(self):
36
+ return self._data
37
+
38
+
39
+ class CurrencyResult(SynapseResponse):
40
+ """
41
+ Attributes:
42
+ from_currency (str): Source currency code
43
+ to_currency (str): Target currency code
44
+ amount (float): Input amount
45
+ rate (float): Exchange rate
46
+ result (float): Converted amount
47
+ timestamp (str): ISO timestamp
48
+ cached (bool): Whether response was cached
49
+ """
50
+ def __init__(self, data: dict, cached: bool):
51
+ super().__init__(data)
52
+ self.from_currency = data.get("from")
53
+ self.to_currency = data.get("to")
54
+ self.cached = cached
55
+
56
+
57
+ class WeatherResult(SynapseResponse):
58
+ """
59
+ Attributes:
60
+ city (str): City name
61
+ country (str): Country code
62
+ temperature (float): Current temperature
63
+ feels_like (float): Feels like temperature
64
+ humidity (int): Humidity percentage
65
+ description (str): Weather description
66
+ icon (str): Icon URL
67
+ wind_speed (float): Wind speed
68
+ units (str): metric or imperial
69
+ """
70
+ pass
71
+
72
+
73
+ class StockResult(SynapseResponse):
74
+ """
75
+ Attributes:
76
+ ticker (str): Stock ticker symbol
77
+ price (float): Current price
78
+ change (float): Price change
79
+ change_pct (str): Percentage change
80
+ volume (int): Trading volume
81
+ high (float): Day high
82
+ low (float): Day low
83
+ prev_close (float): Previous close
84
+ """
85
+ pass
86
+
87
+
88
+ class WikiResult(SynapseResponse):
89
+ """
90
+ Attributes:
91
+ title (str): Article title
92
+ summary (str): Article summary
93
+ url (str): Wikipedia URL
94
+ image (str): Thumbnail image URL
95
+ query (str): Original query
96
+ """
97
+ pass
98
+
99
+
100
+ class NewsArticle(SynapseResponse):
101
+ """
102
+ Attributes:
103
+ title (str): Article title
104
+ description (str): Article description
105
+ url (str): Article URL
106
+ source (str): Source name
107
+ published (str): Publication date
108
+ image (str): Article image URL
109
+ """
110
+ pass
111
+
112
+
113
+ class NewsResult(SynapseResponse):
114
+ """
115
+ Attributes:
116
+ topic (str): Search topic
117
+ count (int): Number of articles
118
+ articles (list): List of NewsArticle objects
119
+ """
120
+ def __init__(self, data: dict, cached: bool):
121
+ super().__init__(data)
122
+ self.articles = [NewsArticle(a) for a in data.get("articles", [])]
123
+ self.cached = cached
124
+
125
+
126
+ # ── API MODULES ───────────────────────────────────────────────
127
+
128
+ class CurrencyAPI:
129
+ def __init__(self, client):
130
+ self._client = client
131
+
132
+ def convert(self, from_currency: str, to_currency: str, amount: float = 1.0) -> CurrencyResult:
133
+ """
134
+ Convert between currencies.
135
+
136
+ Args:
137
+ from_currency: Source currency code (e.g. 'CAD')
138
+ to_currency: Target currency code (e.g. 'USD')
139
+ amount: Amount to convert (default 1.0)
140
+
141
+ Returns:
142
+ CurrencyResult with rate and result
143
+
144
+ Example:
145
+ result = client.currency.convert("CAD", "USD", 500)
146
+ print(f"500 CAD = {result.result} USD at rate {result.rate}")
147
+ """
148
+ res = self._client._get("/api/v1/currency/convert", {
149
+ "from": from_currency.upper(),
150
+ "to": to_currency.upper(),
151
+ "amount": str(amount),
152
+ })
153
+ return CurrencyResult(res["data"], res.get("cached", False))
154
+
155
+
156
+ class WeatherAPI:
157
+ def __init__(self, client):
158
+ self._client = client
159
+
160
+ def current(self, city: str, units: str = "metric") -> WeatherResult:
161
+ """
162
+ Get current weather for a city.
163
+
164
+ Args:
165
+ city: City name (e.g. 'Vancouver')
166
+ units: 'metric' (°C) or 'imperial' (°F), default 'metric'
167
+
168
+ Returns:
169
+ WeatherResult with temperature, humidity, description, etc.
170
+
171
+ Example:
172
+ w = client.weather.current("Vancouver")
173
+ print(f"{w.city}: {w.temperature}°C, {w.description}")
174
+ """
175
+ res = self._client._get("/api/v1/weather", {"city": city, "units": units})
176
+ return WeatherResult(res["data"])
177
+
178
+
179
+ class StocksAPI:
180
+ def __init__(self, client):
181
+ self._client = client
182
+
183
+ def quote(self, ticker: str) -> StockResult:
184
+ """
185
+ Get a real-time stock quote.
186
+
187
+ Args:
188
+ ticker: Stock ticker symbol (e.g. 'AAPL', 'NVDA')
189
+
190
+ Returns:
191
+ StockResult with price, change, volume, etc.
192
+
193
+ Example:
194
+ stock = client.stocks.quote("NVDA")
195
+ print(f"NVDA: ${stock.price} ({stock.change_pct})")
196
+ """
197
+ res = self._client._get("/api/v1/stocks/quote", {"ticker": ticker.upper()})
198
+ return StockResult(res["data"])
199
+
200
+
201
+ class WikiAPI:
202
+ def __init__(self, client):
203
+ self._client = client
204
+
205
+ def search(self, query: str, sentences: int = 3) -> WikiResult:
206
+ """
207
+ Search Wikipedia and get a clean summary.
208
+
209
+ Args:
210
+ query: Search query (e.g. 'quantum computing')
211
+ sentences: Number of sentences to return (default 3)
212
+
213
+ Returns:
214
+ WikiResult with title, summary, url, and image
215
+
216
+ Example:
217
+ result = client.wiki.search("Keaton Technologies")
218
+ print(result.summary)
219
+ """
220
+ res = self._client._get("/api/v1/wiki", {"q": query, "sentences": str(sentences)})
221
+ return WikiResult(res["data"])
222
+
223
+
224
+ class NewsAPI:
225
+ def __init__(self, client):
226
+ self._client = client
227
+
228
+ def search(self, topic: str, limit: int = 5, lang: str = "en") -> NewsResult:
229
+ """
230
+ Get latest news articles on a topic.
231
+
232
+ Args:
233
+ topic: Search topic (e.g. 'technology', 'AMD GPU')
234
+ limit: Number of articles 1-10 (default 5)
235
+ lang: Language code (default 'en')
236
+
237
+ Returns:
238
+ NewsResult with list of NewsArticle objects
239
+
240
+ Example:
241
+ news = client.news.search("PC hardware", limit=3)
242
+ for article in news.articles:
243
+ print(article.title, "-", article.source)
244
+ """
245
+ res = self._client._get("/api/v1/news", {
246
+ "topic": topic, "limit": str(limit), "lang": lang
247
+ })
248
+ return NewsResult(res["data"], res.get("cached", False))
249
+
250
+
251
+ # ── MAIN CLIENT ───────────────────────────────────────────────
252
+
253
+ class Synapse:
254
+ """
255
+ Synapse API client by Keaton Technologies.
256
+
257
+ Args:
258
+ api_key: Your Synapse API key (get one at keatontechnologies.com/synapse)
259
+ base_url: Override the API base URL (optional)
260
+
261
+ Example:
262
+ from keatpy import Synapse
263
+
264
+ client = Synapse(api_key="syn_yourkey")
265
+
266
+ # Currency
267
+ result = client.currency.convert("CAD", "USD", 100)
268
+ print(result.result) # 71.8
269
+
270
+ # Weather
271
+ w = client.weather.current("Vancouver")
272
+ print(w.temperature) # 14.2
273
+
274
+ # Stocks
275
+ s = client.stocks.quote("AAPL")
276
+ print(s.price) # 213.45
277
+
278
+ # Wikipedia
279
+ wiki = client.wiki.search("quantum computing")
280
+ print(wiki.summary)
281
+
282
+ # News
283
+ news = client.news.search("PC hardware", limit=3)
284
+ for article in news.articles:
285
+ print(article.title)
286
+ """
287
+
288
+ def __init__(self, api_key: str, base_url: Optional[str] = None):
289
+ if not api_key:
290
+ raise ValueError("api_key is required. Get one at keatontechnologies.com/synapse")
291
+ self.api_key = api_key
292
+ self.base_url = (base_url or BASE_URL).rstrip("/")
293
+
294
+ # API modules
295
+ self.currency = CurrencyAPI(self)
296
+ self.weather = WeatherAPI(self)
297
+ self.stocks = StocksAPI(self)
298
+ self.wiki = WikiAPI(self)
299
+ self.news = NewsAPI(self)
300
+
301
+ def _get(self, path: str, params: dict = None) -> dict:
302
+ query = ("?" + urllib.parse.urlencode(params)) if params else ""
303
+ url = self.base_url + path + query
304
+
305
+ req = urllib.request.Request(url, headers={
306
+ "X-Synapse-Key": self.api_key,
307
+ "User-Agent": f"keatpy/{VERSION}",
308
+ })
309
+
310
+ try:
311
+ with urllib.request.urlopen(req, timeout=10) as response:
312
+ raw = response.read().decode("utf-8")
313
+ data = json.loads(raw)
314
+ except urllib.error.HTTPError as e:
315
+ raw = e.read().decode("utf-8")
316
+ data = json.loads(raw)
317
+ raise SynapseError(data.get("error", "Request failed"), e.code)
318
+ except urllib.error.URLError as e:
319
+ raise SynapseError(f"Connection failed: {e.reason}")
320
+
321
+ if not data.get("success"):
322
+ raise SynapseError(data.get("error", "Unknown error"))
323
+
324
+ return data
325
+
326
+ def status(self) -> dict:
327
+ """Check API status and list available endpoints."""
328
+ return self._get("/api/v1/status")
329
+
330
+
331
+ class SynapseError(Exception):
332
+ """Raised when the Synapse API returns an error."""
333
+ def __init__(self, message: str, status_code: int = None):
334
+ super().__init__(message)
335
+ self.status_code = status_code
336
+
337
+
338
+ # ── CONVENIENCE EXPORTS ───────────────────────────────────────
339
+ __all__ = [
340
+ "Synapse",
341
+ "SynapseError",
342
+ "CurrencyResult",
343
+ "WeatherResult",
344
+ "StockResult",
345
+ "WikiResult",
346
+ "NewsResult",
347
+ "NewsArticle",
348
+ ]
349
+
350
+ __version__ = VERSION
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: keatpy
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Synapse by Keaton Technologies
5
+ License: MIT
6
+ Project-URL: Homepage, https://keatontechnologies.com/synapse
7
+ Project-URL: Repository, https://github.com/microphonicwire-blip/keatpy
8
+ Keywords: keaton,synapse,api,currency,weather,stocks,news
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+
15
+ # keatpy
16
+
17
+ Official Python SDK for [Synapse](https://keatontechnologies.com/synapse) by Keaton Technologies.
18
+
19
+ One API key. Currency, weather, stocks, news, and Wikipedia — unified.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install keatpy
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```python
30
+ from keatpy import Synapse
31
+
32
+ client = Synapse(api_key="syn_yourkey")
33
+
34
+ # Currency conversion
35
+ result = client.currency.convert("CAD", "USD", 100)
36
+ print(f"100 CAD = {result.result} USD")
37
+
38
+ # Weather
39
+ w = client.weather.current("Vancouver")
40
+ print(f"{w.city}: {w.temperature}°C, {w.description}")
41
+
42
+ # Stock quote
43
+ s = client.stocks.quote("NVDA")
44
+ print(f"NVDA: ${s.price} ({s.change_pct})")
45
+
46
+ # Wikipedia
47
+ wiki = client.wiki.search("quantum computing", sentences=2)
48
+ print(wiki.summary)
49
+
50
+ # News
51
+ news = client.news.search("PC hardware", limit=3)
52
+ for article in news.articles:
53
+ print(article.title, "—", article.source)
54
+ ```
55
+
56
+ ## Get an API Key
57
+
58
+ Visit [keatontechnologies.com/synapse](https://keatontechnologies.com/synapse)
59
+
60
+ ## License
61
+
62
+ MIT
@@ -0,0 +1,7 @@
1
+ README.md
2
+ pyproject.toml
3
+ keatpy/__init__.py.py
4
+ keatpy.egg-info/PKG-INFO
5
+ keatpy.egg-info/SOURCES.txt
6
+ keatpy.egg-info/dependency_links.txt
7
+ keatpy.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ keatpy
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "keatpy"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for Synapse by Keaton Technologies"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.8"
12
+ keywords = ["keaton", "synapse", "api", "currency", "weather", "stocks", "news"]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://keatontechnologies.com/synapse"
21
+ Repository = "https://github.com/microphonicwire-blip/keatpy"
keatpy-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+