Build an Ad Spy Tool With AI: The UI Takes Hours, the Data Is the Hard Part

How to build an ad spy tool with AI in Claude Code, Cursor, Lovable or Bolt: a ready prompt for a Next.js swipe-file app on a winning Meta ads Data API.

The short answer

You can build an ad spy tool with AI in an afternoon: Claude Code, Cursor, Lovable or Bolt will generate the search page, ad cards, video player, brand pages and saved boards in hours. What they cannot generate is the data: daily history, spend estimates, transcripts and tags. Point the build at the Ad Radar Data API and its OpenAPI spec, and the copy-paste prompt below produces a working Next.js swipe-file app on 2,761 winning Meta ads with the key kept server side.

In this article8 sections

What AI builds in hours, and what it can't

If you want to build an ad spy tool with AI, the good news is real: Claude Code, Cursor, Lovable and Bolt are now very good at the visible part. Describe a searchable board of video ads with filters, a detail page and saved collections, and you will have something that looks like Foreplay or Ad Radar by dinner.

The bad news is that the visible part was never the product. An ad spy tool is a data business with a UI on top. Here is how the work actually splits:

PartCan an AI coding tool build it in an afternoon?Why
Search page, filters, ad cards, video playerYesStandard UI, well represented in training data
Ad detail page, brand pages, saved boardsYesCRUD and layout
Auth, billing, deployMostlyWell-documented libraries
Daily collection of every active adNoNeeds a running pipeline, not code that compiles
History (days running, variants over time)NoExists only from the day you start recording; cannot be generated
Spend estimates for commercial adsNoMeta doesn't publish them; you need a model and data to calibrate it
Video transcriptsNoNeeds media you downloaded before Meta's URLs expired, then speech-to-text at scale
Tags (hook, angle, awareness, format)NoNeeds a fixed taxonomy and every ad run through it
Ranking "what's winning"NoNeeds all of the above

The top three rows are the part you can vibe-code. Everything below them is a pipeline that has to run every day, for months, before the first screen is worth looking at. Our ad spy tool architecture guide breaks that pipeline down component by component.

Why "just have the AI scrape the Ad Library" fails

The first instinct is to type "write a scraper for the Facebook Ad Library" into the agent. It will happily produce a Playwright script, and it may even work on the day you test it. Then:

  • The page changes. Scrapers read an interface built for people. When the markup or the internal requests change, the scraper returns nothing, and you find out from an empty board.
  • Anti-bot checks kick in once you run it daily across hundreds of brands, and now you are managing proxies instead of building a product.
  • Media expires. Video and image URLs on Meta's CDN are signed and short-lived. If you didn't download the file during the scrape, the thumbnail is dead within days.
  • There is no spend. Meta's own Ad Library API returns spend only for political and issue ads, and returns commercial ads only if they delivered in the EU.
  • There is no history. Outside the EU, an ad leaves the public library when it stops running. Your tool knows nothing about anything that ran before your first scrape.

None of that is a coding problem an agent can solve in one session. It is an operations problem, and the details are in our scraping guide. The fast path is to skip it: build only the app, and read the data from an API that already did the hard part.

The stack: Next.js on the Ad Radar Data API

The Ad Radar Facebook ads API serves Meta ads (Facebook and Instagram) with $50k+ estimated spend, built from the public Meta Ad Library and refreshed every day. Every ad comes scored, tiered (winner or rising), transcribed and tagged on ten dimensions, with public poster and MP4 URLs served by Ad Radar, so the media never expires on you.

2,761

Meta ads with $50k+ estimated spend

782

brands

10

tag dimensions per ad

OpenAPI 3.1

spec for your AI tool to read

Three properties make it a good fit for AI-built apps:

  1. An OpenAPI 3.1 spec at https://app.ad-radar.dev/api/v1/openapi.json. Give it to the agent and it writes against the real contract: exact field names, parameters and error shapes, instead of guessing.
  2. One object shape everywhere. An ad from /ads/search, /winners or /ads/{key} is the same object, so the agent writes one AdCard component and reuses it.
  3. Plain REST with a Bearer key, JSON responses, cursor pagination with up to 100 results per page, and error bodies with a human-readable error that is safe to show to users.

The endpoints a swipe-file app needs:

EndpointScreen
GET /ads/searchHome: search by text (copy and transcript), brand, format, tier, tags, start dates, min estimated spend; sort by score, spend, days
GET /ads/{key}Ad detail: copy, transcript, tags, signals, media, links
GET /ads?keys=Saved board: up to 100 ads by key in one request
GET /brands, GET /brands/{id}Brand pages: active ads trend, launches, estimated spend trend
GET /brands/{id}/hooksThe brand's hook, mechanism and angle mix
GET /winners?since="New this week" feed
GET /patternsWhat wins more often than the baseline
GET /taxonomyFilter dropdowns

The prompt

Paste this into Claude Code or Cursor's agent in an empty folder. It is written to produce a working app in one pass and to avoid the two classic vibe-coding mistakes: a key in the browser, and invented API fields.

