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