Skip to content

valdo404/scala-openrtb

 
 

Repository files navigation

Scala OpenRTB is a full Scala library that provides protobuf bindings as well as JSON serialization for OpenRTB-based entities in a functional fashion. This library also provides SerDes for BidSwitch bidding models, and aims to support other DSPs in the near future.

Artifacts

Scala openrtb artifacts are available on Sonatype.

Building

Build it like any other SBT project. Go to the root folder and run:

sbt compile

Usage

If you want to use the core of ScalaOpenRTB, you only need to add libraryDependencies += "com.powerspace.openrtb" %% "openrtb-model" % "version" to your build.sbt

We also provide json encoders through libraryDependencies += "com.powerspace.openrtb" %% "openrtb-json" % "version"

To leverage ScalaOpenRTB we have to define our bid request/response extensions and their decoders:

object CustomSerdeModule extends SerdeModule {

  // Define encoder for custom extension
  implicit val directEncoder: Encoder[CustomExtension] = openRtbEncoder[CustomExtension]
 
  // Register extension for specific proto-kind object
  override def extensionRegistry: ExtensionRegistry = ExtensionRegistry()
    .registerExtension(CustomProto.bidRequest)
  
  override def nativeRegistry: ExtensionRegistry = ExtensionRegistry()

Then in the bidder client we import defined module and use it for bid requests/response encoding/decoding:

import CustomSerdeModule._
import io.circe.syntax._
import io.circe.parser.decode

implicit val bidRequestEncoder: Encoder[BidRequest] = PowerspaceSerdeModule.bidRequestEncoder
implicit val bidResponseDecoder: Decoder[BidRequest] = PowerspaceSerdeModule.bidResponseDecoder

val bidRequest = BidRequest(...).asJson
val bidRequest = decode[BidResponse](bidRequest)

Work in Progress

  • Macro replacement will be included into ScalaOpenRTB

Links

  • OpenRTB specifications:

  • Powerspace: Powerspace is the 1st native advertising platform for e-mail. Powerspace allows brands to broadcast their content at scale across hundreds of media newsletters leveraging cutting-edge technology solutions.

  • BidSwitch: BidSwitch provides immediate and seamless real-time access for Supply and Demand Partners across all media types (display, mobile, video, native, TV, DOOH, VR, etc.).

  • Medium: Open-sourcing the first OpenRTB Scala framework

Contributions

Feel free to:

  • add support for other DSPs
  • raise an issue
  • submit your pull request

About

Scala OpenRTB tools used at @Powerspace

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%