Anchor to giftCardgift
giftCard
query
Requires access scope.
Returns a gift card resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to GiftCardGift•
Card Represents an issued gift card.
Was this section helpful?
Retrieves a single gift card
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
giftCard(id: "gid://shopify/GiftCard/411106674") {
balance {
amount
currencyCode
}
}
}`,
);
const data = await response.json();
query {
giftCard(id: "gid://shopify/GiftCard/411106674") {
balance {
amount
currencyCode
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { giftCard(id: \"gid://shopify/GiftCard/411106674\") { balance { amount currencyCode } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
giftCard(id: "gid://shopify/GiftCard/411106674") {
balance {
amount
currencyCode
}
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
giftCard(id: "gid://shopify/GiftCard/411106674") {
balance {
amount
currencyCode
}
}
}`,
});
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 {
giftCard(id: "gid://shopify/GiftCard/411106674") {
balance {
amount
currencyCode
}
}
}
QUERY
response = client.query(query: query)
Response
JSON{
"giftCard": {
"balance": {
"amount": "25.0",
"currencyCode": "USD"
}
}
}