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

# Metadata

> Fetch and parse IPFS metadata.

Markets store extended information in IPFS. The TypeScript SDK provides utilities for fetching this metadata.

***

## Fetch Metadata (TypeScript)

```typescript theme={"dark"}
const market = await sdk.orica.fetchMarket(marketAddress);
const metadata = await sdk.orica.fetchIpfsMetadata(market.metadataUri);

if (metadata) {
  console.log("Question:", metadata.question);
  console.log("Options:", metadata.options);
  console.log("Resolution Method:", metadata.resolution_method);
  console.log("Close Date:", new Date(metadata.close_date * 1000));
  console.log("Reasoning:", metadata.reasoning);
  console.log("Image URL:", metadata.image_url);
}
```

***

## Fetch Market with Metadata (TypeScript)

```typescript theme={"dark"}
// Single market
const market = await sdk.orica.fetchMarketWithMetadata(marketAddress, {
  includeMetadata: true,
  metadataTimeout: 10000,
});

console.log("Account:", market.account.question);
console.log("Metadata:", market.metadata?.reasoning);

// All markets
const markets = await sdk.orica.fetchAllMarkets({
  includeMetadata: true,
  metadataTimeout: 5000,
});

for (const { publicKey, account, metadata } of markets) {
  console.log(account.question);
  if (metadata) {
    console.log("  Image:", metadata.image_url);
  }
}
```

***

## Metadata Structure

```typescript theme={"dark"}
interface MarketMetadata {
  question: string;           // Full question text
  options: string[];          // Outcome labels
  resolution_method: string;  // How the market will be resolved
  close_date: number;         // Unix timestamp
  reasoning: string;          // Market description/context
  image_url: string | null;   // HTTP image URL
  image_ipfs_hash: string | null; // IPFS image hash
  creator: string;            // Creator identifier
  created_at: number;         // Creation timestamp
}
```

***

## Fetch Options

```typescript theme={"dark"}
interface FetchOptions {
  /** Fetch and include IPFS metadata */
  includeMetadata?: boolean;
  
  /** Timeout in ms for IPFS fetch (default: 5000) */
  metadataTimeout?: number;
}
```

***

## Manual Metadata Fetch

If you need custom handling:

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> async function fetchMetadata(uri: string): Promise<any | null> {
>   if (!uri) return null;
>
>   try {
>     const controller = new AbortController();
>     const timeoutId = setTimeout(() => controller.abort(), 5000);
>
>     const response = await fetch(uri, {
>       signal: controller.signal,
>       headers: { Accept: "application/json" },
>     });
>
>     clearTimeout(timeoutId);
>
>     if (!response.ok) return null;
>     return response.json();
>   } catch {
>     return null;
>   }
> }
>
> const market = await sdk.orica.fetchMarket(marketAddress);
> const metadata = await fetchMetadata(market.metadataUri);
> ```

> [tab] Python
>
> ```python theme={"dark"}
> import httpx
>
> async def fetch_metadata(uri: str) -> dict | None:
>     if not uri:
>         return None
>
>     try:
>         async with httpx.AsyncClient(timeout=5.0) as client:
>             response = await client.get(uri, headers={"Accept": "application/json"})
>             if response.status_code != 200:
>                 return None
>             return response.json()
>     except Exception:
>         return None
>
> market = await sdk.orica.fetch_market(market_address)
> metadata = await fetch_metadata(market.metadata_uri)
> ```

***

## IPFS Gateways

The metadata URI typically points to an IPFS gateway. Common gateways:

| Gateway | URL Pattern |
| - | - |
| Pinata | `https://gateway.pinata.cloud/ipfs/{hash}` |
| Cloudflare | `https://cloudflare-ipfs.com/ipfs/{hash}` |
| IPFS.io | `https://ipfs.io/ipfs/{hash}` |

***

## Next Steps

> [card] [Markets](https://docs.orica.markets/sdk/markets.md)
>
> Fetch market data.

> [card] [Types](https://docs.orica.markets/sdk/types.md)
>
> Complete type definitions.


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