rtbkit.js
Access RTBkit APIs easily with Node.js
Installation
rtbkit.js is available on npm. To install it, type:
$ npm install rtbkit-js
Usage
const rtbkit = ;
Now we can :
- launch an HTTP bidding agent, or
- connect to an RTBkit instance to work with its RESTful APIs
HTTP Bidding Agent
You may create an HTTP Bidding Agent just typing a few strings:
const bidder = rtbkit; var PORT = 7654;var PATH = '/auctions'; bidder; bidder;
This bidder will response with no-bids for the campaign 111 (external-id from the bidding agent config) and will bid with 0.1 CPM for all other campaigns.
The library will automatically fill down bid.id, bid.impid, and bid.ext.external-id fields.
The function will be called once for each imp item and each allowed campaign that have been specified by RTBkit in the bid request.
RTBkit RESTful APIs
To connect to an RTBkit inststance type:
const rtb_test = rtbkit;const banker = rtb_testbanker;const acs = rtb_testacs;
Async/await
rtbkit.js might be used with the await operator in async functions:
{ try var pong = await banker; console; catch err console; };
Callbacks
Or you can use a traditional callback approach. In this case you will have access to the HTTP Response object:
! { banker;};
APIs
Banker API
Budgets management:
var pong = await banker;var summary = await bankersummary; //gets information about all accountsawait banker; // sets a new value for a top-level accountvar accounts = await banker; // lists all accountsvar account = banker; // makes a reference to the specified account. // It's an ordinary synchronous method, you don't need use await here.var hello_world = banker // the same as the previous callawait account; // transfers budget from the parent account to set the new value. Unacceptable for top-level accounts.var childrens = await account; // gets descendants of the accountawait account; // closes the account and all its childs.
Agent Configuration Service (ACS) API
var agents = await acs; // lists all agentsvar agent = acs; // makes a reference to the specified agent. //It's an ordinary synchronous method, you don't need use await here.var config = await agent; //gets the bidding agent's configawait agent; // sets the new configuration for the bidding agent
Standard Ad Server Protocol)
Post Auction Events (a-kaWith the API we may implement a win notification proxy that recieves GET requests from the browser and sends POST requests into the RTBkit's via Standard Ad Server Protocol:
const app = ;const rtbkit = ; const PORT = 888; const RTBKIT_HOST = '127.0.0.1'; const adserver = rtbkitadserver; app; app;
Other events (clicks, conversions) will be implemented later.
Exchange Endoints
Will be implemented later. Will help to send bid requsts into the system and check responses.
RTBkit Mock-up
There is a mock server that emulates all implemented APIs. It starts locally always.
{ try rtbkitmockupstart; const banker = rtbkitbanker var pong = await banker; console; catch err console; } ;