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

# Identify a Market From a Mint

> Reverse-lookup a market and side from any ledger or outcome mint address

<Info>
  During development, you can use the [developer endpoints](/get-started/endpoints) without an API key. For production use, [request an API key](/get-started/api-key) for higher rate limits.
</Info>

Each market has **outcome mints** (YES and NO, the SPL tokens users hold to take a side) and a **ledger mint** (the market's onchain accounting account). Given any of them, the recipe returns the market and the mint's role.

## Resolve a market by mint

<AccordionGroup>
  <Accordion title="Look up a market and detect side">
    ```typescript theme={null}
    import "dotenv/config";

    const DFLOW_METADATA_API_URL = process.env.DFLOW_METADATA_API_URL ?? "https://dev-prediction-markets-api.dflow.net";
    const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpoints
    const DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC

    const headers: HeadersInit = {};
    if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;

    const mintAddress = "OUTCOME_OR_LEDGER_MINT_ADDRESS";

    const market = await fetch(
      `${DFLOW_METADATA_API_URL}/api/v1/market/by-mint/${mintAddress}`,
      { headers }
    ).then((r) => r.json());

    if (!market.accounts) {
      throw new Error(`No market found for mint "${mintAddress}". Replace with a real outcome or ledger mint. Response: ${JSON.stringify(market)}`);
    }

    const accounts = market.accounts[DFLOW_SETTLEMENT_MINT];

    const role =
      mintAddress === accounts.yesMint ? "YES outcome token"
      : mintAddress === accounts.noMint ? "NO outcome token"
      : mintAddress === accounts.marketLedger ? "market ledger"
      : "unknown";

    console.log(market.ticker, role);
    console.log("  title:", market.title);
    console.log("  status:", market.status);
    console.log("  result:", market.result || "<undetermined>");
    console.log("  redemptionStatus:", accounts.redemptionStatus ?? "<not open>");
    ```
  </Accordion>
</AccordionGroup>

<Tip>
  `market.accounts` is keyed by settlement mint. If you support multiple, iterate `Object.entries(market.accounts)` instead.
</Tip>

## Forecast history from the same mint

<AccordionGroup>
  <Accordion title="Fetch historical forecast percentiles">
    ```typescript theme={null}
    const now = Math.floor(Date.now() / 1000);
    const dayAgo = now - 24 * 60 * 60;

    const params = new URLSearchParams({
      percentiles: "2500,5000,7500",
      startTs: dayAgo.toString(),
      endTs: now.toString(),
      periodInterval: "60",
    });

    const history = await fetch(
      `${DFLOW_METADATA_API_URL}/api/v1/event/by-mint/${mintAddress}/forecast_percentile_history?${params}`,
      { headers }
    ).then((r) => r.json());

    console.log(JSON.stringify(history, null, 2));
    ```
  </Accordion>
</AccordionGroup>

<Note>
  Response is relayed verbatim from Kalshi.
</Note>

## Related Resources

<CardGroup cols={2}>
  <Card title="Find Markets" href="/prediction-markets/recipes/find-markets" icon="search">
    Discover markets by category, tag, status, or series.
  </Card>

  <Card title="Bulk Fetch Markets" href="/prediction-markets/recipes/bulk-fetch-markets" icon="layer-group">
    Hydrate multiple markets and outcome mints in one call.
  </Card>

  <Card title="Monitor Market Lifecycle" href="/prediction-markets/recipes/monitor-market-lifecycle" icon="clock">
    Track status changes and know when redemption opens.
  </Card>

  <Card title="Prediction Market Data Model" href="/prediction-markets/prediction-market-data-model" icon="diagram-project">
    Events, markets, outcomes, mints, and how they relate.
  </Card>
</CardGroup>

## API Routes

* [`GET /api/v1/market/by-mint/{mint_address}`](/resources/metadata-api/markets/market-by-mint)
* [`GET /api/v1/event/by-mint/{mint_address}/forecast_percentile_history`](/resources/metadata-api/events/forecast-percentile-history-by-mint)