Build a Next.js (App Router, TypeScript, Tailwind) web app called "Swipe": a
searchable swipe file of winning Meta ads, powered by the Ad Radar Data API.

DATA CONTRACT
- Read the OpenAPI 3.1 spec first: https://app.ad-radar.dev/api/v1/openapi.json
  Generate types from it with `npx openapi-typescript <spec-url> -o lib/adradar-types.ts`
  and use ONLY fields and parameters that exist in the spec. Do not invent fields.
- Base URL https://app.ad-radar.dev/api/v1, header `Authorization: Bearer ${AD_RADAR_KEY}`.
- Lists return { data, pagination: { limit, hasMore, nextCursor }, total }.
  Paginate with `cursor` = pagination.nextCursor. Max limit 100.

SECURITY
- Call the API only from server code (server components, route handlers,
  server actions) through one helper in lib/adradar.ts that imports "server-only".
- Read the key from process.env.AD_RADAR_KEY. Never use a NEXT_PUBLIC_ prefix.
  Add .env.local to .gitignore and create .env.example with AD_RADAR_KEY=.
- Cache GET responses with fetch(..., { next: { revalidate: 3600 } }); the data
  refreshes daily.
- Map 429 responses (code quota_exceeded or rate_limited) to a friendly banner;
  show the API's `error` message for other errors.

PAGES
1. "/" Search. A search box (q searches headline, body, brand and transcript),
   filters: format (video/image), tier (winner/rising), min estimated spend,
   started_after, and tag filters built from GET /taxonomy (dimension:value,
   comma separated in the `tags` param). Sort: score, spend, days, recent.
   Results as a responsive grid of AdCards with "Load more" using the cursor.
   Keep all filters in the URL query string so searches are shareable.
2. AdCard: media.poster image (play media.video on click, muted, inline),
   brand, headline, first sentence of transcript (or body) as "Hook",
   "Est. spend $X" (always the word estimated), metrics.daysRunning days,
   metrics.variants variants, tier badge, up to 3 tag labels, a Save button.
3. "/ad/[key]" Detail from GET /ads/{key} (encode the key, it contains ":").
   Full copy, full transcript in a readable column, all tags grouped by
   dimension, signals table, links to links.library and links.landing,
   and a "Copy brief" button that copies a markdown brief: brand, hook,
   script split into hook / body / CTA, tags, est. spend, days running.
4. "/brands/[slug]" from GET /brands/{id} (slug is accepted as id): stats,
   a 90-day sparkline of activeAdsTrend[].active, the 12-week spendTrend,
   the hook mix from GET /brands/{id}/hooks as a bar list, and the brand's
   ads from /ads/search?brand=<slug>&sort=score.
5. "/new" New winners this week: GET /winners?since=<7 days ago, YYYY-MM-DD>.
6. "/saved" Boards. Store ONLY adKeys plus user notes and board names
   (SQLite via Drizzle, file data/swipe.db). Render a board by calling
   GET /ads?keys=<up to 100 comma-separated keys>, and list `missing` keys.
   Do not copy ad content into the database.

QUALITY
- Clean, dense, light UI. Cards in a 4-column grid on desktop, 1 on mobile.
- Loading skeletons, empty states with a suggestion ("try fewer filters").
- No placeholder data and no mock API: every screen reads the real API.
- Add a README with setup steps (npm i, copy .env.example, npm run dev).
When done, run the build, fix all type errors, and tell me which files to read first.

A few choices in that prompt are deliberate:

  • "Use only fields that exist in the spec" plus generated types is what stops the agent from inventing ad.spend or ad.hook fields that don't exist. With types in place, a wrong field is a compile error the agent fixes itself.
  • server-only and no NEXT_PUBLIC_ keep the key out of the browser bundle. Next.js inlines NEXT_PUBLIC_ variables into the JavaScript it ships, so anything with that prefix is public.
  • Store keys, not ads. Saved boards hold adKey and your notes, and fetch fresh data with GET /ads?keys=, which takes up to 100 keys per request. The board always shows the current estimated spend, days running and delivery status, and you are not building a copy of the dataset.
  • Revalidate hourly. The corpus refreshes daily, so caching responses for an hour costs you nothing in freshness and cuts requests sharply.

Using it in each tool

Claude Code

Save the prompt as PROMPT.md in an empty folder and run claude "Follow PROMPT.md". Claude Code reads the spec URL, scaffolds the app, runs the build and fixes type errors in the same session. One extra that helps: connect the Ad Radar MCP server with the same key, so the agent can look at real records while it designs the cards.

claude mcp add --transport http ad-radar https://app.ad-radar.dev/api/mcp \
  --header "Authorization: Bearer $AD_RADAR_KEY"

Then ask it to "call search_ads for three winning video ads and design the AdCard around what you see." It will lay out the card for real headlines, real transcript lengths and real tag counts instead of lorem ipsum.

Cursor

Open an empty folder, switch the chat to Agent mode, and paste the prompt. If the agent doesn't fetch the spec on its own, download it first (curl -o openapi.json https://app.ad-radar.dev/api/v1/openapi.json) and reference the file in the chat. Keep .env.local out of the indexed context.

