Skip to main content
Skip table of contents

Searching using search rails

Description

You can set up a rails template specifically for search results (see Set up a search template). A client application can perform a search by sending a request to Content Builder, which will return a rails template populated with the search results.

The app can display it in the same way that it displays any other rails template. This means that you can use the same code and do not need different, specific code for displaying search results.

Request

To search using a particular search template, send a GET request to:

CODE
https://server:port/contentdelivery/v2/templateviews/{templateid/templatename}?q="<query>"

Preconditions

The operator should have created the search template. See Set up a search template.

The template name or ID used in this request is the one specified during template creation.

Headers

  • Authorization: Bearer – bearer token

  • Content-Type: application/json

  • Nagra-Target – the destination (e.g., TV). This determines the template layout that is returned. (A layout can have a destination of of tv, mobile, tablet, and/or desktop, or all of these.)

  • Nagra-Device-Type – the device type (e.g., Android or iOS). This determines the technicals that are are returned in rails responses.

  • Accept-Language – the locale (e.g., en_GB)

Mandatory arguments

  • {templateid/templatename} – the client must pass either a template ID or a template name (both are unique)

  • "<query>"– the search query term(s). For example, "Sylvester%20Stallone" or "Adventure%20Time".

Response

A successful request returns an HTTP 200 status. The response includes the contents of the specified template, populated with the search results.

An unsuccessful request returns an HTTP 500 status if there was a problem with the request.

Example

