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

# Cryptocurrency Prices

> Get real-time cryptocurrency prices and market data

## Endpoint

<CodeGroup>
  ```bash GET Request theme={null}
  GET /api/v1/crypto
  ```

  ```bash cURL Example theme={null}
  curl "https://stocks-dev.up.railway.app/api/v1/crypto?limit=20"
  ```

  ```python Python theme={null}
  import requests

  response = requests.get("https://stocks-dev.up.railway.app/api/v1/crypto", params={"limit": 50})
  data = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://stocks-dev.up.railway.app/api/v1/crypto?limit=20');
  const data = await response.json();
  ```
</CodeGroup>

## Parameters

<ParamField query="limit" type="integer" default="20">
  Number of cryptocurrencies to return (max 100)
</ParamField>

## Response

<ResponseField name="cryptocurrencies" type="array">
  Array of cryptocurrency data

  <Expandable title="Crypto Object">
    <ResponseField name="symbol" type="string">
      Cryptocurrency symbol (e.g., BTC, ETH)
    </ResponseField>

    <ResponseField name="name" type="string">
      Full cryptocurrency name
    </ResponseField>

    <ResponseField name="price" type="number">
      Current price in USD
    </ResponseField>

    <ResponseField name="change" type="number">
      24-hour price change in USD
    </ResponseField>

    <ResponseField name="changesPercentage" type="number">
      24-hour percentage change
    </ResponseField>

    <ResponseField name="marketCap" type="number">
      Market capitalization
    </ResponseField>

    <ResponseField name="volume" type="number">
      24-hour trading volume
    </ResponseField>

    <ResponseField name="rank" type="number">
      Market cap ranking
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="timestamp" type="string">
  Response timestamp in ISO format
</ResponseField>

## Example Response

```json theme={null}
{
  "cryptocurrencies": [
    {
      "symbol": "BTC",
      "name": "Bitcoin",
      "price": 43250.00,
      "change": 1250.50,
      "changesPercentage": 2.98,
      "marketCap": 850000000000,
      "volume": 28500000000,
      "rank": 1
    },
    {
      "symbol": "ETH",
      "name": "Ethereum",
      "price": 2650.75,
      "change": -125.25,
      "changesPercentage": -4.51,
      "marketCap": 320000000000,
      "volume": 15200000000,
      "rank": 2
    },
    {
      "symbol": "BNB",
      "name": "Binance Coin",
      "price": 315.80,
      "change": 15.60,
      "changesPercentage": 5.20,
      "marketCap": 48500000000,
      "volume": 1800000000,
      "rank": 3
    }
  ],
  "timestamp": "2025-06-28T18:42:12.471731"
}
```

## Use Cases

<AccordionGroup>
  <Accordion title="Crypto Portfolio Tracking">
    Monitor cryptocurrency holdings and performance:

    ```python theme={null}
    def track_crypto_portfolio(holdings):
        response = requests.get("/api/v1/crypto", params={"limit": 100})
        all_cryptos = {crypto["symbol"]: crypto for crypto in response.json()["cryptocurrencies"]}
        
        portfolio_value = 0
        for symbol, amount in holdings.items():
            if symbol in all_cryptos:
                crypto = all_cryptos[symbol]
                value = crypto["price"] * amount
                portfolio_value += value
                print(f"{symbol}: ${value:,.2f} ({crypto['changesPercentage']:+.2f}%)")
        
        return portfolio_value

    holdings = {"BTC": 0.5, "ETH": 2.0, "BNB": 10}
    total_value = track_crypto_portfolio(holdings)
    ```
  </Accordion>

  <Accordion title="Market Analysis">
    Analyze cryptocurrency market trends:

    ```python theme={null}
    def analyze_crypto_market():
        response = requests.get("/api/v1/crypto", params={"limit": 50})
        cryptos = response.json()["cryptocurrencies"]
        
        gainers = [c for c in cryptos if c["changesPercentage"] > 0]
        losers = [c for c in cryptos if c["changesPercentage"] < 0]
        
        print(f"Gainers: {len(gainers)}, Losers: {len(losers)}")
        print(f"Top gainer: {max(gainers, key=lambda x: x['changesPercentage'])['symbol']}")
        print(f"Top loser: {min(losers, key=lambda x: x['changesPercentage'])['symbol']}")
    ```
  </Accordion>

  <Accordion title="Price Alerts">
    Set up price monitoring and alerts:

    ```python theme={null}
    def check_price_alerts(alerts):
        response = requests.get("/api/v1/crypto")
        cryptos = {c["symbol"]: c for c in response.json()["cryptocurrencies"]}
        
        triggered_alerts = []
        for symbol, target_price, condition in alerts:
            if symbol in cryptos:
                current_price = cryptos[symbol]["price"]
                if (condition == "above" and current_price > target_price) or \
                   (condition == "below" and current_price < target_price):
                    triggered_alerts.append({
                        "symbol": symbol,
                        "current_price": current_price,
                        "target_price": target_price,
                        "condition": condition
                    })
        
        return triggered_alerts

    alerts = [("BTC", 45000, "above"), ("ETH", 2500, "below")]
    triggered = check_price_alerts(alerts)
    ```
  </Accordion>
</AccordionGroup>

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Market Gainers" icon="trending-up" href="/api-reference/market/gainers">
    Traditional stock market gainers
  </Card>

  <Card title="Currency Rates" icon="exchange-alt" href="/api-reference/fmp/currencies">
    Foreign exchange rates
  </Card>
</CardGroup>
