Metadata-Version: 2.4
Name: py-modelshop
Version: 1.0.1
Summary: Python client for the Modelshop REST API
Author-email: Modelshop <contact@modelshop.com>
License-Expression: MIT
Project-URL: Homepage, https://www.modelshop.com
Keywords: modelshop,data,analytics,pandas,dataframe
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
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: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: pandas

# py-modelshop

Python client for the [Modelshop](https://www.modelshop.com) REST API. Load datalists as pandas DataFrames, discover models, and inspect schemas.

## Install

```bash
pip install py-modelshop
```

## Quick Start

```python
from py_modelshop import Modelshop

ms = Modelshop(
    domain='https://demo.modelshop.com',
    model_owner='demo',
    model='My Model',
    user='demo',
    password='demo'
)

# Discover available data
print(ms.list_datalists())
print(ms.list_views())

# Load a datalist as a pandas DataFrame
df = ms.datalist('Loan')
print(df.describe())

# Inspect field schema
print(ms.schema('Loan'))
```

## Authentication

**Basic Auth** — provide `user` and `password`:

```python
ms = Modelshop('https://demo.modelshop.com', 'demo',
               model='My Model', user='demo', password='demo')
```

**Access Token** — provide a pre-authorized token (no credentials needed):

```python
ms = Modelshop('https://demo.modelshop.com', 'demo',
               model='My Model', access_token='a1b2c3d4-...')
```

If neither is provided, you'll be prompted for credentials interactively.

## API Reference

### Discovery

| Method | Returns | Description |
|--------|---------|-------------|
| `ms.list_datalists()` | `list[str]` | Names of all datalists in the model |
| `ms.list_views(datalist=None)` | `list[str]` | Names of all views, optionally filtered by datalist |
| `ms.schema(name)` | `dict` | Field names and types for a datalist or view |

### Data Access

| Method | Returns | Description |
|--------|---------|-------------|
| `ms.datalist(name, limit=None, filters=None)` | `DataFrame` | Load a datalist as a pandas DataFrame |
| `ms.get(model, view, output='dict')` | varies | Legacy method — retrieve records as dict, DataFrame, or JSON |
| `ms.put(model, view, payload)` | `dict` | Update records in a view |

### Loading Data

```python
# Full datalist
df = ms.datalist('Loan')

# Limited rows
df = ms.datalist('Loan', limit=1000)

# Filtered
df = ms.datalist('Loan', filters=[
    {'fieldName': 'Status', 'operator': '=', 'value': 'Active'}
])
```

Column names use natural field names (e.g., `df['Loan Amount']`, not `df['loanAmount']`).

## Requirements

- Python 3.8+
- requests
- pandas
