Skip to content

Commit 0df74f2

Browse files
Start.io Bid Adapter : initial release (#13048)
* Implementation of the Start.io adapter * Refactor based on review suggestions * Get rid of deep* methods and adjust tests
1 parent 6e58924 commit 0df74f2

3 files changed

Lines changed: 500 additions & 0 deletions

File tree

modules/startioBidAdapter.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { registerBidder } from '../src/adapters/bidderFactory.js';
2+
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
3+
import { logError } from '../src/utils.js';
4+
import { ortbConverter } from '../libraries/ortbConverter/converter.js'
5+
import { ortb25Translator } from '../libraries/ortb2.5Translator/translator.js';
6+
7+
const BIDDER_CODE = 'startio';
8+
const METHOD = 'POST';
9+
const GVLID = 1216;
10+
const ENDPOINT_URL = `http://pbc-rtb.startappnetwork.com/1.3/2.5/getbid?account=pbc`;
11+
12+
const converter = ortbConverter({
13+
imp(buildImp, bidRequest, context) {
14+
const imp = buildImp(bidRequest, context);
15+
16+
if (imp?.banner?.format?.[0]) {
17+
imp.banner.w ??= imp.banner.format[0]?.w;
18+
imp.banner.h ??= imp.banner.format[0]?.h;
19+
}
20+
21+
return imp;
22+
},
23+
request(buildRequest, imps, bidderRequest, context) {
24+
const request = buildRequest(imps, bidderRequest, context);
25+
const publisherId = bidderRequest?.bids?.[0]?.params?.publisherId;
26+
if (request?.site) {
27+
request.site.publisher = request.site.publisher || {};
28+
request.site.publisher.id = publisherId;
29+
} else if (request?.app) {
30+
request.app.publisher = request.app.publisher || {};
31+
request.app.publisher.id = publisherId;
32+
}
33+
request.ext = request.ext || {};
34+
request.ext.prebid = request.ext.prebid || {};
35+
36+
return request;
37+
},
38+
bidResponse(buildBidResponse, bid, context) {
39+
const isValidBidType = bid?.ext?.prebid?.type === context?.mediaType;
40+
41+
if (context.mediaType === NATIVE) {
42+
const ortb = JSON.parse(bid.adm);
43+
bid.adm = ortb.native;
44+
}
45+
46+
if (isValidBidType) {
47+
return buildBidResponse(bid, context);
48+
}
49+
50+
logError('Bid type is incorrect for bid: ', bid['id'])
51+
},
52+
context: {
53+
netRevenue: true,
54+
ttl: 30
55+
},
56+
translator: ortb25Translator()
57+
});
58+
59+
export const spec = {
60+
code: BIDDER_CODE,
61+
supportedMediaTypes: [VIDEO, BANNER, NATIVE],
62+
gvlid: GVLID,
63+
isBidRequestValid: (bid) => !!bid,
64+
65+
buildRequests: (bidRequests, bidderRequest) => {
66+
return bidRequests.map((bidRequest) => {
67+
const mediaType = Object.keys(bidRequest.mediaTypes || {})[0] || BANNER;
68+
const data = converter.toORTB({ bidRequests: [bidRequest], bidderRequest, context: { mediaType } });
69+
70+
return {
71+
method: METHOD,
72+
url: ENDPOINT_URL,
73+
options: {
74+
contentType: 'text/plain',
75+
withCredentials: false,
76+
crossOrigin: true
77+
},
78+
data: data,
79+
};
80+
});
81+
},
82+
83+
interpretResponse: ({ body }, req) => {
84+
if (!body || !body.seatbid || body.seatbid.length === 0) {
85+
return [];
86+
}
87+
return converter.fromORTB({
88+
response: body,
89+
request: req.data
90+
});
91+
},
92+
93+
onTimeout: (data) => { },
94+
95+
onBidWon: (bid) => {
96+
if (bid.nurl) {
97+
const url = new URL(bid.nurl);
98+
url.searchParams.set('cpm', bid.cpm);
99+
fetch(url.toString(), { method: 'GET', keepalive: true }).catch(err =>
100+
logError('Error triggering win notification', err)
101+
);
102+
}
103+
},
104+
105+
onSetTargeting: (bid) => { },
106+
};
107+
108+
registerBidder(spec);

modules/startioBidAdapter.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Overview
2+
3+
```
4+
Module Name: Start.io Bidder Adapter
5+
Module Type: Bidder Adapter
6+
Maintainer: prebid@start.io
7+
```
8+
9+
# Description
10+
11+
The Start.io Bid Adapter enables publishers to integrate with Start.io's demand sources for banner, video and native ad formats. The adapter supports OpenRTB standards and processes bid requests efficiently using the Prebid.js framework.
12+
13+
# Test Parameters
14+
```
15+
var adUnits = [
16+
{
17+
code: 'test-div',
18+
mediaTypes: {
19+
banner: {
20+
sizes: [[300,250], [728,90]]
21+
}
22+
},
23+
bids: [
24+
{
25+
bidder: 'startio',
26+
params: {
27+
// REQUIRED - Publisher Account ID
28+
accountId: 'your-account-id',
29+
30+
// OPTIONAL - Enable test ads
31+
testAdsEnabled: true
32+
}
33+
}
34+
]
35+
}
36+
];
37+
```
38+
39+
# Sample Instream Video Ad Unit: For Publishers
40+
```
41+
var videoAdUnits = [
42+
{
43+
code: 'test-div-video',
44+
mediaTypes: {
45+
video: {
46+
context: 'instream',
47+
placement: 1,
48+
playerSize: [640, 360],
49+
mimes: ['video/mp4'],
50+
protocols: [2, 3, 5, 6],
51+
api: [2],
52+
maxduration: 30,
53+
linearity: 1,
54+
playbackmethod: [2]
55+
}
56+
},
57+
bids: [
58+
{
59+
bidder: 'startio',
60+
params: {
61+
accountId: 'your-account-id',
62+
testAdsEnabled: true
63+
}
64+
}
65+
]
66+
}
67+
];
68+
```
69+
70+
# Sample Native Ad Unit: For Publishers
71+
```
72+
var nativeAdUnits = [
73+
{
74+
code: 'test-div-native',
75+
mediaTypes: {
76+
native: {
77+
title: { required: true, len: 80 },
78+
body: { required: true },
79+
image: { required: true, sizes: [150, 150] },
80+
icon: { required: false, sizes: [50, 50] },
81+
sponsoredBy: { required: true }
82+
}
83+
},
84+
bids: [
85+
{
86+
bidder: 'startio',
87+
params: {
88+
accountId: 'your-account-id',
89+
testAdsEnabled: true
90+
}
91+
}
92+
]
93+
}
94+
];
95+
```
96+
97+
# Additional Notes
98+
- The adapter processes requests via OpenRTB 2.5 standards.
99+
- Ensure that the `accountId` parameter is set correctly for your integration.
100+
- Test ads can be enabled using `testAdsEnabled: true` during development.
101+
- The adapter supports multiple ad formats, allowing publishers to serve banners, native ads and instream video ads seamlessly.

0 commit comments

Comments
 (0)