Documentation Center

The binaryComponent root query

To fetch a binary resource, identify its namespace, Publication ID, and either its binary ID or the relative URL of one its variants. Alternatively, you can also fetch a binary resource using only the Content Manager URI of its corresponding Multimedia Component.

The following binaryComponent call fetches a binary resource using the identifiers of its namespace (1 for Tridion Sites, 2 for Tridion Docs), Publication, and of the binary resource itself:
binaryComponent(namespaceId: 1, publicationId: 98, binaryId: 442598)

This call fetches the binary resource with identifier 442598 from the Tridion Sites Publication with ID 98.

The following binaryComponent call fetches a binary resource using the identifiers of its namespace, Publication, and the relative URL of one of the variants of the resource on the published website:
binaryComponent(namespaceId: 2, publicationId: 28, url: "/pressreleases/images/logo_large.png")

This call fetches the binary resource that has one variant corresponding to the URL http://www.example.com/pressreleases/images/logo_large.png (where http://www.example.com is the published website) from the Tridion Docs Publication with ID 28.

To fetch only one specific binary variant of the binary resource, specify a url parameter in the variants subfield of the binaryComponent field. Set this url parameter to the same value as that of the url parameter of the parent binaryComponent field. For example:
binaryComponent(publicationId: 17, namespaceId: 1, url: "/media/bulls-eye_small.jpg") {
  lastPublishDate
  variants(url: "/media/bulls-eye_small.jpg") {
    binaryId
    variantId
    downloadUrl
    url
    type
  }
}
To fetch a binary resource using its Content Manager URI only, include a call like the following in your query:
binaryComponent(cmUri: "tcm:42-2417-16")

This call fetches the binary resource with the Tridion Sites Content Manager URI tcm:42-2417-16, which uniquely identifies the item.

binaryComponent(cmUri: "ish:16-984-16")

This call fetches the binary resource with the Tridion Docs Content Manager URI ish:16-984-16, which uniquely identifies the item.