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

# Kalshi Quote

> Get an unsigned Kalshi transaction from DFlow. Step 1 of the quote → sign → submit BYOW flow.

Returns an **unsigned Solana transaction** from DFlow. The agent signs it locally and submits via `POST /kalshi/agent/submit`. Your private key never leaves your machine.

## Notes

* Agent-only endpoint. Requires Bearer API key in `Authorization` header.
* Supports `BUY` (amount in USDC) and `SELL` (shares).
* Server resolves market token mints from DFlow metadata automatically.
* Response is raw JSON (not wrapped by global ApiResponse interceptor).
* If `quoteErrorCode` is present, the quote is degraded — no unsigned transaction is available.

## Request fields

| Field               | Type   | Required      | Description                                            |
| ------------------- | ------ | ------------- | ------------------------------------------------------ |
| `marketTicker`      | string | Yes           | Kalshi market ticker, e.g. `KXHIGHNY-26FEB19-T70`      |
| `side`              | string | Yes           | `YES` or `NO`                                          |
| `action`            | string | Yes           | `BUY` or `SELL`                                        |
| `amount`            | number | BUY required  | Buy amount in USDC (min 0.000001)                      |
| `shares`            | number | SELL required | Sell shares (min 0.000001)                             |
| `userPublicKey`     | string | No            | Solana wallet address (overrides agent's sol\_address) |
| `destinationWallet` | string | No            | Destination wallet for received tokens                 |

## Example

<Tabs>
  <Tab title="curl">
    ```bash theme={null}
    curl -X POST "https://www.aionmarket.com/bvapi/kalshi/agent/quote" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "marketTicker": "KXHIGHNY-26FEB19-T70",
        "side": "YES",
        "action": "BUY",
        "amount": 10,
        "userPublicKey": "8Yj7Dfp8oS3wkt2uP12xMz9VfF7ZzBv4qfB8Zbe8vXJ1"
      }'
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python theme={null}
    from aion_sdk import AionMarketClient

    client = AionMarketClient(
        api_key="YOUR_API_KEY",
        base_url="https://www.aionmarket.com/bvapi",
    )

    quote = client.kalshi_quote(
        market_ticker="KXHIGHNY-26FEB19-T70",
        side="YES",
        action="BUY",
        amount=10,
        user_public_key="8Yj7Dfp8oS3wkt2uP12xMz9VfF7ZzBv4qfB8Zbe8vXJ1",
    )

    # Check for quote errors before proceeding
    if quote.get("quoteErrorCode"):
        print(f"Quote error: {quote['quoteErrorCode']} - {quote.get('quoteErrorMessage', '')}")
    else:
        quote_id = quote["quoteId"]
        unsigned_tx = quote["unsignedTransaction"]
    ```
  </Tab>
</Tabs>

<Warning>
  Quotes expire in **\~2 minutes**. Sign and call `POST /kalshi/agent/submit` promptly.
  If the quote expires, request a new one.
</Warning>

## Response

```json theme={null}
{
  "marketTicker": "KXHIGHNY-26FEB19-T70",
  "title": "Will NYC high be above 70F on Feb 19?",
  "status": "active",
  "side": "YES",
  "action": "BUY",
  "yesPrice": "0.6500",
  "noPrice": "0.3500",
  "yesMint": "6JYgs7EJFc5oQZiWAH1mMzEFEfAdCBGnM4y7rD3P6dS4",
  "noMint": "7NykYSMXd3QxjxeRgp3TD1MmwhNwhebZcxes9T2uYLMV",
  "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "outputMint": "6JYgs7EJFc5oQZiWAH1mMzEFEfAdCBGnM4y7rD3P6dS4",
  "scaledAmount": "10000000",
  "quoteId": "quote_1713604800000_42",
  "unsignedTransaction": "AQAB...",
  "expiresAt": 1713604920000,
  "inAmount": "10000000",
  "outAmount": "15384615",
  "minOutAmount": "14615384"
}
```

| Response field        | Type   | Description                                                |
| --------------------- | ------ | ---------------------------------------------------------- |
| `marketTicker`        | string | Echoed market ticker                                       |
| `title`               | string | Market question title                                      |
| `status`              | string | Market status (e.g. `active`, `settled`)                   |
| `side`                | string | `YES` or `NO`                                              |
| `action`              | string | `BUY` or `SELL`                                            |
| `yesPrice`            | string | Current YES price                                          |
| `noPrice`             | string | Current NO price                                           |
| `yesMint`             | string | YES outcome token mint address                             |
| `noMint`              | string | NO outcome token mint address                              |
| `inputMint`           | string | Input token mint for this trade (USDC or outcome token)    |
| `outputMint`          | string | Output token mint for this trade (outcome token or USDC)   |
| `scaledAmount`        | string | Trade amount in atomic units (6 decimals)                  |
| `quoteId`             | string | Server-generated quote ID — pass to `/kalshi/agent/submit` |
| `unsignedTransaction` | string | Base64-encoded unsigned Solana transaction from DFlow      |
| `expiresAt`           | number | Quote expiry timestamp in milliseconds                     |
| `inAmount`            | string | DFlow actual input amount (scaled, 6 decimals). Optional   |
| `outAmount`           | string | DFlow estimated output amount (scaled). Optional           |
| `minOutAmount`        | string | DFlow minimum output with slippage protection. Optional    |
| `quoteErrorCode`      | string | Error code when DFlow cannot build transaction. Optional   |
| `quoteErrorMessage`   | string | Human-readable error message. Optional                     |


## OpenAPI

````yaml POST /kalshi/agent/quote
openapi: 3.1.0
info:
  title: Aion AI Agent API
  description: >-
    API for agent registration, wallet onboarding, market discovery, order
    management, and execution on Aion.
  version: 1.0.0
  contact:
    name: Aion Support
    email: info@aionmarket.com
    url: https://docs.aionmarket.com
servers:
  - url: https://www.aionmarket.com/bvapi
    description: Aion API
security:
  - bearerAuth: []
tags:
  - name: Agent Management
  - name: Market Operations
  - name: Order Management
  - name: Trading
  - name: Kalshi
  - name: Skills
  - name: Wallet Management
  - name: Trades & Leaderboard
  - name: Utilities
  - name: Settings
  - name: Positions & Portfolio
  - name: Fee Charging
paths:
  /kalshi/agent/quote:
    post:
      tags:
        - Kalshi
      summary: Kalshi Quote
      description: >-
        Generate an unsigned Kalshi transaction via DFlow. BUY with
        userPublicKey triggers KYC and geo checks; omitting userPublicKey allows
        preview mode.
      operationId: kalshiQuote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KalshiQuoteRequest'
      responses:
        '200':
          description: Unsigned Kalshi quote
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KalshiQuoteResponse'
components:
  schemas:
    KalshiQuoteRequest:
      type: object
      required:
        - marketTicker
        - side
        - action
      properties:
        marketTicker:
          type: string
          description: Kalshi market ticker
          example: KXHIGHNY-26FEB19-T70
          maxLength: 120
        side:
          type: string
          description: Trade direction
          enum:
            - 'YES'
            - 'NO'
            - 'yes'
            - 'no'
        action:
          type: string
          description: Order action
          enum:
            - BUY
            - SELL
            - buy
            - sell
        amount:
          type: number
          description: BUY order amount in USDC (required when action=BUY, min 0.000001)
          example: 10
        shares:
          type: number
          description: SELL share quantity (required when action=SELL, min 0.000001)
          example: 5
        userPublicKey:
          type: string
          description: User Solana wallet address
          example: 8Yj7Dfp8oS3wkt2uP12xMz9VfF7ZzBv4qfB8Zbe8vXJ1
          maxLength: 128
        destinationWallet:
          type: string
          description: Destination wallet for received tokens
          maxLength: 128
    KalshiQuoteResponse:
      type: object
      properties:
        quoteId:
          type: string
        expiresAt:
          type: string
        unsignedTransaction:
          type: string
        previewOnly:
          type: boolean
        kycRequired:
          type: boolean
        geoblocked:
          type: boolean
        venue:
          type: string
        marketId:
          type: string
        side:
          type: string
        action:
          type: string
        amount:
          type: string
        shares:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      x-default: YOUR_API_KEY

````