---
title: theme - GraphQL Admin
description: Returns a particular theme for the shop.
api_version: 2025-10
api_name: admin
type: query
api_type: graphql
source_url:
html: https://shopify.dev/docs/api/admin-graphql/latest/queries/theme?example=retrieves-a-single-asset-for-a-theme
md: https://shopify.dev/docs/api/admin-graphql/latest/queries/theme.md?example=retrieves-a-single-asset-for-a-theme
---
# theme
query
Requires `read_themes` access scope.
Returns a particular theme for the shop.
## Arguments
* id
[ID!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID)
required
The ID of the theme.
***
## Possible returns
* OnlineStoreTheme
[OnlineStoreTheme](https://shopify.dev/docs/api/admin-graphql/latest/objects/OnlineStoreTheme)
A theme for display on the storefront.
***
## Examples
* ### Get file content by theme id and filename
#### Query
```graphql
query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files(filenames: ["assets/index.js"], first: 1) {
nodes {
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
```
#### cURL
```bash
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { theme(id: \"gid://shopify/OnlineStoreTheme/225007463\") { id name role files(filenames: [\"assets/index.js\"], first: 1) { nodes { body { ... on OnlineStoreThemeFileBodyText { content } } } } } }"
}'
```
#### React Router
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files(filenames: ["assets/index.js"], first: 1) {
nodes {
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}`,
);
const json = await response.json();
return json.data;
}
```
#### Ruby
```ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files(filenames: ["assets/index.js"], first: 1) {
nodes {
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
QUERY
response = client.query(query: query)
```
#### Node.js
```javascript
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files(filenames: ["assets/index.js"], first: 1) {
nodes {
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}`,
});
```
#### Response
```json
{
"theme": {
"id": "gid://shopify/OnlineStoreTheme/225007463",
"name": "Comfort",
"role": "UNPUBLISHED",
"files": {
"nodes": [
{
"body": {
"content": "console.log('foo');"
}
}
]
}
}
}
```
* ### Get theme by id
#### Query
```graphql
query {
theme(id: "gid://shopify/OnlineStoreTheme/529529152") {
id
name
role
}
}
```
#### cURL
```bash
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { theme(id: \"gid://shopify/OnlineStoreTheme/529529152\") { id name role } }"
}'
```
#### React Router
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
theme(id: "gid://shopify/OnlineStoreTheme/529529152") {
id
name
role
}
}`,
);
const json = await response.json();
return json.data;
}
```
#### Ruby
```ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query {
theme(id: "gid://shopify/OnlineStoreTheme/529529152") {
id
name
role
}
}
QUERY
response = client.query(query: query)
```
#### Node.js
```javascript
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
theme(id: "gid://shopify/OnlineStoreTheme/529529152") {
id
name
role
}
}`,
});
```
#### Response
```json
{
"theme": {
"id": "gid://shopify/OnlineStoreTheme/529529152",
"name": "Comfort",
"role": "MAIN"
}
}
```
* ### Get theme files by theme id
#### Query
```graphql
query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files {
edges {
node {
filename
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
}
```
#### cURL
```bash
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { theme(id: \"gid://shopify/OnlineStoreTheme/225007463\") { id name role files { edges { node { filename body { ... on OnlineStoreThemeFileBodyText { content } } } } } } }"
}'
```
#### React Router
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files {
edges {
node {
filename
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
}`,
);
const json = await response.json();
return json.data;
}
```
#### Ruby
```ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files {
edges {
node {
filename
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
}
QUERY
response = client.query(query: query)
```
#### Node.js
```javascript
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
theme(id: "gid://shopify/OnlineStoreTheme/225007463") {
id
name
role
files {
edges {
node {
filename
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
}`,
});
```
#### Response
```json
{
"theme": {
"id": "gid://shopify/OnlineStoreTheme/225007463",
"name": "Comfort",
"role": "UNPUBLISHED",
"files": {
"edges": [
{
"node": {
"filename": "assets/index.js",
"body": {
"content": "console.log('foo');"
}
}
},
{
"node": {
"filename": "assets/styles.css",
"body": {
"content": "p { color: red; }"
}
}
},
{
"node": {
"filename": "layout/theme.liquid",
"body": {
"content": "
{{ content_for_header }}sandbox
{{ content_for_layout }}
"
}
}
}
]
}
}
}
```
* ### Retrieves a list of assets for a theme
#### Query
```graphql
query ThemeFilesPaginated($themeId: ID!) {
theme(id: $themeId) {
files(first: 50) {
edges {
node {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
userErrors {
code
filename
}
}
}
}
```
#### Variables
```json
{
"themeId": "gid://shopify/OnlineStoreTheme/225007463"
}
```
#### cURL
```bash
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query ThemeFilesPaginated($themeId: ID!) { theme(id: $themeId) { files(first: 50) { edges { node { body { ... on OnlineStoreThemeFileBodyBase64 { contentBase64 } ... on OnlineStoreThemeFileBodyText { content } ... on OnlineStoreThemeFileBodyUrl { url } } checksumMd5 contentType createdAt filename size updatedAt } cursor } pageInfo { endCursor hasNextPage hasPreviousPage startCursor } userErrors { code filename } } } }",
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/225007463"
}
}'
```
#### React Router
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ThemeFilesPaginated($themeId: ID!) {
theme(id: $themeId) {
files(first: 50) {
edges {
node {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
userErrors {
code
filename
}
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/225007463"
},
},
);
const json = await response.json();
return json.data;
}
```
#### Ruby
```ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query ThemeFilesPaginated($themeId: ID!) {
theme(id: $themeId) {
files(first: 50) {
edges {
node {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
userErrors {
code
filename
}
}
}
}
QUERY
variables = {
"themeId": "gid://shopify/OnlineStoreTheme/225007463"
}
response = client.query(query: query, variables: variables)
```
#### Node.js
```javascript
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query ThemeFilesPaginated($themeId: ID!) {
theme(id: $themeId) {
files(first: 50) {
edges {
node {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
cursor
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
userErrors {
code
filename
}
}
}
}`,
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/225007463"
},
},
});
```
#### Response
```json
{
"theme": {
"files": {
"edges": [
{
"node": {
"body": {
"content": "console.log('foo');"
},
"checksumMd5": "fd33535a878f593c91bf93c7b39da272",
"contentType": "application/javascript",
"createdAt": "2024-10-30T22:18:48Z",
"filename": "assets/index.js",
"size": "19",
"updatedAt": "2024-10-30T22:18:48Z"
},
"cursor": "ImFzc2V0c1wvaW5kZXguanMi"
},
{
"node": {
"body": {
"content": "p { color: red; }"
},
"checksumMd5": "5fc2748b49b0a877ea0bb50a105038ab",
"contentType": "text/css",
"createdAt": "2024-10-30T22:18:48Z",
"filename": "assets/styles.css",
"size": "17",
"updatedAt": "2024-10-30T22:18:48Z"
},
"cursor": "ImFzc2V0c1wvc3R5bGVzLmNzcyI="
},
{
"node": {
"body": {
"content": "{{ content_for_header }}sandbox
{{ content_for_layout }}
"
},
"checksumMd5": null,
"contentType": "application/x-liquid",
"createdAt": "2010-07-12T19:31:50Z",
"filename": "layout/theme.liquid",
"size": "3252",
"updatedAt": "2010-07-12T19:31:50Z"
},
"cursor": "ImxheW91dFwvdGhlbWUubGlxdWlkIg=="
}
],
"pageInfo": {
"endCursor": "ImxheW91dFwvdGhlbWUubGlxdWlkIg==",
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "ImFzc2V0c1wvaW5kZXguanMi"
},
"userErrors": []
}
}
}
```
* ### Retrieves a single asset for a theme
#### Query
```graphql
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}
```
#### Variables
```json
{
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
}
```
#### cURL
```bash
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query ThemeFiles($themeId: ID!, $filenames: [String!]!) { theme(id: $themeId) { files(filenames: $filenames) { nodes { body { ... on OnlineStoreThemeFileBodyBase64 { contentBase64 } ... on OnlineStoreThemeFileBodyText { content } ... on OnlineStoreThemeFileBodyUrl { url } } checksumMd5 contentType createdAt filename size updatedAt } userErrors { code filename } } } }",
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
}
}'
```
#### React Router
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
},
},
);
const json = await response.json();
return json.data;
}
```
#### Ruby
```ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}
QUERY
variables = {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
}
response = client.query(query: query, variables: variables)
```
#### Node.js
```javascript
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}`,
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
},
},
});
```
#### Response
```json
{
"theme": {
"files": {
"nodes": [
{
"body": {
"content": "console.log('foo');"
},
"checksumMd5": "fd33535a878f593c91bf93c7b39da272",
"contentType": "application/javascript",
"createdAt": "2024-10-30T22:18:46Z",
"filename": "assets/index.js",
"size": "19",
"updatedAt": "2024-10-30T22:18:46Z"
}
],
"userErrors": []
}
}
}
```
* ### Retrieves a single theme by its ID
#### Query
```graphql
query Theme($id: ID!) {
theme(id: $id) {
createdAt
id
name
prefix
processing
processingFailed
role
themeStoreId
updatedAt
}
}
```
#### Variables
```json
{
"id": "gid://shopify/OnlineStoreTheme/529529152"
}
```
#### cURL
```bash
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query Theme($id: ID!) { theme(id: $id) { createdAt id name prefix processing processingFailed role themeStoreId updatedAt } }",
"variables": {
"id": "gid://shopify/OnlineStoreTheme/529529152"
}
}'
```
#### React Router
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query Theme($id: ID!) {
theme(id: $id) {
createdAt
id
name
prefix
processing
processingFailed
role
themeStoreId
updatedAt
}
}`,
{
variables: {
"id": "gid://shopify/OnlineStoreTheme/529529152"
},
},
);
const json = await response.json();
return json.data;
}
```
#### Ruby
```ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query Theme($id: ID!) {
theme(id: $id) {
createdAt
id
name
prefix
processing
processingFailed
role
themeStoreId
updatedAt
}
}
QUERY
variables = {
"id": "gid://shopify/OnlineStoreTheme/529529152"
}
response = client.query(query: query, variables: variables)
```
#### Node.js
```javascript
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query Theme($id: ID!) {
theme(id: $id) {
createdAt
id
name
prefix
processing
processingFailed
role
themeStoreId
updatedAt
}
}`,
"variables": {
"id": "gid://shopify/OnlineStoreTheme/529529152"
},
},
});
```
#### Response
```json
{
"theme": {
"createdAt": "2024-10-30T22:18:09Z",
"id": "gid://shopify/OnlineStoreTheme/529529152",
"name": "Comfort",
"prefix": "/t/1",
"processing": false,
"processingFailed": false,
"role": "MAIN",
"themeStoreId": 1234,
"updatedAt": "2024-10-30T22:18:09Z"
}
}
```
[Open in GraphiQL](http://localhost:3457/graphiql?query=query%20ThemeFiles\(%24themeId%3A%20ID!%2C%20%24filenames%3A%20%5BString!%5D!\)%20%7B%0A%20%20theme\(id%3A%20%24themeId\)%20%7B%0A%20%20%20%20files\(filenames%3A%20%24filenames\)%20%7B%0A%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20body%20%7B%0A%20%20%20%20%20%20%20%20%20%20...%20on%20OnlineStoreThemeFileBodyBase64%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20contentBase64%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20...%20on%20OnlineStoreThemeFileBodyText%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20content%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20...%20on%20OnlineStoreThemeFileBodyUrl%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20url%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20checksumMd5%0A%20%20%20%20%20%20%20%20contentType%0A%20%20%20%20%20%20%20%20createdAt%0A%20%20%20%20%20%20%20%20filename%0A%20%20%20%20%20%20%20%20size%0A%20%20%20%20%20%20%20%20updatedAt%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20userErrors%20%7B%0A%20%20%20%20%20%20%20%20code%0A%20%20%20%20%20%20%20%20filename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22themeId%22%3A%20%22gid%3A%2F%2Fshopify%2FOnlineStoreTheme%2F225007463%22%2C%0A%20%20%22filenames%22%3A%20%5B%0A%20%20%20%20%22assets%2Findex.js%22%0A%20%20%5D%0A%7D)
```javascript
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
},
},
);
const json = await response.json();
return json.data;
}
```
##### GQL
```
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}
```
##### cURL
```
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query ThemeFiles($themeId: ID!, $filenames: [String!]!) { theme(id: $themeId) { files(filenames: $filenames) { nodes { body { ... on OnlineStoreThemeFileBodyBase64 { contentBase64 } ... on OnlineStoreThemeFileBodyText { content } ... on OnlineStoreThemeFileBodyUrl { url } } checksumMd5 contentType createdAt filename size updatedAt } userErrors { code filename } } } }",
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
}
}'
```
##### React Router
```
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}`,
{
variables: {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
},
},
);
const json = await response.json();
return json.data;
}
```
##### Node.js
```
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}`,
"variables": {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
},
},
});
```
##### Ruby
```
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
theme(id: $themeId) {
files(filenames: $filenames) {
nodes {
body {
... on OnlineStoreThemeFileBodyBase64 {
contentBase64
}
... on OnlineStoreThemeFileBodyText {
content
}
... on OnlineStoreThemeFileBodyUrl {
url
}
}
checksumMd5
contentType
createdAt
filename
size
updatedAt
}
userErrors {
code
filename
}
}
}
}
QUERY
variables = {
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
}
response = client.query(query: query, variables: variables)
```
## Input variables
JSON
```json
{
"themeId": "gid://shopify/OnlineStoreTheme/225007463",
"filenames": [
"assets/index.js"
]
}
```
## Response
JSON
```json
{
"theme": {
"files": {
"nodes": [
{
"body": {
"content": "console.log('foo');"
},
"checksumMd5": "fd33535a878f593c91bf93c7b39da272",
"contentType": "application/javascript",
"createdAt": "2024-10-30T22:18:46Z",
"filename": "assets/index.js",
"size": "19",
"updatedAt": "2024-10-30T22:18:46Z"
}
],
"userErrors": []
}
}
}
```