Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with eBay API

To integrate eBay with Lovable, create Supabase Edge Functions that authenticate with eBay's OAuth2 system and proxy calls to eBay Browse, Inventory, and Fulfillment APIs. Store your eBay App ID and Client Secret in Cloud Secrets. This lets you build listing management tools, inventory dashboards, and order sync workflows directly in Lovable.

What you'll learn

  • How to create an eBay developer account and register an application to get API credentials
  • How to implement eBay OAuth2 client credentials flow in a Supabase Edge Function
  • How to use eBay Browse API to search and display listings from the eBay marketplace
  • How to manage eBay inventory listings using the Inventory API via Edge Functions
  • How to sync eBay orders to Supabase for centralized order management
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate13 min read60 minutesE-commerceMarch 2026RapidDev Engineering Team
TL;DR

To integrate eBay with Lovable, create Supabase Edge Functions that authenticate with eBay's OAuth2 system and proxy calls to eBay Browse, Inventory, and Fulfillment APIs. Store your eBay App ID and Client Secret in Cloud Secrets. This lets you build listing management tools, inventory dashboards, and order sync workflows directly in Lovable.

Connect Lovable to eBay for Marketplace Listing and Order Management

eBay's marketplace reaches over 135 million active buyers worldwide, making it a powerful channel for product sellers. Building a custom management interface in Lovable lets your team handle eBay listing creation, inventory updates, and order processing from a purpose-built dashboard — rather than navigating eBay's dense seller hub interface.

The integration uses eBay's Open Platform APIs, which are organized into distinct API groups. The Browse API (public data, requires only App ID token) lets you search eBay listings and display product information. The Inventory API (requires user OAuth token) lets you create, update, and delete your own eBay listings. The Fulfillment API (requires user OAuth token) lets you retrieve and manage orders placed on eBay. Because these APIs require proper OAuth2 authentication, all calls must route through Supabase Edge Functions rather than being made directly from React components.

eBay provides a Sandbox environment for testing — a separate set of credentials and a test marketplace at sandbox.ebay.com where you can create test listings and orders without real money. Always build and test against the Sandbox first, then switch credentials to production. This guide covers the Application Token flow (suitable for Browse API) and points you toward the User Token flow needed for selling operations.

Integration method

Edge Function Integration

eBay API integration in Lovable uses Supabase Edge Functions to handle eBay's OAuth2 authentication and proxy API calls to eBay's Browse, Inventory, and Fulfillment APIs. Your eBay App ID and Client Secret are stored in Cloud Secrets and accessed via Deno.env.get(). The Edge Function fetches an OAuth2 application token (for public data like Browse API) or guides through user token flow (for selling/fulfillment operations) and caches tokens to avoid repeated auth calls.

Prerequisites

  • An eBay developer account at developer.ebay.com — free to create with any eBay account
  • An eBay application registered in the eBay Developer Program to obtain App ID, Dev ID, and Cert ID
  • An eBay Sandbox account for testing (auto-created when you register as an eBay developer)
  • A Lovable project with Lovable Cloud enabled
  • An eBay seller account if you plan to use Inventory or Fulfillment APIs (selling features)

Step-by-step guide

1

Register an eBay application and get credentials

Go to developer.ebay.com and sign in with your eBay account. Navigate to the 'My Account' section and select 'Application Access Keys'. Click 'Create a Keyset' and choose 'REST API'. Fill in the Application Title with something like 'Lovable Integration', select the appropriate environment (Sandbox for testing, Production for live use), and click 'Submit'. eBay will generate three credential pairs: App ID (Client ID), Dev ID, and Cert ID (Client Secret). The most important values are the App ID and Cert ID — these are what you will use for OAuth2. eBay also assigns a different App ID for Sandbox vs Production, so keep track of which environment each set belongs to. The Sandbox environment uses the prefix 'SBX-' in its URLs and credentials. If you plan to use Inventory or Fulfillment APIs (which require a user OAuth token, not just an application token), you also need to set up OAuth2 redirect URIs in your eBay application settings under 'User Tokens'. For this guide's Browse API usage, only the Application Token flow is needed and no redirect URI is required.

