GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

DataSourceBuilder

DataSourceBuilder

BlazeSDK.DataSourceBuilder() returns a factory whose methods each produce a BlazeDataSourceType. Pick the method that matches how you select content: by label expression, by explicit IDs, by free text, by recommendations, or by combining several sources.

See Content recommendations for how Recommendations, Trending, and Personalization (explicit vs implicit) are described in Concepts. On Web, optional personalized on labels() uses BlazePersonalized. That property adds optional ID or label filtering; it isn't the same as the Concepts term personalization. On native, see BlazeDataSourcePersonalizedType (iOS) and BlazeDataSourcePersonalizedType (Android).

labels(params: LabelsDataSourceParams): BlazeDataSourceType

ParameterTypeRequiredDescription
params.labelsstringstring[]A string, array of strings, or BlazeWidgetLabel representing the labels. Mandatory if text not provided.
params.text?stringstring[]Search term (case-insensitive). Searches content metadata in the context of the labels. To search irrespective of labels, use the text() method.
params.labelsPriority?stringstring[]A string, an array of strings, or an array of BlazeWidgetLabel for priority.
params.orderType?OrderTypeNoThe order type
params.maxItems?numberNoThe maximum number of items
personalized?objectNoOptional BlazePersonalized filter (IDs or labels). See Content recommendations for how Concepts names differ from this API option.

// Labels only 
const dataSource = BlazeSDK.DataSourceBuilder().labels({
  labels: BlazeSDK.LabelBuilder().atLeastOneOf('top-stories', 'live-stories'),
  labelsPriority: `[${BlazeSDK.LabelBuilder().singleLabel('live-stories')}]`,
  orderType: 'RecentlyUpdatedFirst',
  maxItems: 4,
});

// Labels + Text 
const dataSourceWithText = BlazeSDK.DataSourceBuilder().labels({
  labels: 'soccer',  // Required - filters content to soccer-related items
  text: 'goals',      // Optional - searches for "goals" within soccer-labeled content
  orderType: 'RecentlyUpdatedFirst',
  maxItems: 10
});

ids(params: IdsDataSourceParams): BlazeDataSourceType

ParameterTypeRequiredDescription
params.idsstring[]YesAn array of strings representing the IDs.
params.orderType?OrderTypeNoThe order type,
const dataSource = BlazeSDK.DataSourceBuilder().ids({
   ids: ['1234','5678'],
   orderType: 'RecentlyUpdatedFirst',
 });

text(params: TextDataSourceParams): BlazeDataSourceType

Searches content by text across the entire video catalog metadata. This method performs a text-only search without any label filtering, allowing you to search all available content.

ParameterTypeRequiredDescription
params.textstringYesSearch term (case-insensitive). Searches across video catalog metadata.
params.orderType?OrderTypeNoThe order type
params.maxItems?numberNoThe maximum number of items

Supported Content Types: story, moment, video

Use Case: Use this method when you want to search across all content without restricting to specific labels. The search is performed on the video catalog metadata (titles, descriptions, etc.).

const dataSource = BlazeSDK.DataSourceBuilder().text({
  text: 'championship goals',
  orderType: 'RecentlyUpdatedFirst',
  maxItems: 10
});

Note: For text search within a specific label context, use the labels() method with the text parameter instead.

recommendations(params: RecommendationsDataSourceParams): BlazeDataSourceType

For you is viewer-specific; Trending is global across the Experiences platform. See Content recommendations.

ParameterTypeRequiredDescription
params.recommendations.forYou.anyLabelFilter?string[]NoShow contents that match any of these labels.
params.recommendations.forYou.coldStartLabels?string[]NoCold start labels for For you only. See Cold start for For you.
params.recommendations.trending.anyLabelFilter?string[]NoShow contents that match any of these labels in the trending feed.

Supported Web SDK version: @wscsports/blaze-web-sdk 0.35.6 or later. The For you cold start parameter coldStartLabels is available in 0.35.6 or later.

const forYouDataSource = BlazeSDK.DataSourceBuilder().recommendations({
  recommendations: {
    forYou: {
      anyLabelFilter: ['soccer'],
      // Cold start: shown only to new viewers, until they reach the interaction threshold
      coldStartLabels: ['top-moments', 'trending-teams'],
      },
  }});

const trendingDataSource = BlazeSDK.DataSourceBuilder().recommendations({
  recommendations: {
    trending: {
      anyLabelFilter: ['soccer'],
    },
 }});

composite(params: CompositeDataSourceParams): BlazeDataSourceType

Combines several independent data sources into a single deduplicated feed. Sub sources are fetched in parallel and merged in the order they are declared, keeping the first occurrence of a duplicated item. Use it to blend content from different sources (for example, editorial labels plus a recommendations feed) into one widget.

ParameterTypeRequiredDescription
params.dataSourcesarrayYesThe data sources to combine, in priority order. Each entry has a dataSource and an optional config.
params.dataSources[].dataSourceBlazeDataSourceTypeYesA data source built with any other DataSourceBuilder method (labels, ids, text, recommendations).
params.dataSources[].config?objectNoPer source configuration. Set isMandatory: true to make a fetch failure for that source fail the whole composite. Default false.

An empty response (0 items) from a source is not treated as a failure. When a source is not mandatory and its fetch fails, the composite continues with the remaining sources.

Supported Web SDK version: @wscsports/blaze-web-sdk 0.36.1 or later.

const dataSource = BlazeSDK.DataSourceBuilder().composite({
  dataSources: [
    {
      dataSource: BlazeSDK.DataSourceBuilder().labels({ labels: 'featured' }),
      config: { isMandatory: true },
    },
    {
      dataSource: BlazeSDK.DataSourceBuilder().recommendations({
        recommendations: { forYou: { anyLabelFilter: ['soccer'] } },
      }),
    },
  ],
});

const widget = BlazeSDK.WidgetRowView('container-id', { dataSource });

Related

BlazeDataSourceType | LabelBuilder | VideoFiltersBuilder | Ordering and item limits


Did this page help you?