Metadata-Version: 2.4
Name: bt-network-api
Version: 0.1.0
Summary: FastAPI REST service exposing Bittensor network data via the Bittensor SDK
License: MIT License
        
        Copyright (c) 2026 SUMON2026
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Requires-Python: <3.15,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: bittensor<11.0,>=10.5.0
Requires-Dist: fastapi>=0.110.1
Requires-Dist: uvicorn
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: httpx>=0.27.0; extra == "dev"
Requires-Dist: ruff>=0.15.12; extra == "dev"
Requires-Dist: mypy>=1.20.2; extra == "dev"
Dynamic: license-file

# bt-network-api

A FastAPI REST service exposing Bittensor network data through the
[Bittensor SDK](https://pypi.org/project/bittensor/).

## Features

- Chain status and network data over HTTP
- Mock mode for offline development and testing
- Configurable network, host, and port

## Endpoints

| Route | Description |
| --- | --- |
| `GET /` | Service index |
| `GET /health` | Liveness check |
| `GET /block` | Current chain block number |
| `GET /subnets` | All subnet info |
| `GET /neurons/{netuid}` | Neurons on a subnet |
| `GET /metagraph/{netuid}` | Metagraph of a subnet |
| `GET /delegates` | Delegate identities |
| `GET /staking/{address}` | Stake info for a coldkey address |

## Install

```bash
pip install bt-network-api
```

## Usage

```bash
# Install from source
uv sync --extra dev

# Run the server (defaults to 0.0.0.0:8091)
uv run bt-network-api --host 0.0.0.0 --port 8091

# Or via uvicorn
uv run uvicorn bt_network_api.app:app --host 0.0.0.0 --port 8091
```

Verify it is running:

```bash
curl -s http://localhost:8091/health
```

## Configuration

Environment variables:

| Variable | Default | Description |
| --- | --- | --- |
| `BT_API_NETWORK` | `finney` | Bittensor network name |
| `BT_API_MOCK` | `0` | Use mock data (`1`) instead of the live chain |

## Development

```bash
uv run ruff format --check src tests
uv run ruff check src
uv run mypy src/
uv run pytest
uv build
```
