Base classes for IAB VAST handling. Supports the full IAB VAST 2.0, 3.0, and 4.0 specifications.
To parse a tag into model objects, use iab-vast-parser. To load and parse a chain of VAST files, use iab-vast-loader.
import { VAST } from 'iab-vast-model'
const vast = new VAST()
// ... Do your thing ...
The API attempts to favor developer experience over mapping the VAST specifications to classes one-to-one. That has a few implications:
-
You won't find classes corresponding to
<Creatives>
,<CreativeExtensions>
,<Extensions>
,<MediaFiles>
and<Verifications>
. Instead, those have been folded into their parent objects. -
Where a child object can occur multiple times, the corresponding property will either be an array or a
SortedList
. The latter models VAST'ssequence
attribute and automatically orders elements by its value. -
Elements that are not required are
null
by default. A typical example isTrackingEvents
on the ads in aCreative
.
- AbsoluteTimeOffset
- AbstractAd
- AbstractClicks
- AbstractExtension
- AbstractResource
- AbstractTimeOffset
- AbstractVerificationResource
- AdBuffet
- SortedList
- TrackingEvents
- Creative
- Companion
- NonLinear
- Linear
- AdPod
- AdSystem
- InLine
- Wrapper
- Icon
- MediaFile
- InteractiveCreativeFile
- Category
- Click
- CompanionAds
- CreativeExtension
- UniversalAdId
- StaticResource
- Pricing
- VideoClicks
- VAST
- Extension
- FlashResource
- Verification
- HTMLResource
- IconClicks
- ViewableImpression
- Impression
- IFrameResource
- JavaScriptResource
- NonLinearAds
- TrackingEvent
- RelativeTimeOffset
- SortedListItem
- Survey
Extends AbstractTimeOffset
Represents a time offset expressed as an absolute duration in seconds.
Extends SortedListItem
Abstract class for ads (i.e., InLine and Wrapper).
The ad system for this ad.
Type: AdSystem
The conditional attribute for this ad.
Type: boolean
The creatives for this ad.
Type: SortedList<Creative>
The error-tracking URIs for this ad.
The extensions for this ad.
The ad server-defined identifier for this ad.
Type: string
The impression-tracking configurations for this ad.
Type: Array<Impression>
The pricing configuration for this ad.
Type: Pricing
The verifications for this ad.
Type: Array<Verification>
The viewable impression for this ad.
Type: ViewableImpression
Stores the click-through URI and a set of click-tracking pixels.
The click-through configuration.
Type: Click
The click-tracking configurations.
Base class for VAST Extension as well as CreativeExtension.
The MIME type of any code that might be included in the extension.
Type: string
The <Extension>
XML DOM element.
Type: Element
Base class for a verification resource used by a HTMLResource, a IFrameResource and a StaticResource.
The URI to this resource.
Type: string
Represents a time offset.
The value for this offset.
Type: number
Extends AbstractResource
Base class for a verification resource used by a FlashResource and a JavaScriptResource.
The name of the API framework.
Type: string
Represents a VAST ad buffet.
The ad pod for this ad buffet.
Type: AdPod
The ads in this ad buffet.
Type: SortedList
Represents a list of SortedListItems, ordered by SortedListItem#sequence.
Adds the given item to this list.
Parameters
item
SortedListItem the item.
Empties this list.
Gets the item at the given index.
Parameters
index
number the index.
Returns SortedListItem the item.
The length of this list.
Type: number
Removes the given item from this list.
Parameters
item
SortedListItem the item.
Creates an array representation of this list.
Returns Array<SortedListItem> the item array.
Configures tracking events. Maps VAST event types to arrays of TrackingEvent instances.
Adds a tracking-event configuration for the given event type.
Parameters
event
string the event type.config
TrackingEvent the tracking event configuration.
Gets the tracking-event configurations for the given event type.
Parameters
event
string the event type.
Returns Array<TrackingEvent> the tracking event configurations.
The event types tracked by this configuration.
Extends SortedListItem
Represents a creative.
The ID of the Ad with which this creative is served.
Required for VAST 2.0 and 3.0, optional for VAST 4.0.
Type: string
The string that identifies an API that is needed to execute this creative.
Type: string
The companion ads for this creative, if any.
Type: CompanionAds
The creative extensions for this creative.
Type: Array<CreativeExtension>
The ID of this creative.
Type: string
The linear ad for this creative, if any.
Type: Linear
The non-linear ads for this creative, if any.
Type: NonLinearAds
The unique creative identifier for this creative.
Type: UniversalAdId
Represents a single companion inside CompanionAds.
The ad parameters for this companion ad.
Type: string
The ad slot ID of this companion ad.
Type: string
The alt text of this companion ad.
Type: string
The API framework used by this companion ad.
Type: string
The height of this companion ad's asset in pixels.
Type: number
The width of this companion ad's asset in pixels.
Type: number
The click-through configuration.
Type: Click
The click-tracking configurations.
The expanded height of this companion ad in pixels.
Type: number
The expanded width of this companion ad in pixels.
Type: number
The height of this companion ad in pixels.
Type: number
The ID for this companion ad.
Type: string
The pixel ratio for which the companion creative is intended.
Type: string
The resource associated with this companion ad.
Type: (StaticResource | IFrameResource | HTMLResource)
The event-tracking configuration for this companion ad.
Type: TrackingEvents
The width of this companion ad in pixels.
Type: number
Represents a single non-linear ad inside NonLinearAds.
The ad parameters for this non-linear ad.
Type: string
The API framework used by this non-linear ad.
VAST 2.0 and 3.0 only.
Type: string
The click-through configuration for this non-linear ad.
Type: Click
The click-tracking configurations for this non-linear ad.
The expanded height of this non-linear ad in pixels.
VAST 2.0 and 3.0 only.
Type: number
The expanded width of this non-linear ad in pixels.
VAST 2.0 and 3.0 only.
Type: number
The height of this non-linear ad in pixels.
VAST 2.0 and 3.0 only.
Type: number
The ID of this non-linear ad.
VAST 2.0 and 3.0 only.
Type: string
Whether this non-linear ad's aspect ratio should be maintained when scaled.
VAST 2.0 and 3.0 only.
Type: boolean
The minimum suggested duration of this non-linear ad in seconds.
VAST 2.0 and 3.0 only.
Type: number
The resource associated with this non-linear ad.
Type: Resource
Whether this non-linear ad is meant to scale to larger dimensions.
VAST 2.0 and 3.0 only.
Type: boolean
The width of this non-linear ad in pixels.
VAST 2.0 and 3.0 only.
Type: number
Represents a linear within a Creative.
The ad parameters for this linear creative.
Type: string
The duration of this linear creative in seconds.
Type: number
The icons for this linear creative.
The interactive creative files for this linear creative.
Type: Array<InteractiveCreativeFile>
The media files for this linear creative.
The URI of the raw mezzanine file for this linear creative, intended for video transcoding.
Type: string
The time interval after which this linear creative can be skipped.
Type: TimeOffset
The event-tracking configuration for this linear creative.
Type: TrackingEvents
The video click tracking configuration for this linear creative.
Type: VideoClicks
Represents a VAST ad pod.
The ads in this ad pod.
Type: SortedList
Stores information about the ad system.
The name of the ad server that returned the ad.
Type: string
The version of the ad system.
Type: string
Extends AbstractAd
Represents an InLine ad.
The title for this ad.
Type: string
The advertiser name for this ad.
Type: string
The categories for this ad.
The description for this ad.
Type: string
The survey URI for this ad.
Extends AbstractAd
Represents a wrapper ad.
Whether multiple ads are allowed in the requested VAST response.
Type: boolean
Whether to use an available Ad when the requested VAST response returns no ads.
Type: boolean
Whether subsequent wrappers after a requested VAST response is allowed.
Type: boolean
The URI to a VAST response that may be another VAST Wrapper or a VAST InLine ad.
Type: string
Represents an icon used in a Linear creative.
The API framework used by this icon.
Type: string
The click-tracking configuration for this icon.
Type: IconClicks
The duration of this icon in seconds.
Type: number
The height of this icon in pixels.
Type: number
The time offset of this icon in seconds.
Type: number
The industry initiative that this icon supports.
Type: string
The pixel ratio for which the icon creative is intended.
Type: string
The resource associated with this icon.
Type: Resource
The view-tracking URIs for this icon.
The width of this icon in pixels.
Type: number
The horizontal position of this icon. Either a number of pixels or the
string "left"
or "right"
.
The vertical position of this icon. Either a number of pixels or the
string "top"
or "bottom"
.
Represents a media file used in a Linear creative.
The API framework used by this media file.
Type: string
The bitrate of this media file in kbps.
Type: number
The codec of this media file in RFC 4281 format.
Type: string
The delivery method for this media file.
Type: string
The height of this media file in pixels.
Type: number
The ID of this media file.
Type: string
Whether this media file's aspect ratio should be maintained when scaled.
Type: boolean
The maximum bitrate of this media file in kbps.
Type: number
The minimum bitrate of this media file in kbps.
Type: number
Whether this media file is meant to scale to larger dimensions.
Type: boolean
The MIME type of this media file.
Type: string
The URI to this media file.
Type: string
The width of this media file in pixels.
Type: number
Represents an interactive creative file used in a Linear creative.
The API framework used by this interactive creative file.
Type: string
The MIME type of this interactive creative file.
Type: string
The URI to this interactive creative file.
Type: string
Pricing information for real-time bidding.
The URL for the organizational authority that produced the list being used to identify the ad content.
Type: string
The category code or label that identifies the ad content.
Type: string
Describes a click configuration.
The ID of this click.
Type: string
The URI of this tracking pixel.
Type: string
Represents companion ads within a Creative.
The companion ads.
Determines which companion creative to display when multiple companions
are supplied and whether the ad can be displayed without its companion
creative. Either "all"
, "any"
, or "none"
.
Type: string
Extends AbstractExtension
Represents a creative extension.
Represents a unique identifier for an ad.
The string identifying the unique creative identifier.
Type: string
The registry URL for the unique creative identifier.
Type: string
A string for the unique creative identifier.
Type: string
Extends AbstractResource
Describes non-HTML creative.
The MIME type of this resource.
Type: string
Represents pricing information for real-time bidding.
The three-letter ISO-4217 currency symbol that identifies the currency of
the value provided (e.g. "USD"
, "GBP"
, etc.).
Type: string
The pricing model. Either "CPM"
, "CPC"
, "CPE"
, or "CPV"
.
Type: string
The price that can be used in real-time bidding systems.
Type: number
Extends AbstractClicks
Represents the click-tracking configuration for a Linear creative.
The custom-click configurations.
Extends AdBuffet
Represents a VAST document.
The error-tracking URIs for this document.
The URI associated with this document.
Type: string
The VAST version used by this document.
Type: number
Extends AbstractExtension
Represents a VAST extension.
Extends AbstractVerificationResource
Describes a Flash resource used to collect verification data.
Represents a list of verification resources for a vendor.
The Flash resources for this verification vendor.
Type: Array<FlashResource>
The JavaScript resources for this verification vendor.
Type: Array<JavaScriptResource>
The home page URL for the verification service provider that supplies the resource file.
Type: string
The viewable impression for this verification vendor.
Type: ViewableImpression
Extends AbstractResource
Describes an HTML snippet.
Extends AbstractClicks
Represents the click tracking configuration for an Icon.
Represents the impression-tracking URIs for both an InLine and any Wrapper.
The ad server ID of this viewability impression pixel.
Type: string
The URIs that direct the video player to a tracking resource file that the video player should request if the ad is executed but never meets criteria for a viewable impression.
The URIs that direct the video player to a tracking resource file that the video player should request at the time that criteria is met for a viewable impression.
The URIs that direct the video player to a tracking resource file that the video player should request if the player cannot determine whether criteria is met for a viewable impression.
Represents an impression.
The ad server id for the impression.
Type: string
The URI of this impression resource.
Type: string
Extends AbstractResource
Describes an HTML page for display within an iframe.
Extends AbstractVerificationResource
Describes a JavaScript resource used to collect verification data.
Represents non-linear ads within a Creative.
The non-linear ads.
The event-tracking configuration.
Type: TrackingEvents
Represents an event to be tracked.
The time offset for this event configuration.
Type: TimeOffset
The tracking URI for this event configuration.
Type: string
Extends AbstractTimeOffset
Represents a time offset expressed as a percentage (between 0 and 100).
Represents an item in a SortedList. Base class for Ad and Creative.
The sequence number of this item within its parent.
Type: number
Represents survey information for data collection.
The MIME type of the resource being served.
Type: string
The URI to any resource relating to an integrated survey.
Type: string
The main thing that's missing is validation. There are a few steps to this:
- Use validator to check all values passed to setters.
- Verify that every required property is set.
- Write tests for the validation code.
- Enclose all validation code in marker comments (e.g.,
// <strict>
). This will allow us to strip it out and produce a lightweight "loose" build without any validation, making tags load faster.
PRs welcome!
MIT