Pro tip: Start with the eBay Sandbox environment. Sandbox credentials work with sandbox.ebay.com and will not affect real listings or orders.

Expected result: You have an eBay App ID (Client ID) and Cert ID (Client Secret) for either Sandbox or Production environment.

2

Add eBay credentials to Cloud Secrets

In your Lovable project, click the '+' icon next to the Preview panel to open the Cloud tab, then locate the Secrets section. Add two secrets for your eBay credentials. Click 'Add Secret' and enter EBAY_CLIENT_ID as the name, then paste your eBay App ID as the value. Add another secret named EBAY_CLIENT_SECRET and paste your Cert ID value. If you are building for the eBay Sandbox first (strongly recommended), also add EBAY_ENVIRONMENT with value sandbox — your Edge Function can use this to switch between https://api.sandbox.ebay.com and https://api.ebay.com base URLs. These secrets are encrypted at rest and only accessible from Edge Functions via Deno.env.get(). Lovable's security system blocks approximately 1,200 hardcoded API keys per day and the SOC 2 Type II certified infrastructure ensures your eBay credentials are handled securely. Never paste your eBay Cert ID in a Lovable chat message or in any frontend code — it must live exclusively in Cloud Secrets.

Pro tip: eBay has separate App IDs and Cert IDs for Sandbox and Production. When you go live, update EBAY_CLIENT_ID and EBAY_CLIENT_SECRET with the production values and set EBAY_ENVIRONMENT to production.

Expected result: EBAY_CLIENT_ID, EBAY_CLIENT_SECRET, and EBAY_ENVIRONMENT secrets appear in your Cloud Secrets panel.

3

Create the eBay OAuth2 token and API proxy Edge Function

Ask Lovable to create a Supabase Edge Function that handles eBay's OAuth2 Client Credentials flow to obtain an Application Token, then uses that token to proxy requests to the eBay Browse API. The Edge Function needs to POST to eBay's token endpoint with your Client ID and Client Secret encoded as Base64 Basic Auth, request the 'https://api.ebay.com/oauth/api_scope' scope, and cache the returned access_token for its 7,200-second lifetime. For production implementations, store the token and its expiry in Supabase so you do not request a new token on every function invocation. The Edge Function should then accept an 'endpoint' parameter specifying which eBay API to call (e.g., /buy/browse/v1/item_summary/search) and forward any query parameters. The eBay Sandbox token URL is https://api.sandbox.ebay.com/identity/v1/oauth2/token and the Production URL is https://api.ebay.com/identity/v1/oauth2/token.

Lovable Prompt

Create a Supabase Edge Function called ebay-proxy that first fetches an OAuth2 Application Token from eBay using EBAY_CLIENT_ID and EBAY_CLIENT_SECRET from Deno.env.get(). The token endpoint is https://api.sandbox.ebay.com/identity/v1/oauth2/token (use sandbox for now). Then use that token to call eBay Browse API endpoints. Accept 'endpoint' and 'q' query parameters to forward to eBay. Return the eBay JSON response with CORS headers.

Paste this in Lovable chat