CODE
{
  "name": "First Rail",
  "title": "Home",
  "layout": "portrait",
  "properties": {
    "secret": "sssshh!"
  },
  "sections": [
    {
      "type": "SearchItem",
      "properties": {
        "secret": "sssshh!"
      },
      "source": "string",
      "contents": [
        {
          "type": "editorial",
          "id": "GLOBAL_star_wars",
          "title": "Star Wars",
          "Actors": [
            "Harrison Ford"
          ],
          "rating": {
            "code": "string",
            "precedence": "string",
            "title": "string"
          },
          "ratings": [
            {
              "code": "string",
              "precedence": "string",
              "title": "string"
            }
          ],
          "duration": 120,
          "description": "Space action",
          "synopsis": "Space action",
          "categories": [
            "Space",
            "Action"
          ],
          "seriesRef": "string",
          "tmsId": "GLOBAL_star_wars",
          "contentType": "movie",
          "seasonNumber": 0,
          "episodeNumber": 0,
          "episode": 0,
          "year": 0,
          "images": [
            {
              "name": "small_16_9",
              "aspectRatio": "string",
              "height": 0,
              "width": 0,
              "uri": "string",
              "hints": [
                "string"
              ]
            }
          ],
          "technicals": [
            {
              "id": "string",
              "isSTCU": true,
              "isLTCU": true,
              "media": {
                "AV_PlaylistName": {
                  "frameDuration": 0,
                  "format": "string",
                  "id": "string",
                  "fileName": "string"
                }
              },
              "deviceType": "string",
              "promoImages": [
                "string"
              ],
              "products": {
                "id": "string",
                "startPurchase": "string",
                "endValidity": "string",
                "startValidity": "string",
                "rentalDuration": 0,
                "price": {
                  "startPurchase": 0,
                  "endPurchase": "string",
                  "currency": "string",
                  "value": 0
                },
                "platformRef": "string",
                "endPurchase": 0,
                "impulsive": true,
                "regions": [
                  "string"
                ],
                "title": "string",
                "type": "string"
              }
            }
          ],
          "links": [
            {
              "provider": "Netflix",
              "type": "string",
              "action": "string",
              "url": "https://netflix.com/abc/xyz"
            }
          ]
        },
        {
          "type": "programme",
          "editorial": {
            "type": "editorial",
            "id": "GLOBAL_star_wars",
            "title": "Star Wars",
            "Title": "Star Wars",
            "Actors": [
              "Harrison Ford"
            ],
            "rating": {
              "code": "string",
              "precedence": "string",
              "title": "string"
            },
            "ratings": [
              {
                "code": "string",
                "precedence": "string",
                "title": "string"
              }
            ],
            "duration": 120,
            "Description": "Space action",
            "Synopsis": "Space action",
            "Categories": [
              "Space",
              "Action"
            ],
            "seriesRef": "string",
            "Directors": [
              "string"
            ],
            "Producers": [
              "string"
            ],
            "TmsId": "GLOBAL_star_wars",
            "contentType": "movie",
            "SeasonNumber": 0,
            "episodeNumber": 0,
            "Episode": "string",
            "year": 0,
            "Images": [
              "string"
            ],
            "technicals": [
              {
                "id": "string",
                "media": {
                  "AV_PlaylistName": {
                    "id": "string",
                    "fileName": "string",
                    "drmId": "string",
                    "drmInstanceName": "string",
                    "format": "string",
                    "uri": "string"
                  }
                },
                "isSTCU": true,
                "isLTCU": true,
                "guardTimeStart": "string",
                "guardTimeEnd": "string",
                "cUStartDate": 0,
                "cUEndDate": 0
              }
            ],
            "position": 0,
            "sportType": "string",
            "ltcuRepresentationOfStcu": true,
            "PromoImages": [
              "string"
            ],
            "nodeRefs": [
              "string"
            ],
            "DisplayPriority": {
              "additionalProp1": "string",
              "additionalProp2": "string",
              "additionalProp3": "string"
            },
            "InHomeBlockingRequired": true,
            "CUStartDate": 0,
            "CUEndDate": 0,
            "period": {
              "duration": 0,
              "start": 0,
              "end": 0
            }
          },
          "id": "string",
          "title": "string",
          "contentRef": "string",
          "rating": {
            "code": "string",
            "precedence": "string",
            "title": "string"
          },
          "ratings": [
            {
              "code": "string",
              "precedence": "string",
              "title": "string"
            }
          ],
          "periodStart": "string",
          "periodEnd": "string",
          "airingStartTime": 0,
          "airingEndTime": 0,
          "promoImages": [
            "string"
          ],
          "serviceRef": "string",
          "tmsId": "string",
          "isnPvr": "string",
          "isStartOver": true,
          "isCatchUp": true,
          "categories": [
            "string"
          ],
          "drmId": "string",
          "contentType": "string",
          "seasonNumber": 0,
          "episodeNumber": 0,
          "episode": 0,
          "synopsis": "string",
          "seriesRef": "string",
          "images": [
            {
              "name": "small_16_9",
              "aspectRatio": "string",
              "height": 0,
              "width": 0,
              "uri": "string",
              "hints": [
                "string"
              ]
            }
          ],
          "technicals": [
            {
              "id": "string",
              "isSTCU": true,
              "isLTCU": true,
              "media": {
                "AV_PlaylistName": {
                  "frameDuration": 0,
                  "format": "string",
                  "id": "string",
                  "fileName": "string"
                }
              },
              "deviceType": "string",
              "promoImages": [
                "string"
              ],
              "products": {
                "id": "string",
                "startPurchase": "string",
                "endValidity": "string",
                "startValidity": "string",
                "rentalDuration": 0,
                "price": {
                  "startPurchase": 0,
                  "endPurchase": "string",
                  "currency": "string",
                  "value": 0
                },
                "platformRef": "string",
                "endPurchase": 0,
                "impulsive": true,
                "regions": [
                  "string"
                ],
                "title": "string",
                "type": "string"
              }
            }
          ]
        },
        {
          "btvServices": {
            "id": "string",
            "locale": "en_GB",
            "isFreemium": true,
            "deviceType": [
              "ION"
            ],
            "editorial": {
              "id": "string",
              "period": {
                "duration": 0,
                "start": 0,
                "end": 0
              }
            },
            "technical": {
              "id": "string",
              "period": {
                "duration": 0,
                "start": 0,
                "end": 0
              },
              "catchUpSupport": true,
              "startOverSupport": true,
              "title": "string",
              "shortName": "string",
              "longName": "string",
              "description": "string"
            }
          },
          "btvProgramme": {
            "type": "programme",
            "editorial": {
              "type": "editorial",
              "id": "GLOBAL_star_wars",
              "title": "Star Wars",
              "Title": "Star Wars",
              "Actors": [
                "Harrison Ford"
              ],
              "rating": {
                "code": "string",
                "precedence": "string",
                "title": "string"
              },
              "ratings": [
                {
                  "code": "string",
                  "precedence": "string",
                  "title": "string"
                }
              ],
              "duration": 120,
              "Description": "Space action",
              "Synopsis": "Space action",
              "Categories": [
                "Space",
                "Action"
              ],
              "seriesRef": "string",
              "Directors": [
                "string"
              ],
              "Producers": [
                "string"
              ],
              "TmsId": "GLOBAL_star_wars",
              "contentType": "movie",
              "SeasonNumber": 0,
              "episodeNumber": 0,
              "Episode": "string",
              "year": 0,
              "Images": [
                "string"
              ],
              "technicals": [
                {
                  "id": "string",
                  "media": {
                    "AV_PlaylistName": {
                      "id": "string",
                      "fileName": "string",
                      "drmId": "string",
                      "drmInstanceName": "string",
                      "format": "string",
                      "uri": "string"
                    }
                  },
                  "isSTCU": true,
                  "isLTCU": true,
                  "guardTimeStart": "string",
                  "guardTimeEnd": "string",
                  "cUStartDate": 0,
                  "cUEndDate": 0
                }
              ],
              "position": 0,
              "sportType": "string",
              "ltcuRepresentationOfStcu": true,
              "PromoImages": [
                "string"
              ],
              "nodeRefs": [
                "string"
              ],
              "DisplayPriority": {
                "additionalProp1": "string",
                "additionalProp2": "string",
                "additionalProp3": "string"
              },
              "InHomeBlockingRequired": true,
              "CUStartDate": 0,
              "CUEndDate": 0,
              "period": {
                "duration": 0,
                "start": 0,
                "end": 0
              }
            },
            "id": "string",
            "title": "string",
            "contentRef": "string",
            "rating": {
              "code": "string",
              "precedence": "string",
              "title": "string"
            },
            "ratings": [
              {
                "code": "string",
                "precedence": "string",
                "title": "string"
              }
            ],
            "periodStart": "string",
            "periodEnd": "string",
            "airingStartTime": 0,
            "airingEndTime": 0,
            "promoImages": [
              "string"
            ],
            "serviceRef": "string",
            "tmsId": "string",
            "isnPvr": "string",
            "isStartOver": true,
            "isCatchUp": true,
            "categories": [
              "string"
            ],
            "drmId": "string",
            "contentType": "string",
            "seasonNumber": 0,
            "episodeNumber": 0,
            "episode": 0,
            "synopsis": "string",
            "seriesRef": "string",
            "images": [
              {
                "name": "small_16_9",
                "aspectRatio": "string",
                "height": 0,
                "width": 0,
                "uri": "string",
                "hints": [
                  "string"
                ]
              }
            ],
            "technicals": [
              {
                "id": "string",
                "isSTCU": true,
                "isLTCU": true,
                "media": {
                  "AV_PlaylistName": {
                    "frameDuration": 0,
                    "format": "string",
                    "id": "string",
                    "fileName": "string"
                  }
                },
                "deviceType": "string",
                "promoImages": [
                  "string"
                ],
                "products": {
                  "id": "string",
                  "startPurchase": "string",
                  "endValidity": "string",
                  "startValidity": "string",
                  "rentalDuration": 0,
                  "price": {
                    "startPurchase": 0,
                    "endPurchase": "string",
                    "currency": "string",
                    "value": 0
                  },
                  "platformRef": "string",
                  "endPurchase": 0,
                  "impulsive": true,
                  "regions": [
                    "string"
                  ],
                  "title": "string",
                  "type": "string"
                }
              }
            ]
          }
        }
      ],
      "size": 5
    }
  ]
}

See also

For full details of this API, see the Content Delivery API documentation.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.