1

I'm trying to create a extension in a openRTB protobuf request, but I don't know how. As they say in their docs (https://github.com/google/openrtb/wiki) I should can do something like that:

BidRequest request = BidRequest.newBuilder()
    // ... add Imp, etc.
    .addDevice(Device.newBuilder()
        .setModel("Nexus 85")
        // ... other standard Device fields
        .setGeo(Geo.newBuilder()
            .setCountry("USA")
            .setCity("Newer York")
            .zetZip("102879")
            .setExtension(SpaceAdsExt.planet, "Mars")))
    .build();

In this example, they set a custom extension named SpaceAdsExt.planet. How I can implement an extension like this?

1 Answer 1

1

The BidRequest proto has certain ranges of tag numbers reserved for extensions. According to its definition here, tags 200 to 999 and 2000 to 9999 are reserved for extension by exchanges and projects. You will need to create a .proto file that extends BidRequest by defining an extension for one of these tag numbers. That would look something like this:

extend com.google.openrtb.BidRequest {
  optional MyExtension my_extension = 2111;
}

For more detail, see the protocol buffer documentation here. One thing to beware of is that you must choose a unique tag number for your extension--if someone else defines an extension with the same tag number that you chose, then data corruption could result. I would recommend checking with the OpenRTB developers to see if they have a convention for ensuring uniqueness of extension numbers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.