gs1-decoder-client 1.0.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.
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""
|
|
2
|
+
GS1 Barcode & Digital Link Decoder API Python Client SDK (Zero External Dependencies)
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import json
|
|
6
|
+
import urllib.request
|
|
7
|
+
import urllib.error
|
|
8
|
+
from typing import Any, Dict, Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Gs1DecoderClient:
|
|
12
|
+
"""
|
|
13
|
+
Client for GS1 Barcode & Digital Link Decoder API.
|
|
14
|
+
|
|
15
|
+
:param api_key: RapidAPI key ('x-rapidapi-key'). Optional for test evaluation.
|
|
16
|
+
Get your key at: https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027
|
|
17
|
+
:param base_url: Custom API endpoint override.
|
|
18
|
+
:param rapidapi_host: RapidAPI host header.
|
|
19
|
+
"""
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
api_key: Optional[str] = None,
|
|
23
|
+
base_url: Optional[str] = None,
|
|
24
|
+
rapidapi_host: str = "gs1-barcode-digital-link-decoder-sunrise-2027.p.rapidapi.com"
|
|
25
|
+
):
|
|
26
|
+
self.api_key = api_key or os.environ.get("RAPIDAPI_KEY", "")
|
|
27
|
+
self.rapidapi_host = rapidapi_host
|
|
28
|
+
if base_url:
|
|
29
|
+
self.base_url = base_url.rstrip("/")
|
|
30
|
+
elif self.api_key:
|
|
31
|
+
self.base_url = "https://gs1-barcode-digital-link-decoder-sunrise-2027.p.rapidapi.com"
|
|
32
|
+
else:
|
|
33
|
+
self.base_url = "https://gs1-decoder.alph4nir.workers.dev".rstrip("/")
|
|
34
|
+
|
|
35
|
+
def request(self, endpoint: str, method: str = "GET", payload: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
36
|
+
url = f"{self.base_url}/{endpoint.lstrip('/')}"
|
|
37
|
+
headers = {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
"Accept": "application/json",
|
|
40
|
+
"User-Agent": "gs1-decoder-python-client/1.0"
|
|
41
|
+
}
|
|
42
|
+
if self.api_key:
|
|
43
|
+
headers["x-rapidapi-key"] = self.api_key
|
|
44
|
+
headers["x-rapidapi-host"] = self.rapidapi_host
|
|
45
|
+
|
|
46
|
+
data = json.dumps(payload).encode("utf-8") if payload else None
|
|
47
|
+
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
with urllib.request.urlopen(req, timeout=10) as response:
|
|
51
|
+
res_data = json.loads(response.read().decode("utf-8"))
|
|
52
|
+
if not self.api_key and response.status == 200:
|
|
53
|
+
meta = res_data.setdefault("meta", {})
|
|
54
|
+
meta["notice"] = "Free evaluation tier. Subscribe for full throughput & SLA: https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027"
|
|
55
|
+
return res_data
|
|
56
|
+
except urllib.error.HTTPError as e:
|
|
57
|
+
try:
|
|
58
|
+
return json.loads(e.read().decode("utf-8"))
|
|
59
|
+
except Exception:
|
|
60
|
+
return {
|
|
61
|
+
"success": False,
|
|
62
|
+
"error": f"HTTP {e.code}: {e.reason}",
|
|
63
|
+
"code": f"HTTP_{e.code}",
|
|
64
|
+
"upgrade_url": "https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027"
|
|
65
|
+
}
|
|
66
|
+
except Exception as e:
|
|
67
|
+
return {"success": False, "error": str(e), "code": "NETWORK_ERROR"}
|
|
68
|
+
|
|
69
|
+
def get_health(self) -> Dict[str, Any]:
|
|
70
|
+
"""Check edge health status."""
|
|
71
|
+
return self.request("/health", method="GET")
|
|
72
|
+
|
|
73
|
+
def validate(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
74
|
+
"""Submit validation/parse request."""
|
|
75
|
+
return self.request("/api/v1/validate", method="POST", payload=payload)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gs1-decoder-client
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official zero-dependency Python client for GS1 Barcode & Digital Link Decoder API via RapidAPI
|
|
5
|
+
Author: RapidAPI Microservices Portfolio
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027
|
|
8
|
+
Project-URL: Documentation, https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027
|
|
9
|
+
Project-URL: Source, https://github.com/DrMkdaddy/api-monorepo
|
|
10
|
+
Keywords: gs1-decoder,rapidapi,sdk,api,validation,fintech
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# GS1 Barcode & Digital Link Decoder API — Python Client
|
|
16
|
+
|
|
17
|
+
[](https://pypi.org/project/gs1-decoder-client/)
|
|
18
|
+
[](https://opensource.org/licenses/MIT)
|
|
19
|
+
[](https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027)
|
|
20
|
+
|
|
21
|
+
Official zero-dependency Python client for **GS1 Barcode & Digital Link Decoder API**.
|
|
22
|
+
|
|
23
|
+
> 🔑 **Get your Dedicated API Key:** [Subscribe to GS1 Barcode & Digital Link Decoder API on RapidAPI](https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🚀 Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install gs1-decoder-client
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## ⚡ Quickstart
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from gs1_decoder_client import Gs1DecoderClient
|
|
39
|
+
|
|
40
|
+
# Zero config for sandbox testing, or pass your RapidAPI key for production
|
|
41
|
+
client = Gs1DecoderClient(api_key="YOUR_RAPIDAPI_KEY")
|
|
42
|
+
|
|
43
|
+
result = client.validate({
|
|
44
|
+
# Enter validation payload
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
print(result)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 📚 API Reference
|
|
53
|
+
|
|
54
|
+
### `Gs1DecoderClient(api_key=..., base_url=...)`
|
|
55
|
+
- `api_key` *(optional)*: RapidAPI Key (`x-rapidapi-key`).
|
|
56
|
+
- `base_url` *(optional)*: Direct edge worker override URL.
|
|
57
|
+
|
|
58
|
+
### `client.validate(payload)`
|
|
59
|
+
Dispatches standard validation / parse request with sub-5ms latency.
|
|
60
|
+
|
|
61
|
+
### `client.get_health()`
|
|
62
|
+
Checks edge isolate health and responsiveness.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 🔗 Links
|
|
67
|
+
- 📖 [RapidAPI Documentation & Key](https://rapidapi.com/noor-mkdad-apis-noor-mkdad-apis-default/api/gs1-barcode-digital-link-decoder-sunrise-2027)
|
|
68
|
+
|
|
69
|
+
## 📄 License
|
|
70
|
+
MIT © RapidAPI Microservices Portfolio
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
gs1_decoder_client/__init__.py,sha256=afmJJ-7cDkbO-e8_hwm8RsN0kTiNV_Ot0PyjqDTlRNA,3338
|
|
2
|
+
gs1_decoder_client-1.0.0.dist-info/METADATA,sha256=hF3lvTByhZSQdCvOp7UglQxfn-LCsm93GNRPisqMhIo,2524
|
|
3
|
+
gs1_decoder_client-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
4
|
+
gs1_decoder_client-1.0.0.dist-info/top_level.txt,sha256=7s9GF0a77N2Kyk0VYwIcOdpdwCZo0GUvsIJjaD7595U,19
|
|
5
|
+
gs1_decoder_client-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gs1_decoder_client
|