Lovable and Bolt

Both build full apps from a prompt in the browser, and both default to their own stacks, so drop the Next.js and SQLite lines and keep everything else. The security section matters even more here. Lovable's guide to calling any API says that for an authenticated API it writes a server function (or an edge function in older React and Vite apps) and asks you to add the key as a secret, rather than pasting it into the chat. Do that, and never accept a version that reads the key from a VITE_ variable: Vite bundles those into browser code. The same rule applies in Bolt: the API call belongs in server code, the key in a server-side environment variable.

Round two: prompts that add the features users pay for

Once the first build runs, these follow-up prompts add depth one at a time:

  1. Transcript search with highlights. "On search results, highlight the matched words of q in the hook line and show the sentence of the transcript where they appear."
  2. A patterns page. "Add /patterns from GET /patterns?format=video: a table of doThis values with lift, winnerRate, ads and advertisers, each linking to /?tags=dimension:value."
  3. Brand compare. "Let me pick up to three brands and show their activeAdsTrend sparklines, stats and hook mix side by side."
  4. An AI brief button. "On the ad page, add 'Adapt to my product': a server action that sends the transcript, tags and my product description to Claude and returns a 30-second script that keeps the winner's structure." Our AI agent for Facebook ads guide shows the prompt rules that keep those drafts grounded.
  5. Alerts. "A daily job that calls /winners?since=yesterday with my saved filters and posts new matches to a Slack webhook." The n8n version does the same without code.

Each of these is an hour of AI-assisted work because the hard fields (transcript, tags, lift, trends) already exist in the API response.

What it costs to run

One HTTP call is one request; one page of up to 100 ads is one call. With hourly revalidation, a team of ten browsing all day uses far fewer requests than page views, because repeated searches and ad pages come from the cache. A busy internal swipe file typically sits well inside the Builder quota.

PlanPrice, every 4 weeksRequestsWhat you can build
Builder$29910,000An internal swipe file, or a product that shows the data to your users (no raw redistribution); includes the web app
Scale$79950,000Builder plus /feed, to keep your own mirror in sync incrementally, and a higher rate limit
ResellerFrom $2,000CustomFull NDJSON /export, resale and white-label

Over quota the API returns a 429 with an upgrade link, never an overage charge, and X-Quota-Remaining on every response lets the app warn you early. Full terms are on the pricing section, and every parameter is in the API docs.

Set that against the alternative. The scraper version of this app needs a scraping budget, workers, storage for every video, a transcription bill, an LLM tagging pass, and above all months of daily snapshots before "days running" or "winner" mean anything. No prompt shortens the months.

Ship the app, not the pipeline

AI made the interface cheap. It did not make the data cheap, and the data is what your users come back for. The fastest way to build an ad spy tool with AI is to let Claude Code, Cursor, Lovable or Bolt write the app, and to feed it a corpus that is already ranked, transcribed and tagged. Start on Builder, paste the prompt above, and by tonight you have a swipe file of 2,761 winning Meta ads your team can search by what the ads actually say.

Figures marked as estimated spend come from Ad Radar's model of engagement on public Meta Ad Library ads. They are estimates, labeled as such, and are best used to rank ads against each other. How the board is built.

FAQ

Questions

Can I build an ad spy tool with AI?

Yes, the app part. AI coding tools such as Claude Code, Cursor, Lovable and Bolt can generate a search interface, ad cards, video playback, filters, brand pages and saved boards in a few hours. The hard part is the data behind it: collecting ads daily, keeping history, estimating spend, transcribing videos and tagging them. Using a data API such as Ad Radar's skips that part.

Why not ask the AI to scrape the Facebook Ad Library?

It will write a scraper that works on the day you test it. Then the page changes, anti-bot checks kick in, the Meta media URLs expire, and you still have no spend for commercial ads, no transcripts, no tags and no history before your first run. A scraper is a pipeline to maintain, not a feature the AI can finish in one prompt.

How do I keep my API key safe in a vibe-coded app?

Call the API only from server code: a Next.js route handler or server component, a Lovable server or edge function, or your backend. Store the key as a server-side secret. Never give it a NEXT_PUBLIC_ or VITE_ prefix, because those values are bundled into the JavaScript that ships to the browser.

Which AI tool is best to build an ad spy tool?

Claude Code and Cursor are best when you want a real codebase you own, for example a Next.js app you deploy yourself; both can read an OpenAPI spec and write typed clients. Lovable and Bolt are faster for a first visual prototype in the browser. The prompt in this article works in all four with small changes.

What can I do with Ad Radar data inside my own app?

On the Builder plan you can use the data inside your product and show it to your users, without redistributing the raw data. Scale adds an incremental feed and higher rate limits. Reselling or white-labeling the data requires the Reseller plan.

Ad data and APIs

Keep reading

All 22 articles in Ad data and APIs

Build on ads that are already winning.

Skip the scraping, storage, transcription and tagging. Query the corpus from your code or your agent.

Builder: 10,000 requests every 4 weeks over REST and MCP, $299. Scale and Reseller for bigger volumes.