You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: libraries/ortbConverter/README.md
+62-50
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Prebid.js - ORTB conversion library
2
2
3
-
This library provides methods to convert Prebid.js bid request objects to ORTB requests,
4
-
and ORTB responses to Prebid.js bid response objects.
3
+
This library provides methods to convert Prebid.js bid request objects to ORTB requests,
4
+
and ORTB responses to Prebid.js bid response objects.
5
5
6
6
## Usage
7
7
@@ -37,13 +37,25 @@ registerBidder({
37
37
})
38
38
```
39
39
40
-
Without any customization, the library will generate complete ORTB requests, but ignores your [bid params](#params).
40
+
Without any customization, the library will generate complete ORTB requests, but ignores your [bid params](#params).
41
41
If your endpoint sets `response.seatbid[].bid[].mtype` (part of the ORTB 2.6 spec), it will also parse the response into complete bidResponse objects. See [setting response mediaTypes](#response-mediaTypes) if that is not the case.
42
42
43
43
### Module-specific conversions
44
44
45
45
Prebid.js features that require a module also require it for their corresponding ORTB conversion logic. For example, `imp.bidfloor` is only populated if the `priceFloors` module is active; `request.cur` needs the `currency` module, and so on. Notably, this means that to get those fields populated from your unit tests, you must import those modules first; see [this suite](https://github.com/prebid/Prebid.js/blob/master/test/spec/modules/openxOrtbBidAdapter_spec.js) for an example.
46
46
47
+
#### priceFloors extensions
48
+
49
+
In addition to `imp.bidfloor` and `imp.bidfloorcur`, the `priceFloors` module also populates media type and `format` objects, if their floors differ:
When invoked, `toORTB({bidRequests, bidderRequest})` first loops through each request in`bidRequests`, converting them into ORTB`imp` objects.
86
98
It then packages them into a single ORTB request, adding other parameters that are not imp-specific (such as for example `request.tmax`).
87
99
88
-
Likewise, `fromORTB({request, response})` first loops through each `response.seatbid[].bid[]`, converting them into Prebid bidResponses; it then packages them into
100
+
Likewise, `fromORTB({request, response})` first loops through each `response.seatbid[].bid[]`, converting them into Prebid bidResponses; it then packages them into
89
101
a single return value.
90
102
91
103
You can customize each of these steps using the `ortbConverter`arguments`imp`, `request`, `bidResponse` and `response`:
@@ -98,8 +110,8 @@ The arguments are:
98
110
-`buildImp`: a function taking `(bidRequest, context)` and returning an ORTB `imp` object;
99
111
- `bidRequest`: the bid request object to convert;
100
112
- `context`: a [context object](#context) that contains at least:
101
-
- `bidderRequest`: the `bidderRequest` argument passed to `toORTB`.
102
-
113
+
- `bidderRequest`: the `bidderRequest` argument passed to `toORTB`.
If you know that a particular ORTB request/response pair deals with exclusively one mediaType, you may also pass it directly in the [context parameter](#context).
209
+
If you know that a particular ORTB request/response pair deals with exclusively one mediaType, you may also pass it directly in the [context parameter](#context).
198
210
Note that - compared to the above - this has additional effects, because `context.mediaType` is also considered during `imp` generation - see [special context properties](#special-context).
For ease of use, the conversion logic gives special meaning to some context properties:
356
368
357
-
-`currency`: a currency string (e.g. `'EUR'`). If specified, overrides the currency to use for computing price floors and `request.cur`. If omitted, both default to `getConfig('currency.adServerCurrency')`.
358
-
-`mediaType`: a bid mediaType (`'banner'`, `'video'`, or `'native'`). If specified:
369
+
-`currency`: a currency string (e.g. `'EUR'`). If specified, overrides the currency to use for computing price floors and `request.cur`. If omitted, both default to `getConfig('currency.adServerCurrency')`.
370
+
-`mediaType`: a bid mediaType (`'banner'`, `'video'`, or `'native'`). If specified:
359
371
- disables `imp` generation for other media types (i.e., if `context.mediaType === 'banner'`, only `imp.banner` will be populated; `imp.video` and `imp.native` will not, even if the bid request specifies them);
360
372
- is passed as the `mediaType` option to `bidRequest.getFloor` when computing price floors;
361
373
- sets `bidResponse.mediaType`.
362
-
-`nativeRequest`: a plain object that serves as the base value for `imp.native.request` (and is relevant only for native bid requests).
363
-
If not specified, the only property that is guaranteed to be populated is `assets`, since Prebid does not require anything else to define a native adUnit. You can use `context.nativeRequest` to provide other properties; for example, you may want to signal support for native impression trackers by setting it to `{eventtrackers: [{event: 1, methods: [1, 2]}]}` (see also the [ORTB Native spec](https://www.iab.com/wp-content/uploads/2018/03/OpenRTB-Native-Ads-Specification-Final-1.2.pdf)).
364
-
-`netRevenue`: the value to set as `bidResponse.netRevenue`. This is a required property of bid responses that does not have a clear ORTB counterpart.
365
-
-`ttl`: the default value to use for `bidResponse.ttl` (if the ORTB response does not provide one in `seatbid[].bid[].exp`).
366
-
374
+
-`nativeRequest`: a plain object that serves as the base value for `imp.native.request` (and is relevant only for native bid requests).
375
+
If not specified, the only property that is guaranteed to be populated is `assets`, since Prebid does not require anything else to define a native adUnit. You can use `context.nativeRequest` to provide other properties; for example, you may want to signal support for native impression trackers by setting it to `{eventtrackers: [{event: 1, methods: [1, 2]}]}` (see also the [ORTB Native spec](https://www.iab.com/wp-content/uploads/2018/03/OpenRTB-Native-Ads-Specification-Final-1.2.pdf)).
376
+
-`netRevenue`: the value to set as `bidResponse.netRevenue`. This is a required property of bid responses that does not have a clear ORTB counterpart.
377
+
-`ttl`: the default value to use for `bidResponse.ttl` (if the ORTB response does not provide one in `seatbid[].bid[].exp`).
378
+
367
379
## Prebid Server extensions
368
380
369
-
If your endpoint is a Prebid Server instance, you may take advantage of the `pbsExtension` companion library, which adds a number of processors that can populate and parse PBS-specific extensions (typically prefixed `ext.prebid`); these include bidder params (with `transformBidParams`), bidder aliases, targeting keys, and others.
381
+
If your endpoint is a Prebid Server instance, you may take advantage of the `pbsExtension` companion library, which adds a number of processors that can populate and parse PBS-specific extensions (typically prefixed `ext.prebid`); these include bidder params (with `transformBidParams`), bidder aliases, targeting keys, and others.
0 commit comments