Get the first five script tags
Description
The following query retrieves the ID of the first five script tags for a shop.
Query
query {
scriptTags(first: 5) {
edges {
node {
id
}
}
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { scriptTags(first: 5) { edges { node { id } } } }"
}'
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 {
scriptTags(first: 5) {
edges {
node {
id
}
}
}
}`,
);
const json = await response.json();
return json.data;
}
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 {
scriptTags(first: 5) {
edges {
node {
id
}
}
}
}
QUERY
response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
scriptTags(first: 5) {
edges {
node {
id
}
}
}
}`,
});
Shopify CLI
shopify app execute \
--query \
'query {
scriptTags(first: 5) {
edges {
node {
id
}
}
}
}'
Response
{
"scriptTags": {
"edges": [
{
"node": {
"id": "gid://shopify/ScriptTag/193372190"
}
},
{
"node": {
"id": "gid://shopify/ScriptTag/408148298"
}
},
{
"node": {
"id": "gid://shopify/ScriptTag/466217408"
}
},
{
"node": {
"id": "gid://shopify/ScriptTag/558170166"
}
},
{
"node": {
"id": "gid://shopify/ScriptTag/764371933"
}
}
]
}
}
Get the first script tag with a specific source URL
Description
The following query retrieves the ID of the first script tag for a shop with a specific source URL.
Query
query {
scriptTags(first: 1, src: "https://js.example.org/foo.js") {
edges {
node {
id
}
}
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { scriptTags(first: 1, src: \"https://js.example.org/foo.js\") { edges { node { id } } } }"
}'
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 {
scriptTags(first: 1, src: "https://js.example.org/foo.js") {
edges {
node {
id
}
}
}
}`,
);
const json = await response.json();
return json.data;
}
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 {
scriptTags(first: 1, src: "https://js.example.org/foo.js") {
edges {
node {
id
}
}
}
}
QUERY
response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
scriptTags(first: 1, src: "https://js.example.org/foo.js") {
edges {
node {
id
}
}
}
}`,
});
Shopify CLI
shopify app execute \
--query \
'query {
scriptTags(first: 1, src: "https://js.example.org/foo.js") {
edges {
node {
id
}
}
}
}'
Response
{
"scriptTags": {
"edges": [
{
"node": {
"id": "gid://shopify/ScriptTag/466217408"
}
}
]
}
}
Retrieves a list of all script tags
Query
query GetScriptTags($first: Int!, $cursor: String) {
scriptTags(first: $first, after: $cursor) {
nodes {
id
cache
createdAt
displayScope
src
updatedAt
}
pageInfo {
startCursor
endCursor
}
}
}
Variables
{
"first": 5,
"cursor": null
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query GetScriptTags($first: Int!, $cursor: String) { scriptTags(first: $first, after: $cursor) { nodes { id cache createdAt displayScope src updatedAt } pageInfo { startCursor endCursor } } }",
"variables": {
"first": 5,
"cursor": null
}
}'
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 GetScriptTags($first: Int!, $cursor: String) {
scriptTags(first: $first, after: $cursor) {
nodes {
id
cache
createdAt
displayScope
src
updatedAt
}
pageInfo {
startCursor
endCursor
}
}
}`,
{
variables: {
"first": 5,
"cursor": null
},
},
);
const json = await response.json();
return json.data;
}
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 GetScriptTags($first: Int!, $cursor: String) {
scriptTags(first: $first, after: $cursor) {
nodes {
id
cache
createdAt
displayScope
src
updatedAt
}
pageInfo {
startCursor
endCursor
}
}
}
QUERY
variables = {
"first": 5,
"cursor": null
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query GetScriptTags($first: Int!, $cursor: String) {
scriptTags(first: $first, after: $cursor) {
nodes {
id
cache
createdAt
displayScope
src
updatedAt
}
pageInfo {
startCursor
endCursor
}
}
}`,
"variables": {
"first": 5,
"cursor": null
},
},
});
Shopify CLI
shopify app execute \
--query \
'query GetScriptTags($first: Int!, $cursor: String) {
scriptTags(first: $first, after: $cursor) {
nodes {
id
cache
createdAt
displayScope
src
updatedAt
}
pageInfo {
startCursor
endCursor
}
}
}' \
--variables \
'{
"first": 5,
"cursor": null
}'
Response
{
"scriptTags": {
"nodes": [
{
"id": "gid://shopify/ScriptTag/193372190",
"cache": false,
"createdAt": "2024-10-29T22:38:08Z",
"displayScope": "ONLINE_STORE",
"src": "https://js.example.org/online_store.js",
"updatedAt": "2024-10-29T22:38:08Z"
},
{
"id": "gid://shopify/ScriptTag/408148298",
"cache": false,
"createdAt": "2024-10-29T22:38:08Z",
"displayScope": "ALL",
"src": "https://protocol-relative.com/foo.js",
"updatedAt": "2024-10-29T22:38:08Z"
},
{
"id": "gid://shopify/ScriptTag/466217408",
"cache": false,
"createdAt": "2024-10-29T22:38:08Z",
"displayScope": "ALL",
"src": "https://js.example.org/foo.js",
"updatedAt": "2024-10-29T22:38:08Z"
},
{
"id": "gid://shopify/ScriptTag/558170166",
"cache": false,
"createdAt": "2024-10-29T22:38:08Z",
"displayScope": "ALL",
"src": "https://js.example.org/bar.js?bar=baz",
"updatedAt": "2024-10-29T22:38:08Z"
},
{
"id": "gid://shopify/ScriptTag/764371933",
"cache": false,
"createdAt": "2024-10-29T22:38:08Z",
"displayScope": "ALL",
"src": "https://secure-js.example.org/bar.js?bar=baz",
"updatedAt": "2024-10-29T22:38:08Z"
}
],
"pageInfo": {
"startCursor": "eyJsYXN0X2lkIjoxOTMzNzIxOTAsImxhc3RfdmFsdWUiOiIxOTMzNzIxOTAifQ==",
"endCursor": "eyJsYXN0X2lkIjo3NjQzNzE5MzMsImxhc3RfdmFsdWUiOiI3NjQzNzE5MzMifQ=="
}
}
}