Skip to content
guides

JavaScript SDK

Our Javascript SDK is the easiest way to start making requests to the Topsort API.

Installation

The SDK works in any modern JavaScript environment, meaning browsers and most javascript runtimes (we are yet to support Deno).

Start by adding it to your dependencies:

Terminal window
# add topsort's sdk to your project
npm i @topsort/sdk

Usage

Now, lets import the library and make a request.

Its important to consider that the api key is something you generally want to keep secret. In some cases, such as loading banners client-side this is not possible, but in most cases you should try to make auctions server-side.

import { createAuction } from '@topsort/sdk';
// set your api key here
const config = {
apiKey: "TSE_mykey",
};
const auctionDetails: TopsortAuction = {
auctions: [
{
type: "listings",
slots: 1,
products: ["product1", "product2"],
},
};
createAuction(config, auctionDetails)
.then((result) => console.log(result))
.catch((error) => console.error(error));

This will create an auction with the given details. You can find more information about the available options in the documentation.

We work continuously on improving the SDK. If you find issues or have feature suggestions, open an issue!