> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monei.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Offramp Services

> Manage crypto-to-fiat swaps, track transaction history, and handle payouts using the Monei Python SDK

# Overview

The `Offramp Services` provides a full suite of services for converting crypto to fiat, tracking transactions, and managing payout accounts.

Included services:

* **Exchange** — retrieve assets, get quotes, and initiate swaps
* **Ledger** — view transaction history and track orders
* **Payouts** — retrieve supported banks and verify bank accounts

All services require a properly configured `MoneiClient` instance.

> **Note**: All methods return response objects with attributes accessible via dot notation (e.g., `assets.data`, `quote.fiat_amount`).

***

## Offramp Exchange

`monei.offramp_exchange` allows you to retrieve available assets, get crypto-to-fiat quotes, and initiate swaps.

### Get Offramp Assets

Retrieve a list of assets available for offramp transactions.

```python theme={null}
assets = monei.offramp_exchange.get_assets()

print(assets)
```

### Get Crypto-to-Fiat Quote

Retrieve a quote for swapping crypto to fiat.

```python theme={null}
quote_request = {
    "crypto": "USDT",
    "fiat": "NGN",
    "amount": 100
}

quote = monei.offramp_exchange.get_quote(quote_request)

print(quote)
```

### Initiate Swap

Initiate a crypto-to-fiat swap.

```python theme={null}
swap_data = {
    "crypto": "USDT",
    "fiat": "NGN",
    "amount": 100,
    "destination_bank_account": "1234567890"
}

order = monei.offramp_exchange.initiate_swap(swap_data)

print(order)
```

***

## Offramp Ledger

`monei.offramp_ledger` provides methods to track transaction history and order statuses.

### Get Offramp Transactions

Retrieve a paginated list of offramp transactions.

```python theme={null}
request_data = {
    "user_id": "user-123",
    "page": 1,
    "limit": 10
}

transactions = monei.offramp_ledger.get_transactions(request_data)

print(transactions)
```

### Track Order

Track an individual order by reference.

```python theme={null}
reference = "order-123"

order_details = monei.offramp_ledger.track_order(reference)

print(order_details)
```

***

## Offramp Payouts

`monei.offramp_payouts` provides methods to retrieve supported banks and verify payout accounts.

### Get Offramp Banks

Retrieve a list of supported payout banks.

```python theme={null}
banks = monei.offramp_payouts.get_banks()

print(banks)
```

### Verify Offramp Bank Account

Verify a bank account before initiating a payout.

```python theme={null}
verify_data = {
    "account_number": "0123456789",
    "bank_code": "057"
}

verification = monei.offramp_payouts.verify_bank_account(verify_data)

print(verification)
```

***

## Working with Response Objects

All methods return objects with attribute access:

