# refget v2 Quickstart

## Installation

```bash
pip install "ai4gh[refget]"
```

## Get a Reference Sequence

```python
import asyncio
from ai4gh.specs.refget.client import RefgetClient


async def main():
    async with RefgetClient(base_url="https://refget.example.org") as client:
        # Get sequence by checksum
        sequence = await client.get_sequence("ga4gh:SQ.abc123")
        print(f"Sequence (first 100bp): {sequence[:100]}")

        # Get sequence metadata
        metadata = await client.get_metadata("ga4gh:SQ.abc123")
        print(f"Length: {metadata.length}")
        print(f"Aliases: {metadata.aliases}")


asyncio.run(main())
```

## Subsequence Retrieval

```python
async with RefgetClient(base_url="https://refget.example.org") as client:
    # Get a specific range
    subseq = await client.get_sequence(
        "ga4gh:SQ.abc123",
        start=1000,
        end=2000,
    )
    print(f"Subsequence length: {len(subseq)}")
```

## Compliance Testing

```bash
ai4gh test refget https://refget.example.org
```

## MCP Tool

```json
{
  "tool": "refget_sequence",
  "arguments": {
    "base_url": "https://refget.example.org",
    "checksum": "ga4gh:SQ.abc123"
  }
}
```

## Data Models

```python
from ai4gh.specs.refget.models import SequenceMetadata, ServiceInfo
```