supabase/functions/ebay-proxy/index.ts
1import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
2
3const corsHeaders = {
4 "Access-Control-Allow-Origin": "*",
5 "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
6};
7
8let cachedToken: { token: string; expiry: number } | null = null;
9
10async function getEbayToken(): Promise<string> {
11 if (cachedToken && Date.now() < cachedToken.expiry) {
12 return cachedToken.token;
13 }
14
15 const clientId = Deno.env.get("EBAY_CLIENT_ID")!;
16 const clientSecret = Deno.env.get("EBAY_CLIENT_SECRET")!;
17 const env = Deno.env.get("EBAY_ENVIRONMENT") || "sandbox";
18 const tokenUrl = env === "production"
19 ? "https://api.ebay.com/identity/v1/oauth2/token"
20 : "https://api.sandbox.ebay.com/identity/v1/oauth2/token";
21
22 const credentials = btoa(`${clientId}:${clientSecret}`);
23 const response = await fetch(tokenUrl, {
24 method: "POST",
25 headers: {
26 "Authorization": `Basic ${credentials}`,
27 "Content-Type": "application/x-www-form-urlencoded",
28 },
29 body: "grant_type=client_credentials&scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope",
30 });
31
32 const data = await response.json();
33 if (!response.ok) throw new Error(data.error_description || "eBay token request failed");
34
35 cachedToken = {
36 token: data.access_token,
37 expiry: Date.now() + (data.expires_in - 60) * 1000,
38 };
39 return cachedToken.token;
40}
41
42serve(async (req) => {
43 if (req.method === "OPTIONS") {
44 return new Response("ok", { headers: corsHeaders });
45 }
46
47 try {
48 const env = Deno.env.get("EBAY_ENVIRONMENT") || "sandbox";
49 const baseUrl = env === "production" ? "https://api.ebay.com" : "https://api.sandbox.ebay.com";
50 const token = await getEbayToken();
51
52 const url = new URL(req.url);
53 const endpoint = url.searchParams.get("endpoint") || "/buy/browse/v1/item_summary/search";
54 url.searchParams.delete("endpoint");
55
56 const ebayUrl = new URL(`${baseUrl}${endpoint}`);
57 url.searchParams.forEach((value, key) => {
58 ebayUrl.searchParams.set(key, value);
59 });
60
61 const response = await fetch(ebayUrl.toString(), {
62 headers: {
63 "Authorization": `Bearer ${token}`,
64 "Content-Type": "application/json",
65 "X-EBAY-C-MARKETPLACE-ID": "EBAY_US",
66 },
67 });
68
69 const data = await response.json();
70 return new Response(JSON.stringify(data), {
71 status: response.status,
72 headers: { ...corsHeaders, "Content-Type": "application/json" },
73 });
74 } catch (error) {
75 return new Response(
76 JSON.stringify({ error: error.message }),
77 { status: 500, headers: { ...corsHeaders, "Content-Type": "application/json" } }
78 );
79 }
80});

Pro tip: Module-level variable caching (cachedToken) persists across warm Edge Function invocations, reducing unnecessary token requests to eBay.

Expected result: The ebay-proxy Edge Function is deployed and appears in Cloud → Edge Functions.

4

Build an eBay product search component

With the Edge Function deployed, ask Lovable to create a React component that calls the Edge Function to search eBay listings using the Browse API. The Browse API's /buy/browse/v1/item_summary/search endpoint accepts a q parameter for search query, limit for number of results, offset for pagination, and filter for narrowing results by condition, price range, or category. The response contains an itemSummaries array with each item having itemId, title, price (value and currency), condition, image (imageUrl), itemWebUrl (link to eBay listing), and seller information. The component should show a search input, display results as cards with item image, title, price, and condition, and link each card to the live eBay listing. Note that in Sandbox mode, the Browse API returns test data which may appear generic — this is expected behavior.

Lovable Prompt

Build an EbaySearch React component that calls my ebay-proxy Edge Function to search eBay listings. Show a search input field and search button. When the user searches, call the Edge Function with endpoint=/buy/browse/v1/item_summary/search and pass their query as q=. Display results as cards showing item image, title, price with currency, condition, and an 'View on eBay' link. Show loading state and error handling.

Paste this in Lovable chat

Pro tip: The X-EBAY-C-MARKETPLACE-ID header controls which eBay marketplace to search (EBAY_US, EBAY_GB, EBAY_DE, etc.). Match this to your target audience.

Expected result: The search component returns eBay listings matching the user's query, displayed as cards with images and prices.

5

Store and display eBay order data in Supabase

