API Documentation
Overview
Euro Gadgets Exchange provides a RESTful API for B2B electronics trading. All API endpoints require authentication.
Authentication
All API requests require a valid session token. Use NextAuth.js for authentication.
// Example: Get session
import { auth } from "@/lib/auth";
const session = await auth();
if (!session?.user) {
return { error: "Unauthorized" };
}Available Endpoints
Listings
Manage supply listings (Want to Sell)
POST
/api/listings- Create listingGET
/api/listings- Get all listingsWant to Buy Requests
Manage demand requests (WTB)
POST
/api/wtb- Create WTB requestGET
/api/wtb- Get all WTB requestsMatches
Manage matches between supply and demand
GET
/api/matches- Get all matchesPUT
/api/matches/:id/stage- Update match stageMessages
Manage deal messages
POST
/api/messages- Send messageGET
/api/messages/:matchId- Get match messagesRate Limiting
API requests are rate limited to prevent abuse. Current limits:
- 100 requests per minute for authenticated users
- 1000 requests per hour for authenticated users
- 10 requests per minute for unauthenticated users
Error Handling
All errors return JSON with the following format:
{
"error": "Error message",
"code": "ERROR_CODE",
"details": { ... }
}Support
For API support, contact: support@euro-gadgets.com