bsm / openrtb Goto Github PK
View Code? Open in Web Editor NEWOpenRTB protocol defintions for Go
License: Other
OpenRTB protocol defintions for Go
License: Other
OpenRTB 2.6 is released and includes features to support CTV buying and selling. Following are the updates :
Reference: https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf
Is there any plan to support these fields of 2.6.
Hello guys,
I have a requirement where the native bid request is present in another field. following is my impression json.
{
"imp": [
{
"id": "1",
"tagid": "12345",
"secure": 0,
"native": {
"requestobj": {
"layout": 2,
"assets": [
{
"id": 1,
"required": 1,
"img": {
"type": 1,
"wmin": 64,
"hmin": 64,
"mimes": []
}
},
{
"id": 2,
"required": 0,
"data": {
"type": 2,
"len": 40
}
}
]
},
"api": [],
"ver": "1"
},
"instl": 0
}
]
}
I tried to modify https://github.com/bsm/openrtb/blob/master/native.go with following snippet
package openrtb
import (
"github.com/bsm/openrtb/native/request"
)
// This object represents a native type impression. Native ad units are intended to blend seamlessly into
// the surrounding content (e.g., a sponsored Twitter or Facebook post). As such, the response must be
// well-structured to afford the publisher fine-grained control over rendering.
// The presence of a Native as a subordinate of the Imp object indicates that this impression is offered as
// a native type impression. At the publisher’s discretion, that same impression may also be offered as
// banner and/or video by also including as Imp subordinates the Banner and/or Video objects,
// respectively. However, any given bid for the impression must conform to one of the offered types.
type Native struct {
Request Extension `json:"request"` // Request payload complying with the Native Ad Specification.
Ver string `json:"ver,omitempty"` // Version of the Native Ad Specification to which request complies; highly recommended for efficient parsing.
API []int `json:"api,omitempty"` // List of supported API frameworks for this impression.
BAttr []int `json:"battr,omitempty"` // Blocked creative attributes
Ext Extension `json:"ext,omitempty"`
NativeJSON request.Request `json:"requestobj,omitempty"` // Native Json Object.
}
but no luck it gives me a compilation error, stating
can't load package: import cycle not allowed
package github.com/bsm/openrtb
imports github.com/bsm/openrtb/native/request
imports github.com/bsm/openrtb
Can anyone of you guys help me out here, how do we handle this case. ?
Thanks
Shiva
Native Ad Response is as follows -
{
"id": "D64s_873",
"bidid": "7410cn73n0293stw",
"seatbid": [
{
"bid": [
{
"id": "cabw74389b7947b48932",
"impid": "1",
"price": 0.28221,
"nurl": "http://random.link/?action=nurlnative&auction=${AUCTION_PRICE}&uniq=v5v5576c5",
"adm": "{\"native\":{\"assets\":[{\"id\":1,\"required\":0,\"img\":{\"url\":\"http://randomlink.one\",\"w\":300,\"h\":300}},{\"id\":2,\"required\":0,\"img\":{\"url\":\"http://randomlink.two\",\"w\":1200,\"h\":628}},{\"id\":3,\"required\":0,\"title\":{\"text\":\"You’re just a tap away\"}}],\"link\":{\"url\":\"http://somerandom.link/dasdasdad\"},\"imptrackers\":[\"http://anotherrandom.link/?action=lorem&ipsum=123\",\"http://andanotherrandom.link/?action=lorem&ipsum=321\"]}}",
"adomain": [
"loremipsum.com"
],
"cat": [
"IAB1",
"IAB9"
],
"attr": [],
"adid": "cahw34987h34",
"cid": "a9oxn84a983n4",
"crid": "p8na038n4x9"
}
],
"seat": "429"
}
],
"cur": "USD"
}
I try to Unmarshal Native Ad Response (which is "adm") as follows -
var native response.Response
err := json.Unmarshal([]bytes(bidResponse.AdMarkup), &native)
if err != nil {
return
}
This however fails as "adm" contains "native" as parent wrapper.
The only solution I see is trimming the "native" parent object from the "adm" string, this however doesn't appear to be the correct solution.
How is the Native Request/Response subpackage supposed to be used in such scenario?
Update -
Also Native Response fields like required
which is inside Asset
struct is omitted during json.Marshal
if it has a zero
value.
I found minor bug on sua.
According to IAB reference, Browsers fileld of sua type is Array of BrandVersion
, but current it is BrandVersion
.
https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf
Line 6 in b106b7e
I want to fix this bug, but I don't have authorization to this repository, so please fix someone else.
If I'm wrong in pointing this out, please ignore this issue and close.
Impression.Id
has tag json:"id
— should be json:"id"
. This breaks case-sensitive validators.
I am developing a server in Golang that accepts openRTB requests. Some of the requests that our partners are sending to the server contain minor problems with JSON validity like a wrong type of hyphen ("user":{"customdata":"48474fea-0aa1-45e1-8817-c5070e27448b”}). This kind of problem leads to an error in decoding with json package and initializing a openrtb.BidRequest struct. Is there a way to ignore a field that is not valid but still extract correct information from a request?
What is the best way going about reading a native request? I was intending on Native being a string object, but it looks like it's set as an Extension and I see there are json marshal and unmarshal functions associated to it. I have this, but haven't yet tested it:
var native request.Request
nativeBytes, err := json.Marshal(imp.Native.Request)
if err != nil {
return
}
err = json.Unmarshal(nativeBytes, &native)
if err != nil {
return
}
Many RTB exchanges expect width and height to be 0x0 for them to support dynamic ad sizes for Video ads.
If we can remove the omitempty
tag from w
and h
for only the Video
object the zero values would begin to pass.
type Video struct {
Width int `json:"w,omitempty"` // <-- Remove this omitempty
Height int `json:"h,omitempty"` // <-- Remove this omitempty
}
Let me know your thoughts.
GDPR int `json:"gdpr,omitempty" // Flag that indicates whether or not the request is subject to GDPR regulations 0 = No, 1 = Yes, omission indicates Unknown
But marshaller converts {gdpr: 0} into "{}" string. Thus should be:
GDPR int `json:"gdpr"
OpenRTB 2.2 specifies a buyer id field on User object as buyeurid
and OpenRTB 2.3 as buyerid
. How do you handle this?
What is your intention regarding http://www.iab.net/media/file/OpenRTB-Native-Ads-Specification-1_0-Final.pdf ?
Would an implementation be in scope of this package or should it be layered on top of it?
While taking a stab at providing the right structures for marshalling, I could only see re-use of the Video type, but MinDuration and MaxDuration are required instead of recommended in the OpenRTB Native Ads Specification.
At the moment I am leaning towards a subpackage "nativeads" importing "openrtb" and parsing the string in Native.Request there. That would allow matching Native.Ver with the ver field encoded the the structure in the request.
Another idea would be to provide a completely independent package and let the user of both packages do that.
Any recommendations?
When you set video sequence to 0, it automatically sets it's value to 1 when is marshalled.
Hi there,
since openrtb 3.0 is out for a while, is there any plan for it?
thanks!
+1 for new release. Need #115.
Thanks
Hello,
I updated the dependency for this library today and noticed that parsing the openRTB requests has changed. What is the new equivalent to this command:
req, err := openrtb.ParseRequest(r.Body)
Could you provide an example or point to documentation?
Bump go to 1.17, bump deps and update CI workflows pls
Hello,
I think there are some contradictions with IAB OpenRTB specifications on validators:
For example, in IAB specifications, it seems that an imp
object can contain a video
object and/or a banner
object.
The presence of a Videoas a subordinate ofthe Impobject indicates that this impression is offered as a video type impression. At the publisher’s discretion, that same impression may also be offered as banner, audio, and/or native by also including as Impsubordinates objects of those types. However, any given bid for the impression must conform to one of the offered types.
Source: https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf
But here is the code of the validator:
func (imp *Impression) assetCount() int {
n := 0
if imp.Banner != nil {
n++
}
if imp.Video != nil {
n++
}
if imp.Native != nil {
n++
}
return n
}
// Validate the `imp` object
func (imp *Impression) Validate() error {
if imp.ID == "" {
return ErrInvalidImpNoID
}
if count := imp.assetCount(); count > 1 {
return ErrInvalidImpMultiAssets
}
if imp.Video != nil {
if err := imp.Video.Validate(); err != nil {
return err
}
}
return nil
}
Is there any particular reason for that behavior ?
Hi,
I'm using the code in production and after seeing error rates go up post-integration with an SSP, I realized that they're sending auctions that specify the secure tag as a string rather than an int.
I've resorted to forking to repo and specifying it as a json.Number - is maintaining a local fork my only solution or perhaps I could submit a PR?
Thanks,
Since 2.6 it's deprecated
And should be 0 by default. (Now 1)
Hi,
I have cloned bsm/openrtb to suit my requirement mentioned here in this ticket #62
Thanks a lot.
I have been using this api for quiet a long time, i have forked this binaries in my repo ( reason for doing it was to customise a little )
bsm/openrtb v3.0.2
for instance earlier i was consuming impression object as request.Imp[] and now its been changed to request.Impressions[].github.com/bsm/openrtb v2.1.2+incompatible
I have 2 questions wrt to versions :
bsm/openrtb v3.0.2
and include in go.mod as github.com/bsm/openrtb/v3 v3.0.2
for consumption of openRTB 2.2 - 2.5 requests or do i need to downgrade from v3.0.2 to 2.x version of bsm/openrtb
?bsm/openrtb v3.0.2
supports openRTB spec 3.x requests ?Thanks a lot.
The very popular prebid-server uses own DTOs https://github.com/prebid/openrtb
They are support v2.6 fields and v3.0 and overall seems like more fields are supported. But from the other side there is no many enums like ContentCategory that the library have.
Maybe you can merge this two projects?
Hi! Seems like there's a typo in Content Category. OpenRTB 2.5 listing has 3-D Graphics equal to IAB19-1, but in openrtb.go ContentCategoryDGraphics is set to IAB19-13.
Hello,
The question is in the title.
Thanks.
Most sorely missed are
DEVICE_TYPE_PHONE = 4
DEVICE_TYPE_TABLET = 5
DEVICE_TYPE_CONNECTED = 6
DEVICE_TYPE_SET_TOP_BOX = 7
According to IAB reference, Source fileld of sua type is integer, but current it is string.
Line 12 in 56ba587
This causes the following error when decoding json
Unmarshal type error: expected=string, got=number, field=device.sua.source, offset=1282
Line 20 in 8d41110
At line 20 in banner.go:
Pos int `json:"pos,omitempty"`
The omitempty tag is causing the field to be omitted when the value is 0. However, according to the OpenRTB spec, a value of 0 is valid for the pos field:
https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf
A potential fix would be to use an int pointer, which would change the value required to omit the field from 0 to nil.
Pos *int `json:"pos,omitempty"`
Hi guys,
go get github.com/bsm/openrtb/v3 brings:
cannot find package "github.com/bsm/openrtb/v3" in any of:
C:\Program Files\Go\src\github.com\bsm\openrtb\v3 (from $GOROOT)
C:\Users\s_vla\go\src\github.com\bsm\openrtb\v3 (from $GOPATH)
go version:
go version go1.20.4 windows/amd64
could you help? I use your regular github.com/bsm/openrtb but need to upgrade according latest rtb
Hello, wondering if we could get a new release cut to the go package repository? We would like to take advantage of some of the new things, specifically Content Object additions (Network and Channel) as well as the Regulations updates.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.