Anchor to blog
blog
query
Returns a Blog resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to BlogBlog•
Shopify stores come with a built-in blogging engine, allowing a shop to have one or more blogs. Blogs are meant to be used as a type of magazine or newsletter for the shop, with content that changes over time.
Was this section helpful?
- Receive a single Blog
- Retrieves a count of all articles from a blog
- Retrieves a list of all articles from a blog
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query BlogShow($id: ID!) {
blog(id: $id) {
id
title
handle
}
}`,
{
variables: {
"id": "gid://shopify/Blog/397675442"
},
},
);
const data = await response.json();
query BlogShow($id: ID!) {
blog(id: $id) {
id
title
handle
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query BlogShow($id: ID!) { blog(id: $id) { id title handle } }",
"variables": {
"id": "gid://shopify/Blog/397675442"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query BlogShow($id: ID!) {
blog(id: $id) {
id
title
handle
}
}`,
{
variables: {
"id": "gid://shopify/Blog/397675442"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query BlogShow($id: ID!) {
blog(id: $id) {
id
title
handle
}
}`,
"variables": {
"id": "gid://shopify/Blog/397675442"
},
},
});
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 BlogShow($id: ID!) {
blog(id: $id) {
id
title
handle
}
}
QUERY
variables = {
"id": "gid://shopify/Blog/397675442"
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Blog/397675442"
}
Response
JSON{
"blog": {
"id": "gid://shopify/Blog/397675442",
"title": "Yo Blog",
"handle": "smallcheese-blog"
}
}