Toggle Developers
HomeAcademy
  • Welcome
  • GraphQL
    • Getting started
    • Exploring our API
    • Authentication
    • API playground
    • Error handling
  • Key concepts
    • Overview
      • Orders, Transactions & Line Items
      • Card number formats
  • Basics
    • Create a card
    • Check a card balance
    • Redeem a card
  • Webhooks
    • Overview
      • Getting started
      • Authentication & responses
    • Events
      • Card.balance_adjusted
      • Card.card_reference_updated
      • Card.expiry_reminder
      • Card.registered
      • Card.send_recipient_email
      • Card.resend_recipient_email
      • Order.created
      • Order.cancelled
      • Order.send_receipt_email
      • Order.send_cancellation_email
      • Payment.failed
      • Payment.review_opened
      • Fulfilment.dispatched
  • Partner Guides
    • EPOS & Ordering
      • Overview
      • Accreditation
      • Configuration variables
      • Playground examples
      • Physical card orders
      • Custom validity rules
      • Balance check
      • Redemptions & top-ups
      • Reversals
    • Guest gratuity
      • Overview
      • Accreditation
      • Configuration variables
      • Playground examples
      • Creating a card
      • Cancelling a card
      • Register a card
    • CRM
      • Overview
      • Historic data via GraphQL
      • Real time data via webhooks
Powered by GitBook
On this page
  • Pagination
  • If no cards are found
  1. Basics

Check a card balance

To check a card balance, pass in the card_reference to the Cards query.

query($card_reference: String!, $page: Int!, $limit: Int!, $id: Int) {
  Cards(card_reference: $card_reference, limit: $limit, page: $page, id: $id) {
    data {
      card_reference,
      balance,
      initial_balance,
      created_at,
      updated_at
    },
    total,
    per_page
  }
}
{
  "limit": 1,
  "page": 1,
  "card_reference": "6301190000554511994"
}

Pagination

You'll notice there are variables for limit and page. This is because, in theory, this query could return multiple results. You would use these variables to loop through the pages of returned results.

However, for a single card query for a balance check, in reality, you're only ever going to get back one card (or no cards, if no matching card is found), so you shouldn't need to worry about looping through results for this particular use-case.

If no cards are found

If no cards are found for your query, the API will respond with blank JSON for “Data”:

{
  "data": {
    "Cards": {
      "data": [],
      "total": 0,
      "per_page": 1
    }
  }
}

PreviousCreate a cardNextRedeem a card

Last updated 3 years ago