# Use Underdog data in Lovable.

> Connect a Lovable app to live Underdog lines. A copy-paste prompt that stores your API key as a secret, calls the API from a backend function and caches the board. Underdog API (https://underdogapi.com) is an independent Underdog Fantasy pick'em data API: Higher/Lower lines with separate payout multipliers per side, line history, changes and graded results as JSON, CSV, MCP and streams.

Canonical page: https://underdogapi.com/use-with-lovable

## Free offer

**Free API key, no card: 100 credits a month** on the live board, every league, separate Higher/Lower prices, and the last 24 hours of line history. Sign up: https://underdogapi.com/sign-up?ref=ai-claudebot

## Quickstart

1. Get a free key at https://underdogapi.com/sign-up?ref=ai-claudebot (no card), or let your agent request one: `POST https://underdogapi.com/api/v1/agent/signup` with `data_wanted` and `use_case`, then show your user the returned approval_url.
2. Export it: `export UNDERDOG_API_KEY=ud_...`
3. First call with curl:

```bash
curl --fail-with-body 'https://underdogapi.com/api/v1/projections?league=NBA&view=compact&limit=5' \
  -H "Authorization: Bearer $UNDERDOG_API_KEY" \
  -H 'X-User-Request: NBA dashboard integration check'
```

4. Same call in Python:

```python
import os, requests

r = requests.get(
    "https://underdogapi.com/api/v1/projections",
    params={"league": "NBA", "view": "compact", "limit": 5},
    headers={"Authorization": f"Bearer {os.environ['UNDERDOG_API_KEY']}"},
)
r.raise_for_status()
for line in r.json()["data"]:
    print(line["player"]["name"], line["market"]["stat"], line["line"])
```

## Use it from Claude (MCP)

Claude Code, one command:

```bash
claude mcp add --transport http underdog https://underdogapi.com/api/mcp --header "Authorization: Bearer $UNDERDOG_API_KEY"
```

Or add this server to your Claude MCP configuration (the key stays in the environment):

```json
{
  "mcpServers": {
    "underdog": {
      "type": "http",
      "url": "https://underdogapi.com/api/mcp",
      "headers": {
        "Authorization": "Bearer ${UNDERDOG_API_KEY}"
      }
    }
  }
}
```

Guide: https://underdogapi.com/use-with-claude

## Pricing

| Plan | Price | Credits / month | Notes |
| --- | --- | --- | --- |
| Free | $0 | 100 | No card. Live feed 5 minutes behind; last 24 hours of line history |
| Developer | $49/month | 10,000 | For models that need full training pages and loaded game-log seasons. Live feed, no added plan delay |
| Production | $149/month | 50,000 | For apps with real users and push delivery. Everything in Developer, signed webhooks for every change |
| Scale | $499/month | 250,000 | For apps whose traffic has outgrown Production. Everything in Production, 15 live-feed connections at once |

Full pricing: https://underdogapi.com/pricing

## On this page

Guide



One prompt gives your app collected lines with observation times, with the key stored as a secret. Steps follow Lovable's documentation as of 1 November 2026.

Short answer: In Lovable, build the app to call the Underdog REST API from a server function with your key stored as a secret; never put the key in browser code.

## Set it up

1. [Create a free account](https://underdogapi.com/sign-up) and copy an API key from your [workspace](https://underdogapi.com/dashboard/keys).
2. Open your Lovable project and paste the prompt below into the project chat.
3. When Lovable asks for `UNDERDOG_API_KEY`, enter it in the **Add secret** form. Do not type it in the chat.
4. Open the preview and check the table shows a recent **Lines as of** time.
5. Ask Lovable to show the logs for `underdog-board` if the table is empty. A 401 means the key is wrong, so save it again in the project's secrets.

Prompt

```
Connect this app to the Underdog API.

Docs: https://underdogapi.com/llms.txt
Spec: https://underdogapi.com/openapi.json
Auth: Bearer token in the Authorization header.

Secret: ask me for the key with the Add secret form and save it as UNDERDOG_API_KEY. Do not ask me to paste it in chat. Never put it in a VITE_ variable, the frontend, the repo or a URL.

Create one backend function named underdog-board that:
1. Takes an optional league, default NBA.
2. Calls GET https://underdogapi.com/api/v1/projections?league={league}&limit=100&view=compact with Authorization: Bearer from the backend secret and X-User-Request describing the dashboard operation. Omit secrets and personal data; disclose once that summaries are retained for 35 days.
3. Starts with one page. If meta.next_cursor is not null, show that results are partial and offer Load more. Follow the cursor only on that explicit action, keeping filters fixed. Deduplicate by id.
4. On HTTP 429, show the actual quota or rate-limit code and keep any saved rows explicitly labeled with their original observation time. Do not retry monthly exhaustion. Use bounded backoff for transient server failures. Never declare an empty or failed response a successful populated integration.
5. Caches by exact request URL for 5 minutes, so repeated page views do not make upstream calls. Revalidate with its ETag; reuse the saved body on HTTP 304. Read X-Usage-Unit and the remaining allowance. Page size affects credit cost; a 100-row compact projection page costs 1 credit on new plans.
6. Returns { rows, observed_at, source_status, next_cursor, partial } from data and meta. Show source health and original times alongside the table.

The frontend calls only this function, never https://underdogapi.com directly.

Each compact row includes a stable id, sport, player, team, stat, period, line, higher_mult, lower_mult, higher_available, lower_available, opponent, starts_at, status and observed_at. Keep the exact schema from OpenAPI; never infer one side’s availability or price from the other.

Build a table of the rows with filters for sport, stat and payout_tier and a search on player. Show "Lines as of {observed_at}" above it, and a notice if source_status is not fresh. Add this footer: "Data from underdogapi.com. Not affiliated with Underdog. Information, not betting advice."

When you finish, tell me how to confirm the function works.
```

`limit=100&view=compact` starts with a bounded page. Keep partial results visible and load more only when needed. Lovable does not copy manually added secrets when you remix a project, so enter the key again in the new one.

## Let Lovable see the data while it builds

Optional. This gives the Lovable chat live lines to work from, and is separate from your published app.

1. Open [Connectors](https://lovable.dev/dashboard?connectors), select **Add custom**, then **MCP server**.
2. Name it `Underdog` and enter the server URL below.
3. Choose **Bearer token or API key** and enter your key.
4. Select **Add server**.

Server URL

```
https://underdogapi.com/api/mcp
```

## Questions

Why a backend function instead of calling the API from the page?

Anything in the frontend reaches the browser, including a VITE_ variable, and anyone could copy your key. Lovable keeps secrets in the backend and hands them to edge functions at runtime.

What does this starter consume?

It starts with one 100-row compact projection page, costing one credit on new plans. More pages require an explicit Load more action. The five-minute cache reduces repeated upstream calls but adds display delay. Existing request contracts can differ; inspect your usage unit and allowance.

Can my published Lovable app use the MCP server?

No. Lovable says custom MCP servers give context in the project chat only. The published app calls the REST API through the function in the prompt.

A step no longer matches what you see? Tell us and we will fix this page.

[Runnable example **Build a comparison dashboard**](https://underdogapi.com/docs/league-workflows) [Guide **Use with ChatGPT** *Paste the board, connect the MCP server or add a GPT Action.*](https://underdogapi.com/use-with-chatgpt) [Docs **API reference** *Endpoints, filters and errors.*](https://underdogapi.com/docs) [Pricing **Plans and request limits**](https://underdogapi.com/pricing)

## References

- [Lovable: Integrate any API](https://docs.lovable.dev/integrations/any-api)
- [Lovable: Secrets](https://docs.lovable.dev/features/secrets)
- [Lovable: Edge functions](https://docs.lovable.dev/features/edge-functions)
- [Lovable: Connect a custom MCP server](https://docs.lovable.dev/integrations/custom-mcp)

## FAQ

### Is there a free Underdog API?

Yes. The Free plan is a real API key on the live board, not a sample: 100 credits a month, every league, separate Higher/Lower prices and the last 24 hours of line history. No card is needed.

### Is this the official Underdog Fantasy API?

No. Underdog API is an independent data service. It is not affiliated with, endorsed by or sponsored by Underdog Fantasy or Underdog Sports.

### What data does it return?

Underdog Higher/Lower lines with separate payout multipliers and availability for each side, stable market ids through line moves, alternate rungs, recorded line history, changes, graded results and coverage/status endpoints.

### How do I use it from Claude or another AI agent?

Connect the MCP server at https://underdogapi.com/api/mcp with a bearer key, or call the REST API. Agents can request a key for their user with POST /api/v1/agent/signup.

### How much does it cost after the free tier?

Developer is $49/month for 10,000 credits, Production $149/month for 50,000, Scale $499/month for 250,000. Errors and unchanged 304 responses cost zero credits.

### How fresh is the data?

Each row carries its observation time. Check /api/v1/status and /api/v1/coverage before relying on a sport or window; missing collection is reported as unavailable, never filled in.

### Does it place entries or give picks?

No. It is data only: no entries, account operations, guaranteed outcomes or betting advice.

---
Independent data service, not affiliated with Underdog Fantasy or Underdog Sports. Docs: https://underdogapi.com/docs · OpenAPI: https://underdogapi.com/openapi.json · llms.txt: https://underdogapi.com/llms.txt
