Check a card balance
To check a card balance, pass in the
card_reference
to the Cards
query.API call
Variables
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"
}
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 for your query, the API will respond with blank JSON for “Data”:
{
"data": {
"Cards": {
"data": [],
"total": 0,
"per_page": 1
}
}
}
Last modified 1yr ago