Metadata-Version: 2.1
Name: pymerc
Version: 0.4.0
Summary: A Python library for interacting with the Mercatorio browser based game
Home-page: https://github.com/jmgilman/pymerc
License: MIT
Keywords: mercatorio,python,library,game
Author: Joshua Gilman
Author-email: joshuagilman@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: asyncio (>=3.4.3,<4.0.0)
Requires-Dist: httpx[http2] (>=0.27.0,<0.28.0)
Requires-Dist: loguru (>=0.7.2,<0.8.0)
Requires-Dist: pydantic (>=2.7.1,<3.0.0)
Description-Content-Type: text/markdown

# Pymerc

> A Python library for interacting with the [Mercatorio] browser based game

## Usage

You must first [generate API credentials](https://play.mercatorio.io/settings/api).
Once generated, you can instantiate a `Client` instance using the credentials.

```python
from pymerc.client import Client

# Create a new client
client = Client(os.environ["API_USER"], os.environ["API_TOKEN"])

# Interact with the various API endpoints
towns = await client.towns.all()
for town in towns:
    print(town.name)
```

## Testing

Since this library parses live API endpoints, mocking values makes little sense.
Instead, you must provide a `.env` file with your API credentials:

```text
API_USER="<USER>"
API_TOKEN="<TOKEN>"
```

The tests will utilize this to validate that all endpoints are parsing correctly:

```shell
pytest .
```

Additionally, you can create an instance of the client to test with using `ipython`:

```shell
> ipython
In [1]: from shell import main
In [2]: await main()
In [3]: from shell import client
In [4]: # Use the client as needed
```

[Mercatorio]: https://mercatorio.io
