iab-specs
An unofficial Rust implementation of various IAB (Interactive Advertising Bureau) specifications.
Overview
iab-specs provides typed Rust data structures for working with IAB advertising specifications. Rather than being just a parser, this library wraps each specification's logic into idiomatic Rust types using serde for serialization/deserialization.
Currently Supported Specifications
- AdCOM 1.0 - Advertising Common Object Model (enumerations)
- OpenRTB 2.5 - Real-Time Bidding protocol
- OpenRTB 2.6 - Real-Time Bidding protocol with CTV/DOOH support
- OpenRTB 3.0 - Real-Time Bidding protocol with layered architecture
- OpenRTB Native Ads 1.2 - Native advertising specification
- Ads.txt 1.1 - Authorized Digital Sellers declaration for websites
- App-ads.txt 1.0 - Authorized Digital Sellers declaration for mobile and CTV apps
- Sellers.json 1.0 - Supply chain transparency
- Agentic RTB Framework 1.0 - Autonomous agent bidstream processing via the OpenRTB Patch Protocol
- Agentic Direct 2.1 — OpenDirect v2.1 + A2A Protocol for direct campaign management
- Buyer Agent 1.0 — Demand-side campaign planning, UCP embeddings, negotiation, booking workflows, 2 state machines
- Seller Agent 1.0 — Supply-side inventory management, proposals, tiered pricing, negotiation, order execution, 1 state machine
- Agentic Audience v1.0 (Draft) - Embedding exchange protocol for audience targeting
- Registry Agent 1.0 — Agent discovery, trust lifecycle, and registry search
Installation
Add iab-specs to your Cargo.toml with the features you need:
[]
# Enable all specifications
= { = "0.4", = ["adcom", "openrtb_25", "openrtb_26", "openrtb_30", "openrtb_native_12", "ads_txt", "app_ads_txt", "sellers_json", "artb_10", "agentic_direct_21", "buyer_agent_10", "seller_agent_10", "agentic_audience_10", "registry_agent_10"] }
# Or enable only what you need
= { = "0.4", = ["openrtb_30"] }
Or use cargo:
# Enable all specifications
# Or enable only what you need
Crate Structure
This project is organized as a Cargo workspace with 14 crates. You can depend on the umbrella iab-specs crate (unchanged behavior) or depend directly on individual sub-crates for a smaller compile footprint.
Sub-crates
| Crate | Description |
|---|---|
iab-specs |
Umbrella crate — re-exports all enabled sub-crates |
iab-specs-core |
Shared traits and types (Extension trait, common utilities) |
iab-specs-adcom |
AdCOM 1.0 — Advertising Common Object Model enumerations |
iab-specs-openrtb |
OpenRTB 2.5, 2.6, and 3.0 — Real-Time Bidding protocol |
iab-specs-openrtb_native |
OpenRTB Native Ads 1.2 — Native advertising specification |
iab-specs-ads_txt |
Ads.txt 1.1 — Authorized Digital Sellers for websites |
iab-specs-app_ads_txt |
App-ads.txt 1.0 — Authorized Digital Sellers for mobile/CTV |
iab-specs-sellers_json |
Sellers.json 1.0 — Supply chain transparency |
iab-specs-artb |
Agentic RTB Framework 1.0 — Autonomous agent bidstream processing |
iab-specs-agentic_direct |
Agentic Direct 2.1 — OpenDirect v2.1 + A2A Protocol |
iab-specs-buyer_agent |
Buyer Agent 1.0 — Demand-side campaign planning and negotiation |
iab-specs-seller_agent |
Seller Agent 1.0 — Supply-side inventory and order management |
iab-specs-agentic_audience |
Agentic Audience v1.0 (Draft) — Embedding exchange protocol |
iab-specs-registry_agent |
Registry Agent 1.0 — Agent discovery and trust lifecycle |
Umbrella crate (default, unchanged)
[]
= { = "0.4", = ["openrtb_30"] }
Direct sub-crate dependency (smaller compile footprint)
[]
# Use only what you need, without the umbrella
= { = "0.4", = ["openrtb_30"] }
Note: When using
iab-specs-openrtb_nativedirectly, native types are accessed viaiab_specs_openrtb_native::v12::...instead ofiab_specs::openrtb_native::....
Features
⚠️ Important: By default, no features are enabled. You must explicitly enable the specifications you need.
The library uses cargo features to enable/disable specifications:
Specifications:
adcom- AdCOM 1.0 support (Advertising Common Object Model enumerations)openrtb_25- OpenRTB 2.5 support (automatically includesadcom)openrtb_26- OpenRTB 2.6 support (automatically includesopenrtb_25andadcom)openrtb_30- OpenRTB 3.0 support (automatically includesadcom)openrtb_native_12- OpenRTB Native Ads 1.2 support (automatically includesadcom)ads_txt- Ads.txt 1.1 supportapp_ads_txt- App-ads.txt 1.0 support (automatically includesads_txt)sellers_json- Sellers.json 1.0 support (includesserde_json)artb_10- Agentic RTB Framework 1.0 support (autonomous agent bidstream processing)agentic_direct_21- Agentic Direct 2.1 support (automatically includesserde_json)buyer_agent_10- Buyer Agent 1.0 support (automatically includesagentic_direct_21andserde_json)seller_agent_10- Seller Agent 1.0 support (automatically includesagentic_direct_21andserde_json)agentic_audience_10- Agentic Audience v1.0 (Draft) support (automatically includesserde_json)registry_agent_10- Registry Agent 1.0 support (automatically includesagentic_direct_21andserde_json)
Feature Selection Examples
[]
# Only AdCOM support
= { = "0.4", = ["adcom"] }
# Only OpenRTB 2.5 support (automatically includes adcom)
= { = "0.4", = ["openrtb_25"] }
# Only OpenRTB 2.6 support (automatically includes openrtb_25 and adcom)
= { = "0.4", = ["openrtb_26"] }
# Only OpenRTB 3.0 support (automatically includes adcom)
= { = "0.4", = ["openrtb_30"] }
# Only ads.txt support
= { = "0.4", = ["ads_txt"] }
# Only app-ads.txt support (automatically includes ads_txt)
= { = "0.4", = ["app_ads_txt"] }
# Only sellers.json support
= { = "0.4", = ["sellers_json"] }
# OpenRTB 3.0 with ads.txt and sellers.json
= { = "0.4", = ["openrtb_30", "ads_txt", "sellers_json"] }
# Only ARTB 1.0 support (autonomous agent bidstream processing)
= { = "0.4", = ["artb_10"] }
# Only Agentic Direct v2.1 support (agent-to-agent advertising transactions)
= { = "0.4", = ["agentic_direct_21"] }
# Only Buyer Agent 1.0 support (automatically includes agentic_direct_21)
= { = "0.4", = ["buyer_agent_10"] }
# Only Seller Agent 1.0 support (automatically includes agentic_direct_21)
= { = "0.4", = ["seller_agent_10"] }
# Only Agentic Audience v1.0 support (embedding exchange protocol)
= { = "0.4", = ["agentic_audience_10"] }
# Only Registry Agent 1.0 support (automatically includes agentic_direct_21)
= { = "0.4", = ["registry_agent_10"] }
# All specifications
= { = "0.4", = ["adcom", "openrtb_25", "openrtb_26", "openrtb_30", "openrtb_native_12", "ads_txt", "app_ads_txt", "sellers_json", "artb_10", "agentic_direct_21", "buyer_agent_10", "seller_agent_10", "agentic_audience_10", "registry_agent_10"] }
Why no default features?
This design allows you to:
- Minimize dependencies: Only include what you actually use
- Reduce compile time: Don't compile unused specifications
- Smaller binary size: Eliminate unused code from your final binary
- Explicit dependencies: Be clear about which IAB specs your project relies on
Serialization Formats
All types derive serde::Serialize and serde::Deserialize, making the library transport-agnostic. You can use any serde-compatible format:
- JSON — Use
serde_jsonfor human-readable JSON serialization - Protobuf — Use
prostto encode/decode typed messages withVec<u8>extension fields - MessagePack — Use
rmp-serdefor compact binary serialization - CBOR — Use
ciboriumfor CBOR encoding - Any serde format — Plug in any serializer/deserializer that works with serde
Extension fields default to Vec<u8> (opaque bytes), making the library serde-agnostic out of the box. You can use explicit type parameters like BidRequest<serde_json::Value> for JSON extensions, or provide your own types implementing the Extension trait.
Quick Start
Creating an OpenRTB Bid Request
use ;
Using the Builder Pattern
For more ergonomic construction, use the builder pattern:
use ;
Usage Examples
AdCOM
Use standardized enumeration values from the Advertising Common Object Model:
use ;
// Auction types
let auction = FirstPrice;
assert_eq!;
// Device types
let device = Phone;
assert_eq!;
// API frameworks
let api = Mraid3;
assert_eq!;
// Video protocols
let protocol = Vast4;
assert_eq!;
Extension Trait
The Extension trait provides a flexible mechanism for adding custom fields to IAB specification objects. This is particularly useful for vendor-specific data, internal tracking, or experimental features.
Key Features:
- Type-safe extension handling with generics
- Default to
Vec<u8>(opaque bytes, serde-agnostic) - Support for custom strongly-typed extensions
- Thread-safe (Send + Sync)
- Format-neutral serde support (JSON, MessagePack, CBOR, protobuf via prost, etc.)
Types Supporting Extensions:
The Extension trait is used throughout the crate on many types:
- AdCOM types:
Ad,Placement,DistributionChannel,Site,App,User,Device,Content,Publisher,Geo,Segment,Data,Regs, and many more - OpenRTB 2.5/2.6 types:
BidRequest,BidResponse,Imp,Banner,Video,Audio,Site,App,Device,User,Geo,Publisher,Content,Source,SeatBid,Bid, and many more - OpenRTB 3.0 types:
Request,Response,Item,Bid,SeatBid,Source,SupplyChain,SupplyChainNode,Deal,Metric, and many more
Using JSON extensions (with explicit serde_json::Value type parameter):
use AdBuilder;
# use Error;
#
Using custom typed extensions:
use ;
use ;
use Builder;
# use Error;
#
No extensions needed:
use Ad;
# use Error;
#
For complete documentation and examples, see the Extension trait documentation.
OpenRTB 2.5 and 2.6
OpenRTB 2.5 and 2.6 are fully implemented with complete bid request/response objects.
Supply Chain Transparency
use ;
OpenRTB 2.6 Features
OpenRTB 2.6 adds support for CTV ad pods, DOOH multipliers, and more:
use Video;
use ;
OpenRTB 3.0
OpenRTB 3.0 introduces a layered architecture with explicit versioning and supply chain transparency as a first-class feature:
use ;
use ;
Key OpenRTB 3.0 Features:
- Explicit protocol and domain versioning
- Supply chain transparency promoted to core object
- Item-based inventory (replaces Imp)
- Comprehensive tracking URLs (nurl, burl, lurl)
- Package bidding support
- Measurement metrics
OpenRTB 3.0 Documentation:
- Migration Guide - Migrate from 2.x to 3.0
- Usage Guide - Complete examples and patterns
- Best Practices - Production guidelines
OpenRTB Native Ads 1.2
Create and parse native ad requests and responses:
use ;
Integration with OpenRTB 2.5:
use ;
use NativeRequest;
// Create native request
let native_req = builder
.ver
.assets
.build?;
// Serialize to JSON string
let native_json = to_string?;
// Embed in OpenRTB bid request
let bid_request = builder
.id
.imp
.build?;
Key Features:
- Asset-based composition (title, image, video, data)
- Event tracking with impression and click support
- Multi-placement support for feed-based layouts
- DCO (Dynamic Creative Optimization) URL support
- AdCOM integration for standardized enumerations
Agentic RTB Framework 1.0
Process OpenRTB bidstream with autonomous agents using the ARTB Patch Protocol.
Note: The example below uses
serde_json::Valuefor JSON payloads via explicit type parameters. The default payload type isVec<u8>(opaque bytes). Use explicit type parameters likeRTBRequestBuilder::<serde_json::Value, Vec<u8>>::default()for JSON payloads.
use ;
Key ARTB 1.0 Features:
- Atomic, intent-declared mutations to OpenRTB bid requests and responses
- Segment activation, deal management, bid shading, metrics, and content data
- Agent metadata with API and model versioning
- Extension support for custom agent-specific data
Agentic Direct v2.1
Autonomous agent-to-agent advertising transactions combining OpenDirect v2.1 with the A2A Protocol.
use ;
Key Agentic Direct v2.1 Features:
- OpenDirect v2.1 entities: Organization, Account, Product, Order, Line, Creative, Assignment, ChangeRequest, Placement
- A2A Protocol: Agent Cards, Skills, Tasks with A2AMessage history and artifact support
- JSON-RPC 2.0 message framing, MCPTool definitions for agent-to-agent communication
- State machines for Order, Line, and Task lifecycle management
- Dual serialization: snake_case for OpenDirect, camelCase for A2A types
Buyer Agent 1.0
Plan campaigns, negotiate deals, and manage booking workflows with autonomous buyer agents.
use ;
use ;
use ;
Key Buyer Agent 1.0 Features:
- Campaign planning with CampaignBrief, CampaignAllocation, ChannelBrief, and BookingJob entities
- Deal negotiation with NegotiationStrategy and NegotiationOffer types
- Booking tracking with BookedLine and BookingRecommendation types
- Buyer identification with BuyerIdentity for tiered pricing lookups (seat, agency, advertiser)
- UCP embedding support with 384-dimensional vectors, AudiencePlan targeting, UCPModelDescriptor, and UCPConsent
- Linear TV support with LinearTVParams (flighting, cancellation terms, makegood policies)
- V2 type aliases: ChannelAllocation, NegotiationRound, BookingState, ProductRecommendation
- Validated state machines for Campaign (9 states) and Deal (13 states) lifecycles
- Approval rejection loop: AwaitingApproval → Researching for iterative refinement
- Re-exports all Agentic Direct 2.1 types for seamless integration
Seller Agent 1.0
Manage inventory, generate proposals, negotiate pricing, and execute orders with autonomous seller agents.
use ;
use ;
use can_transition_seller_order;
use RateType;
Key Seller Agent 1.0 Features:
- Proposal management with Proposal, ProposalRevision, and ProposalItem entities
- Tiered pricing with TieredPricing, PricingTier, and RateCard types
- Negotiation configuration with NegotiationConfig and NegotiationRound types
- Inventory packaging with MediaKit and Package types
- Change management with ChangeRequest, ChangeType, and ChangeSeverity
- Order execution with ExecutionOrder, DealDistribution, and DspIntegration
- Validated state machine for SellerOrder (13 states) lifecycle with pause/resume support
- Re-exports all Agentic Direct 2.1 types for seamless integration
Agentic Audience v1.0
Exchange embeddings for audience targeting using the Agentic Audience protocol.
⚠️ Draft Specification: Based on Agentic Audience v1.0 Draft. Breaking changes may occur.
use ;
Key Agentic Audience v1.0 Features:
- Embedding envelope for transport (model descriptor, context, embeddings)
- 24 embedding type classifications across 7 signal categories
- Campaign scoring with head weights, requests, and responses
- OpenRTB bid stream extension (
EmbeddingSegmentExt) foruser.data.segment.ext - Signal taxonomy enums (SignalType, EmbeddingType, ModelType, DistanceMetric, etc.)
Registry Agent 1.0
Discover agents, manage trust lifecycles, and search the registry with autonomous registry agents.
use ;
Key Registry Agent 1.0 Features:
- Agent registration with RegisteredAgent, RegistrySource, and AgentTrustInfo entities
- Trust lifecycle state machine: Unknown → Registered → Verified → Preferred (with Blocked terminal state)
- Registry search with RegistrySearchFilter and RegistrySearchResult types
- Trust validation with can_transition_trust and valid_trust_transitions_from functions
- TrustTransition records for audit trails
- Re-exports all Agentic Direct 2.1 types for seamless integration
Ads.txt
Parse and generate ads.txt files:
use ;
use FromStr;
// Parse an ads.txt file
let ads_txt_content = "google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0";
let ads_txt = from_str?;
// Create an ads.txt programmatically
let ads_txt = builder
.contact
.owner_domain
.systems
.build?;
// Serialize to string
let output = ads_txt.to_string;
App-ads.txt
Parse and generate app-ads.txt files for mobile and CTV applications:
use ;
use FromStr;
// Parse an app-ads.txt file
let app_ads_content = r#"
contact=monetization@mygame.com
subdomain=games.mygame.com
# Primary ad network
google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0
# Reseller partners
silverssp.com, 9876, RESELLER, f6578439
"#;
let app_ads = from_str?;
// Create an app-ads.txt programmatically
let app_ads = builder
.contact
.subdomain
.systems
.build?;
// Serialize to string
let output = app_ads.to_string;
Note on ads.txt 1.1 vs app-ads.txt 1.0:
App-ads.txt v1.0 is based on an earlier ads.txt specification and does not support the ads.txt 1.1 features:
OWNERDOMAIN(not in app-ads.txt v1.0)MANAGERDOMAIN(not in app-ads.txt v1.0)
Attempting to parse an app-ads.txt file containing these directives will result in an error.
Sellers.json
Parse and generate sellers.json files:
use ;
use FromStr;
// Parse a sellers.json file
let sellers_json = r#"{
"contact_email": "adops@example.com",
"version": "1.0",
"sellers": [
{
"seller_id": "12345",
"seller_type": "publisher",
"name": "Example Publisher",
"domain": "example.com"
}
]
}"#;
let sellers = from_str?;
// Create sellers.json programmatically
let sellers = builder
.contact_email
.version
.sellers
.build?;
// Serialize to JSON string
let output = to_string_pretty?;
Documentation
Full API documentation is available on docs.rs.
For usage examples, please refer to the unit tests in the source code. Each module includes comprehensive test cases demonstrating both serialization and deserialization.
Development
The project includes shell scripts for common development tasks:
Format Code
Check or fix code formatting with rustfmt:
Run Linter
Check code quality with clippy:
Run Tests
Run tests with configurable features:
You can also use Cargo workspace commands directly to test across all crates:
Generate Coverage
Generate code coverage reports:
All scripts support --help for more options.
Roadmap
- AdCOM 1.0
- Ads.txt 1.1
- App-ads.txt 1.0
- Sellers.json 1.0
- OpenRTB 2.5
- OpenRTB 2.6
- OpenRTB 3.0
- OpenRTB Native Ads 1.2
- Agentic RTB Framework 1.0
- Agentic Direct 2.1
- Buyer Agent 1.0
- Seller Agent 1.0
- Agentic Audience v1.0 (Draft)
- Registry Agent 1.0
- Additional IAB specifications (contributions welcome!)
Contributing
Contributions are welcome! Whether it's:
- Adding new IAB specifications
- Improving existing implementations
- Fixing bugs
- Improving documentation
- Adding examples
Please see CONTRIBUTING.md for detailed guidelines on:
- Development setup
- Running tests locally with
act - Code coverage requirements
- Contribution workflow
Signed commits are required. See the Signing Your Commits section in CONTRIBUTING.md for setup instructions using GPG, SSH, or other supported methods.
Verifying Release Artifacts
Published crate artifacts include GitHub Artifact Attestations for supply chain verification:
License
Licensed under Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.