productcategorizationapi 1.1__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,443 @@
1
+ Metadata-Version: 2.1
2
+ Name: productcategorizationapi
3
+ Version: 1.1
4
+ Summary: product categorization API
5
+ Home-page: https://www.productcategorization.com
6
+ Author-email: info@productcategorizationapi.com
7
+ License: UNKNOWN
8
+ Description: Certainly! Below is an extensively detailed `README.md` for your PyPI package, paraphrased and expanded from your API documentation. It is structured for maximum clarity, includes code examples, best practices, and a thorough section on your additional services (with anchor texts and external research/edu links).
9
+ Below the README, you'll find a sample `__init__.py` for your PyPI package with a `ProductCategorizationAPI` class.
10
+
11
+ ---
12
+
13
+ # ProductCategorization.com Python Client
14
+
15
+ [![PyPI version](https://badge.fury.io/py/productcategorization.svg)](https://pypi.org/project/productcategorization/)
16
+ [![API Docs](https://www.productcategorization.com/api.php)](https://www.productcategorization.com/api.php)
17
+
18
+ ---
19
+
20
+ ## Overview
21
+
22
+ The `productcategorization` Python package provides seamless access to one of the world's most advanced product categorization APIs, powering e-commerce classification for unicorn startups, multinational enterprises, retail analytics platforms, adTech innovators, and online merchants. Whether you operate an e-commerce storefront, marketplace, or SaaS platform, this package allows you to integrate AI-powered categorization directly into your Python applications, unlocking world-class product, URL, and image classification using industry-standard taxonomies.
23
+
24
+ ## Key Features
25
+
26
+ * **Ultra-Accurate Product Categorization**
27
+ Classify product titles, descriptions, and URLs using:
28
+
29
+ * **Google Shopping Taxonomy:** Over 5,500 hierarchical categories for granular and up-to-date mapping.
30
+ * **Shopify Taxonomy:** Leverage the latest Shopify category structure with \~11,000 fine-grained categories.
31
+ * **Amazon and Other Standard Taxonomies:** Flexibility for diverse retail needs.
32
+ * **Custom Taxonomies:** Tailor classifiers to your unique vertical or proprietary taxonomy.
33
+
34
+ * **Multi-Modal Classification**
35
+
36
+ * **Text**: Classify any product-related string.
37
+ * **URL**: Categorize products directly from their web pages.
38
+ * **Image**: Obtain Shopify categories and attribute extraction directly from images (using AI vision).
39
+
40
+ * **Buyer Persona Enrichment**
41
+ Every classification returns relevant buyer personas—select from a proprietary library of over 1,800 personas to enrich your analytics, personalization, or marketing automations.
42
+ Confidence scores and expanded context available.
43
+
44
+ * **High Scalability and Reliability**
45
+ Robust API supporting high throughput (rate limits adjustable upon request), with credit-based billing for predictable scaling.
46
+
47
+ * **Plug-and-Play Python Integration**
48
+ Simple, modern, and extensible Python API client.
49
+ See [Quickstart](#quickstart) for usage examples.
50
+
51
+ ---
52
+
53
+ ## Table of Contents
54
+
55
+ * [Getting Started](#getting-started)
56
+ * [Authentication](#authentication)
57
+ * [API Usage](#api-usage)
58
+
59
+ * [Text Categorization](#text-categorization)
60
+ * [URL Categorization](#url-categorization)
61
+ * [Image Categorization](#image-categorization)
62
+ * [Advanced Options](#advanced-options)
63
+
64
+ * [Buyer Personas and Confidence Scores](#buyer-personas-and-confidence-scores)
65
+ * [Context Expansion](#context-expansion)
66
+ * [Error Handling](#error-handling)
67
+ * [Best Practices](#best-practices)
68
+ * [Integration Examples](#integration-examples)
69
+ * [Contact & Support](#contact--support)
70
+ * [Related Services](#related-services)
71
+ * [References](#references)
72
+
73
+ ---
74
+
75
+ ## Getting Started
76
+
77
+ Install the package via PyPI:
78
+
79
+ ```bash
80
+ pip install productcategorization
81
+ ```
82
+
83
+ Or add it to your `requirements.txt` for automatic deployment.
84
+
85
+ ---
86
+
87
+ ## Authentication
88
+
89
+ All API access is secured by a personal API key.
90
+ To obtain your API key:
91
+
92
+ 1. Sign up and purchase a subscription at [www.productcategorization.com](https://www.productcategorization.com/pricing.php
93
+ 3. Provide the API key in every request (see examples).
94
+
95
+ > **Note:** Never share your API key publicly. Store it securely as an environment variable or in your configuration files.
96
+
97
+ ---
98
+
99
+ ## API Usage
100
+
101
+ ### Text Categorization
102
+
103
+ Classify any product text (title, description, or keyword) in a single line:
104
+
105
+ ```python
106
+ from productcategorization import ProductCategorizationAPI
107
+
108
+ api = ProductCategorizationAPI(api_key="your_api_key")
109
+ result = api.categorize_text("Fluorescent Highlighters 3pc Yellow")
110
+ print(result)
111
+ ```
112
+
113
+ **Sample Response:**
114
+
115
+ ```json
116
+ {
117
+ "total_credits": 100044,
118
+ "remaining_credits": 33075,
119
+ "language": "en",
120
+ "classification": "Office Supplies > Office Instruments > Writing & Drawing Instruments",
121
+ "buyer_personas": [
122
+ "Business Professional", "Office Professional", "Administrative Coordinator", ...
123
+ ],
124
+ "buyer_personas_confidence_selection": {
125
+ "Office Professional": 0.9,
126
+ "Business Professional": 0.8,
127
+ ...
128
+ },
129
+ "ID": "977",
130
+ "status": 200
131
+ }
132
+ ```
133
+
134
+ **Parameters:**
135
+
136
+ * `query` (str): Product text for categorization.
137
+ * `confidence` (optional, int): Set to `1` to include confidence scores for each persona.
138
+ * `expand_context` (optional, int): Set to `1` to auto-generate expanded context for short/ambiguous texts.
139
+
140
+ ---
141
+
142
+ ### URL Categorization
143
+
144
+ You can also classify products by URL, leveraging our AI’s ability to extract relevant text and metadata:
145
+
146
+ ```python
147
+ result = api.categorize_url("https://www.apple.com")
148
+ print(result)
149
+ ```
150
+
151
+ **Sample Python (requests):**
152
+
153
+ ```python
154
+ import requests
155
+
156
+ payload = {'query': 'www.apple.com', 'api_key': 'your_api_key', 'data_type': 'url'}
157
+ response = requests.post("https://www.productcategorization.com/api/iab/iab_web_content_filtering_url.php", data=payload)
158
+ print(response.json())
159
+ ```
160
+
161
+ ---
162
+
163
+ ### Image Categorization
164
+
165
+ Classify products using image URLs or local image files (Shopify Taxonomy + attribute extraction):
166
+
167
+ ```python
168
+ result = api.categorize_image(image_url="https://images.com/product.jpg", text="Product title")
169
+ print(result)
170
+ ```
171
+
172
+ **Example Function:**
173
+
174
+ ```python
175
+ import requests
176
+ import io
177
+
178
+ def call_api(image_url, text, api_key):
179
+ api_endpoint = 'https://www.productcategorization.com/api/ecommerce/ecommerce_shopify_image.php'
180
+ response = requests.get(image_url)
181
+ if response.status_code != 200:
182
+ return {'error': 'Failed to download image'}
183
+ image_file = io.BytesIO(response.content)
184
+ data = {'ip': '0', 'api_key': api_key, 'login': '0', 'text': text}
185
+ files = {'image': ('image.jpg', image_file, 'image/jpeg')}
186
+ response = requests.post(api_endpoint, data=data, files=files)
187
+ return response.json()
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Advanced Options
193
+
194
+ ### Buyer Personas and Confidence Scores
195
+
196
+ Our AI delivers a unique set of buyer personas for every product—ideal for market analysis, targeted marketing, or persona-based analytics.
197
+ Enable confidence scoring to obtain relevance weights for each persona:
198
+
199
+ ```python
200
+ result = api.categorize_text("Eco-Friendly Notebook", confidence=1)
201
+ print(result["buyer_personas_confidence_selection"])
202
+ ```
203
+
204
+ ### Context Expansion
205
+
206
+ For short or ambiguous inputs, enable `expand_context=1` to let our AI generate an enhanced description for improved classification accuracy:
207
+
208
+ ```python
209
+ result = api.categorize_text("3pc Yellow Highlighters", expand_context=1)
210
+ print(result["expanded_context"])
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Error Handling
216
+
217
+ All API responses include a `status` code for programmatic error handling:
218
+
219
+ | Status | Meaning |
220
+ | ------ | ---------------------------------------- |
221
+ | 200 | Request was successful |
222
+ | 400 | Request malformed (check parameters) |
223
+ | 401 | Invalid API key (check or purchase key) |
224
+ | 403 | Quota exhausted (upgrade or add credits) |
225
+
226
+ Example error handling in Python:
227
+
228
+ ```python
229
+ if result["status"] != 200:
230
+ print(f"API Error: {result.get('message', 'Unknown error')}")
231
+ ```
232
+
233
+ ---
234
+
235
+ ## Best Practices
236
+
237
+ * **Monitor Remaining Credits:** Every response includes `total_credits` and `remaining_credits`. Plan your usage to avoid interruptions.
238
+ * **Respect Rate Limits:** Default is 60 requests per minute. Contact support for higher needs.
239
+ * **Secure Your API Key:** Do not embed directly in code if publishing open-source.
240
+ * **Use Context Expansion When Needed:** For short/ambiguous product titles, enable `expand_context`.
241
+ * **Batch Requests:** For large datasets, consider batching requests and handling quota gracefully.
242
+
243
+ ---
244
+
245
+ ## Integration Examples
246
+
247
+ ### Python Example
248
+
249
+ ```python
250
+ from productcategorization import ProductCategorizationAPI
251
+
252
+ api = ProductCategorizationAPI(api_key="your_api_key")
253
+ result = api.categorize_text("Fluorescent Highlighters 3pc Yellow")
254
+ print(result["classification"])
255
+ ```
256
+
257
+ ### JavaScript Example
258
+
259
+ ```javascript
260
+ const apiBaseUrl = "https://www.productcategorization.com/api/ecommerce/ecommerce_category6_get.php?";
261
+ const apiKey = "your_api_key";
262
+ const queryText = "Fluorescent Highlighters 3pc Yellow";
263
+ const encodedQueryText = encodeURIComponent(queryText);
264
+ const finalUrl = `${apiBaseUrl}query=${encodedQueryText}&api_key=${apiKey}`;
265
+
266
+ fetch(finalUrl)
267
+ .then(response => response.json())
268
+ .then(data => console.log(data));
269
+ ```
270
+
271
+ ### Ruby Example
272
+
273
+ ```ruby
274
+ require 'uri'
275
+ require 'net/http'
276
+
277
+ api_base_url = "https://www.productcategorization.com/api/ecommerce/ecommerce_category6_get.php"
278
+ api_key = "your_api_key"
279
+ query_text = "Fluorescent Highlighters 3pc Yellow"
280
+
281
+ encoded_query = URI.encode_www_form_component(query_text)
282
+ url = URI("#{api_base_url}?query=#{encoded_query}&api_key=#{api_key}")
283
+
284
+ response = Net::HTTP.get(url)
285
+ puts response
286
+ ```
287
+
288
+ ### C# Example
289
+
290
+ ```csharp
291
+ using System;
292
+ using System.Net.Http;
293
+ using System.Threading.Tasks;
294
+
295
+ class Program {
296
+ static async Task Main(string[] args) {
297
+ var apiBaseUrl = "https://www.productcategorization.com/api/ecommerce/ecommerce_category6_get.php?";
298
+ var apiKey = "your_api_key";
299
+ var queryText = "Fluorescent Highlighters 3pc Yellow";
300
+ var encodedQueryText = Uri.EscapeDataString(queryText);
301
+ var finalUrl = $"{apiBaseUrl}query={encodedQueryText}&api_key={apiKey}";
302
+
303
+ using (HttpClient client = new HttpClient()) {
304
+ var response = await client.GetStringAsync(finalUrl);
305
+ Console.WriteLine(response);
306
+ }
307
+ }
308
+ }
309
+ ```
310
+
311
+ ---
312
+
313
+ ## Contact & Support
314
+
315
+ Need a higher rate limit, a custom classifier, or additional support?
316
+ Visit [Contact](https://www.productcategorization.com/contact), or email support via your account dashboard.
317
+
318
+ ---
319
+
320
+ ## Related Services
321
+
322
+ Leverage our broader suite of AI-powered APIs to cover every aspect of your business’s data intelligence and privacy needs:
323
+
324
+ * **[Comment Moderation API](https://www.contentmoderationapi.net) – comment moderation api:**
325
+ Safeguard your community, app, or platform with industry-leading AI moderation for comments and user-generated content. Detect profanity, hate speech, spam, and toxicity in real time.
326
+
327
+ * **[Live Video Anonymization](https://www.anomyizationapi.com) – live video anonymization:**
328
+ Protect privacy with automatic anonymization of faces and sensitive objects in live video streams, supporting GDPR compliance and safeguarding user identities.
329
+
330
+ * **[Text Redaction API](https://www.redactionapi.net) – text redaction api:**
331
+ Redact personal data, financial information, or any sensitive fields from documents at scale using our high-precision redaction API.
332
+
333
+ * **[Company Enrichment Data](https://www.companydataapi.com) – company enrichment data:**
334
+ Instantly enhance your CRM, sales, or analytics platform with up-to-date company profiles, firmographics, and contact data.
335
+
336
+ * **[Domain Categorization Data](https://www.urlcategorizationdatabase.com) – domain categorization data:**
337
+ Access the world’s largest database of categorized domains for cybersecurity, web filtering, and content safety.
338
+
339
+ * **[AI Contract Analysis](https://www.aicontractreviewtool.com) – ai contract analysis:**
340
+ Revolutionize contract review workflows with advanced AI-driven contract analysis, risk detection, and compliance assessment.
341
+
342
+ Our APIs integrate seamlessly with your product workflows, providing reliable, scalable, and secure endpoints for your business logic.
343
+
344
+ ---
345
+
346
+ ## References & Further Reading
347
+
348
+ For best-in-class taxonomy, AI, and categorization research, explore:
349
+
350
+ * [Stanford AI Lab](https://ai.stanford.edu)
351
+ * [MIT CSAIL](https://www.csail.mit.edu)
352
+ * [Berkeley AI Research](https://bair.berkeley.edu)
353
+ * [Oxford Internet Institute](https://www.oii.ox.ac.uk)
354
+ * [UCL Centre for Artificial Intelligence](https://www.ucl.ac.uk/ai)
355
+ * [Google AI Blog](https://ai.googleblog.com/)
356
+ * [Microsoft Research](https://www.microsoft.com/en-us/research/)
357
+ * [arXiv Machine Learning](https://arxiv.org/list/cs.LG/recent)
358
+
359
+ For taxonomy standards and e-commerce data:
360
+
361
+ * [Google Shopping Taxonomy](https://support.google.com/merchants/answer/6324436)
362
+ * [Shopify Product Taxonomy](https://github.com/Shopify/product-taxonomy)
363
+
364
+ ---
365
+
366
+ ## License
367
+
368
+ This library is distributed under the MIT License.
369
+
370
+ ---
371
+
372
+ ## Disclaimer
373
+
374
+ This project is unaffiliated with Google, Shopify, or Amazon.
375
+ All trademarks are property of their respective owners.
376
+
377
+ ---
378
+
379
+ # `__init__.py` Example
380
+
381
+ ```python
382
+ import requests
383
+
384
+ class ProductCategorizationAPI:
385
+ def __init__(self, api_key):
386
+ self.api_key = api_key
387
+ self.base_url = "https://www.productcategorization.com/api/"
388
+
389
+ def categorize_text(self, text, confidence=0, expand_context=0):
390
+ params = {
391
+ "query": text,
392
+ "api_key": self.api_key,
393
+ "confidence": str(confidence),
394
+ "expand_context": str(expand_context)
395
+ }
396
+ response = requests.get(self.base_url + "ecommerce/ecommerce_category6_get.php", params=params)
397
+ return response.json()
398
+
399
+ def categorize_url(self, url):
400
+ payload = {
401
+ 'query': url,
402
+ 'api_key': self.api_key,
403
+ 'data_type': 'url'
404
+ }
405
+ headers = {
406
+ 'Content-Type': 'application/x-www-form-urlencoded'
407
+ }
408
+ response = requests.post(self.base_url + "iab/iab_web_content_filtering_url.php", data=payload, headers=headers)
409
+ return response.json()
410
+
411
+ def categorize_image(self, image_url, text="", ip="0", login="0"):
412
+ # Download image to memory
413
+ image_response = requests.get(image_url)
414
+ if image_response.status_code != 200:
415
+ return {'error': 'Failed to download image'}
416
+ import io
417
+ image_file = io.BytesIO(image_response.content)
418
+ data = {
419
+ 'ip': ip,
420
+ 'api_key': self.api_key,
421
+ 'login': login,
422
+ 'text': text
423
+ }
424
+ files = {
425
+ 'image': ('image.jpg', image_file, 'image/jpeg')
426
+ }
427
+ response = requests.post(self.base_url + "ecommerce/ecommerce_shopify_image.php", data=data, files=files)
428
+ return response.json()
429
+ ```
430
+
431
+ ---
432
+
433
+
434
+ Keywords: product categorization,classification,categorization
435
+ Platform: UNKNOWN
436
+ Classifier: License :: OSI Approved :: MIT License
437
+ Classifier: Environment :: GPU :: NVIDIA CUDA :: 11.3
438
+ Classifier: Environment :: GPU :: NVIDIA CUDA :: 11.0
439
+ Classifier: Environment :: GPU :: NVIDIA CUDA
440
+ Classifier: Environment :: GPU :: NVIDIA CUDA :: 11.2
441
+ Classifier: Environment :: GPU :: NVIDIA CUDA :: 10.1
442
+ Classifier: Programming Language :: Python :: 3 :: Only
443
+ Description-Content-Type: text/markdown