Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions modules/startioBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
import { logError } from '../src/utils.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js'
import { ortb25Translator } from '../libraries/ortb2.5Translator/translator.js';

const BIDDER_CODE = 'startio';
const METHOD = 'POST';
const GVLID = 1216;
const ENDPOINT_URL = `http://pbc-rtb.startappnetwork.com/1.3/2.5/getbid?account=pbc`;

const converter = ortbConverter({
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);

if (imp?.banner?.format?.[0]) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this logic not happen in core? Should it be there instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I can see, in core by default we set banner.format in fillBannerImp function. In our case we need to have imp.banner.w and imp.banner.h set explicitly, so we need to extend the functionality.

imp.banner.w ??= imp.banner.format[0]?.w;
imp.banner.h ??= imp.banner.format[0]?.h;
}

return imp;
},
request(buildRequest, imps, bidderRequest, context) {
const request = buildRequest(imps, bidderRequest, context);
const publisherId = bidderRequest?.bids?.[0]?.params?.publisherId;
if (request?.site) {
request.site.publisher = request.site.publisher || {};
request.site.publisher.id = publisherId;
} else if (request?.app) {
request.app.publisher = request.app.publisher || {};
request.app.publisher.id = publisherId;
}
request.ext = request.ext || {};
request.ext.prebid = request.ext.prebid || {};

return request;
},
bidResponse(buildBidResponse, bid, context) {
const isValidBidType = bid?.ext?.prebid?.type === context?.mediaType;

if (context.mediaType === NATIVE) {
const ortb = JSON.parse(bid.adm);
bid.adm = ortb.native;
}

if (isValidBidType) {
return buildBidResponse(bid, context);
}

logError('Bid type is incorrect for bid: ', bid['id'])
},
context: {
netRevenue: true,
ttl: 30
},
translator: ortb25Translator()
});

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [VIDEO, BANNER, NATIVE],
gvlid: GVLID,
isBidRequestValid: (bid) => !!bid,

buildRequests: (bidRequests, bidderRequest) => {
return bidRequests.map((bidRequest) => {
const mediaType = Object.keys(bidRequest.mediaTypes || {})[0] || BANNER;
const data = converter.toORTB({ bidRequests: [bidRequest], bidderRequest, context: { mediaType } });

return {
method: METHOD,
url: ENDPOINT_URL,
options: {
contentType: 'text/plain',
withCredentials: false,
crossOrigin: true
},
data: data,
};
});
},

interpretResponse: ({ body }, req) => {
if (!body || !body.seatbid || body.seatbid.length === 0) {
return [];
}
return converter.fromORTB({
response: body,
request: req.data
});
},

onTimeout: (data) => { },

onBidWon: (bid) => {
if (bid.nurl) {
const url = new URL(bid.nurl);
url.searchParams.set('cpm', bid.cpm);
fetch(url.toString(), { method: 'GET', keepalive: true }).catch(err =>
logError('Error triggering win notification', err)
);
}
},

onSetTargeting: (bid) => { },
};

registerBidder(spec);
101 changes: 101 additions & 0 deletions modules/startioBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Overview

```
Module Name: Start.io Bidder Adapter
Module Type: Bidder Adapter
Maintainer: prebid@start.io
```

# Description

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.

# Test Parameters
```
var adUnits = [
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[300,250], [728,90]]
}
},
bids: [
{
bidder: 'startio',
params: {
// REQUIRED - Publisher Account ID
accountId: 'your-account-id',

// OPTIONAL - Enable test ads
testAdsEnabled: true
}
}
]
}
];
```

# Sample Instream Video Ad Unit: For Publishers
```
var videoAdUnits = [
{
code: 'test-div-video',
mediaTypes: {
video: {
context: 'instream',
placement: 1,
playerSize: [640, 360],
mimes: ['video/mp4'],
protocols: [2, 3, 5, 6],
api: [2],
maxduration: 30,
linearity: 1,
playbackmethod: [2]
}
},
bids: [
{
bidder: 'startio',
params: {
accountId: 'your-account-id',
testAdsEnabled: true
}
}
]
}
];
```

# Sample Native Ad Unit: For Publishers
```
var nativeAdUnits = [
{
code: 'test-div-native',
mediaTypes: {
native: {
title: { required: true, len: 80 },
body: { required: true },
image: { required: true, sizes: [150, 150] },
icon: { required: false, sizes: [50, 50] },
sponsoredBy: { required: true }
}
},
bids: [
{
bidder: 'startio',
params: {
accountId: 'your-account-id',
testAdsEnabled: true
}
}
]
}
];
```

# Additional Notes
- The adapter processes requests via OpenRTB 2.5 standards.
Comment thread
patmmccann marked this conversation as resolved.
- Ensure that the `accountId` parameter is set correctly for your integration.
- Test ads can be enabled using `testAdsEnabled: true` during development.
- The adapter supports multiple ad formats, allowing publishers to serve banners, native ads and instream video ads seamlessly.
Loading