For order management use cases, you need to extend the integration to use eBay's Fulfillment API with a user OAuth token (not just the application token used for Browse API). The Fulfillment API requires going through eBay's user authorization flow where the seller clicks an authorization URL, grants access to your application, and eBay redirects back with an authorization code you exchange for a user access token. This token grants permission to read and manage that specific eBay seller's orders. Store the user access token and refresh token in Supabase (in a secure table with appropriate RLS policies) rather than in Cloud Secrets, since it belongs to a specific user. Your Edge Function for Fulfillment API calls should read the stored token from Supabase, refresh it if expired using the refresh token and eBay's token endpoint, then call the Fulfillment API. The /sell/fulfillment/v1/order endpoint returns a list of orders with buyer details, line items, pricing, and shipping addresses. Sync these to a Supabase orders table for centralized management and to build order status dashboards.

Lovable Prompt

Create an orders dashboard page that calls my ebay-proxy Edge Function with endpoint=/sell/fulfillment/v1/order to fetch recent eBay orders. Display each order in a table showing order ID, creation date, buyer username, total amount, line item count, and fulfillment status. Add a Sync button that refreshes the orders. Store synced orders in a Supabase table called ebay_orders.

Paste this in Lovable chat

Pro tip: eBay user tokens expire after 18 months but access tokens expire after 2 hours — implement token refresh logic using the stored refresh token to maintain seamless access.

Expected result: An orders dashboard shows eBay orders synced to Supabase, with a working sync button.

Common use cases

eBay product search and price comparison tool

Use the eBay Browse API to search for products and display current listings with prices, seller ratings, and condition. Useful for competitive pricing research or building a product comparison tool for your customers.

Lovable Prompt

Create a product search page that queries the eBay Browse API through an Edge Function. Accept a search term input and display results showing item title, price, condition, seller feedback score, and a link to the eBay listing. Use the Edge Function to get an Application Token from eBay first, then call the Browse API /buy/browse/v1/item_summary/search endpoint.

Copy this prompt to try it in Lovable

eBay inventory management dashboard

Build a dashboard for eBay sellers to view all active listings, update prices, adjust quantities, and pause or end listings. The Edge Function uses the eBay Inventory API with a user OAuth token to read and write listing data.

Lovable Prompt

Build an inventory management dashboard that shows all my active eBay listings using the Inventory API. Display each listing's SKU, title, price, quantity, and status. Add buttons to pause or end a listing. Store the eBay user OAuth token in Supabase for authenticated requests through the Edge Function.

Copy this prompt to try it in Lovable

eBay order sync to Supabase

Automatically pull new eBay orders into a Supabase table for centralized order management. The Edge Function calls the Fulfillment API to fetch recent orders and upserts them to a Supabase orders table, enabling tracking across multiple sales channels.

Lovable Prompt

Create an Edge Function that fetches recent orders from the eBay Fulfillment API and saves them to a Supabase orders table. Each order should store eBay order ID, buyer username, total amount, line items as JSON, and fulfillment status. Add a sync button to the dashboard that triggers this Edge Function and shows new orders since the last sync.

Copy this prompt to try it in Lovable

Troubleshooting

Edge Function returns 'invalid_client' error when requesting eBay token

Cause: The EBAY_CLIENT_ID or EBAY_CLIENT_SECRET in Cloud Secrets does not match the registered eBay application credentials, or you are mixing Sandbox and Production credentials.

Solution: Go to developer.ebay.com → My Account → Application Access Keys and verify the exact App ID and Cert ID values. Check that your EBAY_ENVIRONMENT secret matches the credential set you are using — Sandbox credentials only work with sandbox.ebay.com endpoints, and Production credentials only work with api.ebay.com endpoints.

eBay Browse API returns empty itemSummaries array for search queries

Cause: In eBay Sandbox, the Browse API returns limited or no test data for most search queries. This is expected sandbox behavior, not a code bug.

Solution: Switch EBAY_ENVIRONMENT to production to test with real eBay data, or use specific Sandbox test data. The Sandbox environment is primarily useful for testing authentication flows and API request/response structure, not for testing search result content. Verify your request includes the q query parameter and that the X-EBAY-C-MARKETPLACE-ID header matches a valid marketplace ID.

