Last Updated: February 16, 2026, 1:36 PM EET
Status: β
Active & Working
- β
eBay Finding API integration (
lib/ebay.ts) - β
Search endpoint (
/api/ebay/search) - β Environment variables in Vercel
- β Caching (1 hour server-side)
- β Error handling & fallbacks
- β TypeScript types
Make sure these are set in Vercel > Settings > Environment Variables:
NEXT_PUBLIC_EBAY_APP_ID=YourAppId-YourCompany-PRD-xxxxx
NEXT_PUBLIC_EBAY_TRACKING_ID=5338903178Note: These variables are already configured in your Vercel project.
Search by keyword:
GET https://ebay-store.vercel.app/api/ebay/search?q=laptop&limit=12Get trending products:
GET https://ebay-store.vercel.app/api/ebay/search?trending=trueResponse format:
{
"success": true,
"count": 12,
"query": "laptop",
"products": [
{
"id": 1000,
"title": "Apple MacBook Pro 14\"",
"price": 1999,
"currency": "USD",
"image": "https://i.ebayimg.com/...",
"category": "Computers/Tablets & Networking",
"affiliateLink": "https://www.ebay.com/itm/...",
"description": "M3 Pro chip, 16GB RAM",
"condition": "New",
"itemId": "123456789",
"shipping": "0.00"
}
]
}import { useEffect, useState } from 'react';
export function EbayProducts() {
const [products, setProducts] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function fetchProducts() {
const response = await fetch('/api/ebay/search?q=laptop&limit=12');
const data = await response.json();
setProducts(data.products);
setLoading(false);
}
fetchProducts();
}, []);
if (loading) return <div>Loading...</div>;
return (
<div>
{products.map(product => (
<div key={product.id}>{product.title}</div>
))}
</div>
);
}// app/deals/page.tsx
import { getEbayProducts } from '@/lib/ebay';
export default async function DealsPage() {
const products = await getEbayProducts('iPhone 15', 12);
return (
<div>
<h1>Today's Deals</h1>
{products.map((product, i) => (
<div key={i}>{product.title}</div>
))}
</div>
);
}The system automatically rotates trending categories by day:
| Day | Category |
|---|---|
| Sunday | iPhone 15 Pro |
| Monday | PlayStation 5 |
| Tuesday | Nike Air Jordan |
| Wednesday | MacBook Pro M3 |
| Thursday | Samsung Galaxy S24 |
| Friday | Nintendo Switch OLED |
| Saturday | Apple Watch Series 9 |
Usage:
import { getTrendingProducts } from '@/lib/ebay';
const trending = await getTrendingProducts();Fetch products by search keyword.
const products = await getEbayProducts('MacBook Pro', 12);Search multiple keywords and combine results.
const products = await searchMultipleKeywords(
['iPhone', 'iPad', 'MacBook'],
4 // 4 results per keyword = 12 total
);Get today's trending products (auto-rotates daily).
const trending = await getTrendingProducts();- API responses cached for 1 hour
- Uses Next.js
revalidate: 3600 - Reduces API calls to eBay
// Cache for 1 hour
fetch('/api/ebay/search?q=laptop', {
next: { revalidate: 3600 }
});- eBay Free Tier: 5,000 calls/day
- With caching: ~200 unique searches/day = Well within limits
The system gracefully handles errors:
try {
const products = await getEbayProducts('laptop');
if (products.length === 0) {
// Fallback to static products
}
} catch (error) {
console.error('eBay API error:', error);
// Show cached/static products instead
}Visit: https://ebay-store.vercel.app/api/ebay/search?q=laptop
You should see JSON response with products.
curl "https://ebay-store.vercel.app/api/ebay/search?q=laptop&limit=5"Vercel Dashboard > Deployments > [Latest] > Logs
Look for:
π Fetching from eBay API: laptop
β
eBay API: Found 12 items for "laptop"
Problem: Environment variable missing
Solution: Add NEXT_PUBLIC_EBAY_APP_ID to Vercel
Problem: Invalid App ID or API error
Solution: Check App ID format and eBay Developer account status
Problem: No caching
Solution: Already implemented! Should be fast after first request
- eBay API integration
- Search endpoint
- Caching layer
- Error handling
- TypeScript types
- Add Redis caching (for production scale)
- Implement eBay Browse API (more features)
- Add price tracking
- Create "deals" page with eBay products
- Mix eBay + static products on homepage
Official eBay Docs:
- Finding API: https://developer.ebay.com/DevZone/finding/Concepts/FindingAPIGuide.html
- App ID Guide: https://developer.ebay.com/api-docs/static/gs_create-the-ebay-api-keysets.html
Your Implementation:
- Code:
lib/ebay.ts - Endpoint:
app/api/ebay/search/route.ts - Types:
EbayProduct,EbayApiResponse
Your eBay API is now:
- β Connected to Vercel environment
- β Cached for performance
- β Error-resistant with fallbacks
- β Typed with TypeScript
- β Ready for production!
Test it now: https://ebay-store.vercel.app/api/ebay/search?trending=true
Questions? Check the code or test the endpoints above! π