API Reference
Subscribe

Subscribe

Technical details regarding the usage of the subscribe function can be found below. Example code is provided for JavaScript, Go, and Python, along with a response schema.

Route Schema

There are two ways to connect to our real-time API: HTTP or Websocket. If you choose HTTP, the connection is automatically upgraded to a WebSocket connection using status 101 Switching Protocols. However, we strongly recommend the direct use of WebSocket.

wss://api.swooply.co/websocket

Header Parameters

ParameterTypeDescriptionRequired?Default
x-api-keystringYour unique API key. Used to authenticate your application.Yes""

Query Parameters

ParameterTypeDescriptionRequired?Default
categoriesstring[]The categories that are important for your application. Enum: home-and-kitchen, beauty-and-personal-car, clothing-shoes-and-jewelry, toys-and-games, health-household-and-baby-care, baby, electronics, sports-and-outdoors, pet-supplies, and office-supplies.No""

Request Samples

Simply copy and paste the following code to get the newest Amazon deals and freebies. Keep in mind, these are just basic implementations and may need some adaptation.

const WebSocket = require("ws");
 
// Set your Swooply API key and important categories
const apiKey = "YOUR_API_KEY"
const categories = ["home-and-kitchen", "beauty-and-personal-care"]
 
// Encode categories into URL query parameters
const params = new URLSearchParams({ categories: categories.join(",") });
const url = `wss://api.swooply.co/websocket?${params}`;
 
// Set HTTP headers
const headers = {
  "x-api-key": apiKey,
  "Content-Type": "application/json"
};
 
// Create a new WebSocket instance
const socket = new WebSocket(url, {
  headers
});
 
socket.addEventListener("open", () => {
  console.log("Connection opened");
});
 
socket.addEventListener("message", (event) => {
  console.log("Received message:", event.data);
});
 
socket.addEventListener("close", () => {
  console.log("Connection closed");
});
 
socket.addEventListener("error", (error) => {
  console.error("Error:", error);
});

Response Schema

MIME Type: application/json

{
  "type": "product",
  "data": {
      "id": "bey5d294-9xp9-41d8-b11b-291aa7f542d6",
      "pid": "B0BDFRNZY6",
      "offerId": "DwRJKFHGR6VLQZtjZFYcDe06xhqKUppGT2wv36BeCt4hp6zDeIT3OsVqWiFeskDkXb%2BFOiFEAR%2Ba%2F%2FAxkVjyZRYNPGEnLnmheMOO7%2BJpldzLa2szlYq%2BXITIsgy6hQMEFCzhYzFtjEIxyZQfKb9EcZ2P9SKI2W0%2FGTjDtdXuDoayhR4z5PRohscrqx3894ks",
      "name": "LaView 4MP Bulb Security Camera 2.4GHz,360° 2K Security Cameras Wireless Outdoor Indoor Full Color Day and Night, Motion Detection, Audible Alarm, Easy Installation, Compatible with Alexa…",
      "link": "https://www.amazon.com/dp/B0BDFRNZY6",
      "imageURL": "https://m.media-amazon.com/images/I/718Fo0LJFKL.__AC_SX300_SY300_QL70_FMwebp_.jpg",
      "originalPrice": 39.99,
      "primeEarlyAccess": false,
      "promoCode": "",
      "promotionIds": ["A3ELOXF6Q89327"],
      "dealId": "",
      "percentOff": 100,
      "minQuantity": 1
  }
}