Fulfillment API returns 403 Forbidden — 'insufficient permissions'

Cause: The Fulfillment API requires a user OAuth token with seller permissions, not the application token used for Browse API. The application token only grants access to public buyer-facing APIs.

Solution: Implement the eBay OAuth2 Authorization Code flow to obtain a user token. The seller must authorize your application at the eBay consent URL (https://auth.ebay.com/oauth2/authorize for production). Exchange the returned code for a user access token at the token endpoint. Store this token in Supabase and use it for Fulfillment API requests.

Edge Function works in Lovable preview but fails after deployment with 'scope' error

Cause: eBay's Sandbox and Production environments require different OAuth scope URLs. The scope https://api.ebay.com/oauth/api_scope is correct for both, but some API features require additional scopes like https://api.ebay.com/oauth/api_scope/sell.fulfillment.

Solution: Update the scope parameter in your token request to include all required scopes URL-encoded and space-separated. For Fulfillment API access add sell.fulfillment to the scope string. Verify in your eBay application settings under 'OAuth Scopes' that the required scopes are enabled for your application.

typescript
1body: "grant_type=client_credentials&scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.fulfillment",

Best practices

  • Always start development against the eBay Sandbox environment — use separate Cloud Secrets for sandbox vs production credentials and switch by updating EBAY_ENVIRONMENT
  • Cache eBay Application Tokens at the Edge Function module level for the token's lifetime (7,200 seconds) to avoid unnecessary token requests that count against your API rate limits
  • Store user OAuth tokens (for Inventory and Fulfillment APIs) in a Supabase table with RLS policies, not in Cloud Secrets — each seller has their own token and they need per-user storage
  • Implement token refresh logic for user tokens: eBay access tokens expire after 2 hours but refresh tokens last 18 months, so check token expiry before each API call and refresh proactively
  • Handle eBay's pagination: the Browse API returns itemSummaries with a total field and a next URL for the next page — implement load more functionality rather than requesting all results at once
  • Use the eBay Marketplace ID header (X-EBAY-C-MARKETPLACE-ID) to target the correct regional marketplace for your users rather than defaulting to EBAY_US
  • Monitor your eBay API call rate limits in the eBay Developer Portal — Browse API allows 5,000 calls per day on the free plan and Inventory/Fulfillment APIs have per-endpoint limits that vary by plan

Alternatives

Frequently asked questions

Do I need a paid eBay developer account to use these APIs?

No. eBay's Developer Program is free to join and includes access to Sandbox and Production APIs. Some APIs have daily call limits on the free plan. If you need higher volume, eBay offers commercial use tiers. Register at developer.ebay.com with your regular eBay account.

Can I create new eBay listings directly from my Lovable app?

Yes, but it requires the eBay Inventory API with a user OAuth token, which is more complex than the Browse API. The seller must authorize your application through eBay's OAuth consent flow. Once you have a user token, the Inventory API lets you create, update, and publish listings. Start with Browse API to display listings, then add Inventory API for seller tools.

Is there a difference between eBay Sandbox and Production API responses?

Yes, significantly. The Sandbox environment has limited test data and Browse API searches often return empty results or generic items. The Sandbox is best for testing authentication flows, request formats, and error handling — not for testing search functionality with real products. Switch to Production credentials for realistic testing of Browse API search results.

Can my Lovable app sell items on eBay on behalf of my users?

Yes, through eBay's OAuth2 Authorization Code flow. Each user (seller) must grant your application permission via an eBay consent URL. You exchange the resulting code for user-specific access and refresh tokens, store them in Supabase with that user's ID, and use them for all Inventory and Fulfillment API calls on that user's behalf. This is a multi-tenant pattern that requires careful token management.

What happens if I exceed eBay API rate limits?

eBay returns a 429 Too Many Requests response with details on when you can retry. Implement exponential backoff in your Edge Function for retry logic, and cache frequent responses (like category trees or product details) in Supabase to reduce repeat API calls. Monitor your quota usage in the eBay Developer Portal under 'API Metrics'.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.