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

# Quickstart

> Make your first trade using the Aggregation API, from quote request to on-chain settlement.

This guide shows how to request a quote, approve tokens, and broadcast the settlement transaction.

<Info>
  **What you will build:** A complete trade flow that uses solver auction liquidity.

  **Time required:** 10-15 minutes

  **Prerequisites:** Basic knowledge of EVM wallets and token approvals.
</Info>

## How It Differs from the RFQ API

The RFQ API provides firm market maker quotes with guaranteed execution and fill.

The Aggregation API runs a solver auction across on-chain liquidity sources. It supports more tokens but requires a slippage tolerance.

| | RFQ API | Aggregation API |
| - | - | - |
| Liquidity source | Direct market maker quotes | Solver auction across DEXs and aggregators |
| Token coverage | Major pairs | Broad, including long-tail assets |
| Slippage | None | Configurable tolerance |
| Execution | You broadcast the transaction | You broadcast the transaction |
| Base URL | `/pmm/{network}/v3/` | `/jam/{network}/v2/` |

## 1. Request a Quote

```text theme={null}
GET /jam/{network}/v2/quote
```

Required parameters:

| Parameter | Description | Example |
| - | - | - |
| `sell_tokens` | Token addresses that you sell | `0xC02a...` (WETH) |
| `buy_tokens` | Token addresses that you buy | `0xA0b8...` (USDC) |
| `sell_amounts` or `buy_amounts` | Amounts in base units. Use one field. | `1000000000000000000` |
| `taker_address` | Address that supplies the sell tokens | `0xYourWalletAddress` |

Optional parameters:

| Parameter | Description | Default |
| - | - | - |
| `approval_type` | Use `Standard` | `Standard` |
| `slippage` | Maximum acceptable slippage from 0% to 50% | Solver value |
| `receiver_address` | Address that receives the bought tokens | `taker_address` |

<Accordion title="Choosing sell_amounts or buy_amounts">
  * Use `sell_amounts` when you know the exact sell amount.
  * Use `buy_amounts` when you know the exact buy amount.
</Accordion>

The following example sells 1 WETH for USDC on Ethereum:

```python theme={null}
import httpx
from eth_account import Account
from web3 import Web3

NETWORK = "ethereum"
PRIVATE_KEY = "0x<your_private_key>"
RPC_URL = "https://eth.llamarpc.com"

w3 = Web3(Web3.HTTPProvider(RPC_URL))
account = Account.from_key(PRIVATE_KEY)

response = httpx.get(
    f"https://api.bebop.xyz/jam/{NETWORK}/v2/quote",
    params={
        "sell_tokens": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "buy_tokens": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "sell_amounts": "1000000000000000000",
        "taker_address": account.address,
    },
)
response.raise_for_status()
quote = response.json()
```

### Understand the Response

The response includes the winning solver price and a ready-to-broadcast `tx` object.

```json theme={null}
{
  "requestId": "76c0e766-5894-4f20-8799-515f7f9fe0d3",
  "status": "Success",
  "quoteId": "dbddb28f-d459-4a7e-8d53-d29dc74946ab",
  "chainId": 1,
  "approvalType": "Standard",
  "taker": "0x2e7E7c...e9693",
  "receiver": "0x2e7E7c...e9693",
  "expiry": 1773827406,
  "slippage": 0.1,
  "buyTokens": {
    "0xA0b869...eB48": {
      "amount": "2330815183",
      "minimumAmount": "2328484367",
      "decimals": 6,
      "symbol": "USDC"
    }
  },
  "sellTokens": {
    "0xC02aaA...6Cc2": {
      "amount": "1000000000000000000",
      "decimals": 18,
      "symbol": "WETH"
    }
  },
  "settlementAddress": "0xbeb0b0...4ea6",
  "approvalTarget": "0xC5a350...579a",
  "solver": "solver-name",
  "tx": {
    "chainId": 1,
    "from": "0x2e7E7c...e9693",
    "to": "0xbeb0b0...4ea6",
    "value": "0x0",
    "data": "0x2143d82c...",
    "gas": 906396
  }
}
```

| Field | Description |
| - | - |
| `quoteId` | Quote identifier for logs and support requests |
| `solver` | Solver that won the auction |
| `expiry` | Unix timestamp after which the transaction is invalid |
| `buyTokens.minimumAmount` | Minimum output that the transaction enforces |
| `approvalTarget` | Contract that must have a token allowance |
| `tx` | Complete transaction that you sign and broadcast |

<Warning>
  Always approve the `approvalTarget` from the current quote. Do not use the `settlementAddress` as the approval target.
</Warning>

## 2. Approve Tokens

Approve the `approvalTarget` before you broadcast the settlement transaction.

```python theme={null}
sell_token = list(quote["sellTokens"].keys())[0]
sell_amount = int(quote["sellTokens"][sell_token]["amount"])
approval_target = quote["approvalTarget"]

# Check the allowance and approve when necessary.
# See the Token Approvals guide for the complete implementation.
```

See [Token Approvals](/core-concepts/token-approvals) for the complete allowance flow.

## 3. Broadcast the Transaction

Use the `tx` object from the quote response. Add current fee and nonce values before you sign it.

```python theme={null}
tx = quote["tx"]
if tx["from"].lower() != account.address.lower():
    raise ValueError("The quote taker does not match the signing account")
tx |= {
    "nonce": w3.eth.get_transaction_count(account.address),
    "gas": max(quote["tx"]["gas"], 500_000),
    "gasPrice": int(w3.eth.gas_price * 1.5),
}

signed_tx = w3.eth.account.sign_transaction(tx, account.key)
tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
print(f"Transaction: {tx_hash.hex()}")
```

Broadcast the transaction before `expiry`. The transaction reverts after that time.

## 4. Confirm Settlement

Wait for the transaction receipt through your RPC provider.

```python theme={null}
receipt = w3.eth.wait_for_transaction_receipt(tx_hash, timeout=120)

if receipt["status"] != 1:
    raise RuntimeError("Settlement transaction reverted")

print(f'Settled in block {receipt["blockNumber"]}')
```

## Full Example

```python theme={null}
import httpx
from eth_account import Account
from web3 import Web3

PRIVATE_KEY = "0x<your_private_key_hex>"
NETWORK = "ethereum"
RPC_URL = "https://eth.llamarpc.com"

w3 = Web3(Web3.HTTPProvider(RPC_URL))
account = Account.from_key(PRIVATE_KEY)

response = httpx.get(
    f"https://api.bebop.xyz/jam/{NETWORK}/v2/quote",
    params={
        "sell_tokens": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        "buy_tokens": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "sell_amounts": "1000000000000000000",
        "taker_address": account.address,
    },
)
response.raise_for_status()
quote = response.json()

# Approve quote["approvalTarget"] before this step when necessary.
tx = quote["tx"]
tx |= {
    "nonce": w3.eth.get_transaction_count(account.address),
    "gas": max(tx["gas"], 500_000),
    "gasPrice": int(w3.eth.gas_price * 1.5),
}

signed_tx = w3.eth.account.sign_transaction(tx, PRIVATE_KEY)
tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash, timeout=120)

if receipt["status"] != 1:
    raise RuntimeError("Settlement transaction reverted")

print(f'Transaction: {tx_hash.hex()}')
print(f'Settled in block {receipt["blockNumber"]}')
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Token Approvals" icon="key" href="/core-concepts/token-approvals">
    Set up ERC-20 approvals before trading.
  </Card>

  <Card title="RFQ API Quickstart" icon="bolt" href="/rfq-api/quickstart">
    Compare solver competition with firm market maker pricing.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.