Metadata-Version: 2.4
Name: mrc-data
Version: 0.1.0
Summary: Official SDK for MRC Data — China's apparel supply chain API
Project-URL: Homepage, https://meacheal.ai
Project-URL: Documentation, https://docs.meacheal.ai
Project-URL: Repository, https://github.com/mrc-data/mrc-data-python
Project-URL: Issues, https://github.com/mrc-data/mrc-data-python/issues
Author-email: MRC Data <dev@meacheal.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: api,apparel,china,mcp,mrc-data,supply-chain
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24
Description-Content-Type: text/markdown

# mrc-data

Official Python SDK for [MRC Data](https://meacheal.ai) -- China's apparel supply chain API.

Access 1,000+ verified suppliers, 350+ fabric specifications, and 170+ industrial clusters across China, each enriched with independent lab measurements (AATCC, ISO, GB).

## Installation

```bash
pip install mrc-data
```

## Quick start

```python
from mrc_data import MRCData

client = MRCData(api_key="your-api-key")

# Search suppliers in Guangzhou
suppliers = client.search_suppliers(city="Guangzhou", certification="BSCI")

# Get supplier details
detail = client.get_supplier_detail("sup_abc123")

# Search fabrics by composition
fabrics = client.search_fabrics(composition="cotton", weight_min=150)

# Compare industrial clusters
comparison = client.compare_clusters(ids=["cls_humen", "cls_shaoxing"])

# Detect specification discrepancies
result = client.detect_discrepancy(supplier_id="sup_abc123", fabric_id="fab_xyz")

# Database statistics
stats = client.get_stats()
```

## Async usage

```python
import asyncio
from mrc_data import AsyncMRCData

async def main():
    async with AsyncMRCData(api_key="your-api-key") as client:
        suppliers = await client.search_suppliers(province="Guangdong")
        fabrics = await client.search_fabrics(weave="twill")
        print(suppliers)

asyncio.run(main())
```

## API methods

| Method | Endpoint | Description |
|---|---|---|
| `search_suppliers(**kwargs)` | `GET /v1/suppliers` | Search suppliers with filters |
| `get_supplier_detail(id)` | `GET /v1/suppliers/{id}` | Get a single supplier |
| `get_supplier_fabrics(id)` | `GET /v1/suppliers/{id}/fabrics` | List fabrics by supplier |
| `search_fabrics(**kwargs)` | `GET /v1/fabrics` | Search fabrics with filters |
| `get_fabric_detail(id)` | `GET /v1/fabrics/{id}` | Get a single fabric |
| `get_fabric_suppliers(id)` | `GET /v1/fabrics/{id}/suppliers` | List suppliers for a fabric |
| `search_clusters(**kwargs)` | `GET /v1/clusters` | Search industrial clusters |
| `compare_clusters(ids)` | `POST /v1/clusters/compare` | Compare clusters side by side |
| `get_stats()` | `GET /v1/stats` | Aggregate database statistics |
| `detect_discrepancy(**kwargs)` | `POST /v1/discrepancy` | Detect spec discrepancies |

## Error handling

```python
from mrc_data import MRCData, AuthenticationError, NotFoundError, RateLimitError

client = MRCData(api_key="your-api-key")

try:
    detail = client.get_supplier_detail("sup_invalid")
except AuthenticationError:
    print("Check your API key")
except NotFoundError:
    print("Supplier not found")
except RateLimitError:
    print("Slow down -- rate limit exceeded")
```

## Configuration

```python
client = MRCData(
    api_key="your-api-key",
    base_url="https://api.meacheal.ai",  # default
    timeout=60.0,                         # seconds, default 30
)
```

Both `MRCData` and `AsyncMRCData` support context managers for automatic cleanup of the underlying HTTP connection pool.

## License

MIT
