OpenRTB v2.5 types for Go programming language (Golang)
Also includes OpenRTB Dynamic Native Ads API Specification Version 1.2 types:
- 4 Native Ad Request Markup Details
- 5 Native Ad Response Markup Details
- 7 Reference Lists/Enumerations
Requires Go 1.8+
Go 1.8+ is needed for proper Ext json.RawMessage marshaling: non-pointer json.RawMessage is marshaled as base64 string prior to Go 1.8.
This library uses json.RawMessage since v10.0.0.
go get -u "github.com/mxmCherry/openrtb"import "github.com/mxmCherry/openrtb"This repo follows semver - see releases. Master always contains latest code, so better use some package manager to vendor specific version.
- UpperCamelCase
- Capitalized abbreviations (e.g.,
AT,COPPA,PMPetc.) - Capitalized
IDkeys
- Key types should be chosen according to OpenRTB specification (attribute types)
- Numeric types:
int64- time, duration, length, unbound enums (likeBidRequest.at- exchange-specific auctions types are > 500)int8- short enums (with values <= 127), boolean-like attributes (likeBidRequest.test)uint64- width, height, bitrate etc. (unbound positive numbers)float64- coordinates, prices etc.
- Enums:
- all enums, described in section 5, must be typed with section name singularized (e.g., "5.2 Banner Ad Types" ->
type BannerAdType int8) - all typed enums must have constants for each element, prefixed with type name (e.g., "5.2 Banner Ad Types - XHTML Text Ad (usually mobile)" ->
const BannerAdTypeXHTMLTextAd BannerAdType = 1) - never use
iotafor enum constants - section "5.1 Content Categories" should remain untyped and have no constants
- all enums, described in section 5, must be typed with section name singularized (e.g., "5.2 Banner Ad Types" ->
Documentation (godoc)
- Godoc: documenting Go code
- Each entity (type, struct key or constant) should be documented
- Comments for entities should be copy-pasted "as-is" from OpenRTB specification (except section 5 - replace "table" with "list" there; ideally, each sentence must be on a new line)
- Each RTB type should be kept in its own file, named after type
- File names are in underscore_case, e.g.,
type BidRequestshould be declared inbid_request.go - go fmt your code