```python theme={null}
# Get assets response
assets = monei.offramp_exchange.get_assets()
for asset in assets.data:
    print(asset.symbol)       # Asset symbol (e.g., "USDT")
    print(asset.name)         # Asset name (e.g., "Tether USD")
    print(asset.decimals)     # Token decimals
    print(asset.min_amount)   # Minimum swap amount
    print(asset.max_amount)   # Maximum swap amount

# Get quote response
quote = monei.offramp_exchange.get_quote({
    "crypto": "USDT",
    "fiat": "NGN",
    "amount": 100
})
print(quote.crypto_amount)     # Amount of crypto to send
print(quote.fiat_amount)       # Expected fiat amount
print(quote.exchange_rate)     # Exchange rate
print(quote.fee)               # Service fee
print(quote.total_amount)      # Total fiat after fees
print(quote.expires_at)        # Quote expiration time

# Initiate swap response
order = monei.offramp_exchange.initiate_swap({
    "crypto": "USDT",
    "fiat": "NGN",
    "amount": 100,
    "destination_bank_account": "1234567890"
})
print(order.id)                 # Order ID
print(order.reference)          # Order reference
print(order.status)             # Order status
print(order.crypto_amount)      # Crypto amount
print(order.fiat_amount)        # Fiat amount
print(order.bank_account)       # Destination bank account
print(order.created_at)         # Creation date

# Get transactions response
transactions = monei.offramp_ledger.get_transactions({
    "user_id": "user-123",
    "page": 1,
    "limit": 10
})
for tx in transactions.data:
    print(tx.id)                # Transaction ID
    print(tx.reference)         # Transaction reference
    print(tx.type)              # Transaction type
    print(tx.crypto_amount)     # Crypto amount
    print(tx.fiat_amount)       # Fiat amount
    print(tx.status)            # Transaction status
    print(tx.created_at)        # Creation date
print(transactions.pagination)  # Pagination info
print(transactions.pagination.total)     # Total count
print(transactions.pagination.page)      # Current page
print(transactions.pagination.limit)     # Items per page

# Track order response
order_details = monei.offramp_ledger.track_order("order-123")
print(order_details.id)            # Order ID
print(order_details.reference)     # Order reference
print(order_details.status)        # Current status
print(order_details.crypto_amount) # Crypto amount
print(order_details.fiat_amount)   # Fiat amount
print(order_details.bank_account)  # Destination bank account
print(order_details.tx_hash)       # Transaction hash
print(order_details.confirmations) # Block confirmations
print(order_details.updated_at)    # Last update date

# Get banks response
banks = monei.offramp_payouts.get_banks()
for bank in banks.data:
    print(bank.name)          # Bank name
    print(bank.code)          # Bank code
    print(bank.country)       # Country code

# Verify bank account response
verification = monei.offramp_payouts.verify_bank_account({
    "account_number": "0123456789",
    "bank_code": "057"
})
print(verification.account_number)  # Verified account number
print(verification.account_name)    # Account holder name
print(verification.bank_name)       # Bank name
print(verification.bank_code)       # Bank code
print(verification.verified)        # Verification status
```

***

## Response Types

### AssetDto

```python theme={null}
{
    "symbol": str,
    "name": str,
    "decimals": int,
    "min_amount": float,
    "max_amount": float
}
```

### OfframpQuoteResponseDto

```python theme={null}
{
    "crypto_amount": float,
    "fiat_amount": float,
    "exchange_rate": float,
    "fee": float,
    "total_amount": float,
    "expires_at": str
}
```

### OfframpOrderResponseDto

```python theme={null}
{
    "id": str,
    "reference": str,
    "status": "pending" | "processing" | "completed" | "failed",
    "crypto_amount": float,
    "fiat_amount": float,
    "bank_account": str,
    "created_at": str
}
```

### OfframpTransactionDto

```python theme={null}
{
    "id": str,
    "reference": str,
    "type": str,
    "crypto_amount": float,
    "fiat_amount": float,
    "status": str,
    "created_at": str
}
```

### BankDto

```python theme={null}
{
    "name": str,
    "code": str,
    "country": str
}
```

### VerifyBankAccountResponseDto

```python theme={null}
{
    "account_number": str,
    "account_name": str,
    "bank_name": str,
    "bank_code": str,
    "verified": bool
}
```

***

## Error Handling

All offramp service calls may raise an exception if the request fails.

```python theme={null}
from monei import MoneiError

try:
    quote = monei.offramp_exchange.get_quote({
        "crypto": "USDT",
        "fiat": "NGN",
        "amount": 100
    })
    print(quote.fiat_amount)
except MoneiError as err:
    print(err.status_code)  # HTTP status code
    print(err.message)      # Error message
    print(err.code)         # Error code
```

***

## Service Overview

| Service      | Method                      | Description                  |
| ------------ | --------------------------- | ---------------------------- |
| **Exchange** | `get_assets()`              | Retrieve available assets    |
|              | `get_quote(request)`        | Get crypto-to-fiat quote     |
|              | `initiate_swap(data)`       | Initiate crypto-to-fiat swap |
| **Ledger**   | `get_transactions(request)` | Get offramp transactions     |
|              | `track_order(reference)`    | Track order by reference     |
| **Payouts**  | `get_banks()`               | Get supported payout banks   |
|              | `verify_bank_account(data)` | Verify bank account          |

***

## Notes

* All requests require a properly configured `MoneiClient` with authentication
* Always validate input data and ensure the correct crypto/fiat codes before initiating swaps
* Quotes expire after a certain period - obtain a fresh quote before swapping
* Bank account verification is recommended before initiating payouts
* All responses are strongly typed objects with attribute access

***
