List Cards

Learn how to retrieve Marqeta cards’ information.

Overview

In this lesson, we’ll learn how to get a list of all Marqeta cards owned by a specific user. We’ll also learn how to get information about a specific card.

Get all cards owned by a specific user

We can get a list of all Marqeta cards associated with a certain user by making a GET request to the {BASE_URL}/cards/user/{token} endpoint. The path parameter ({token}) refers to the token of the user that we want to retrieve information from. This gives us a list of all the cards associated with that specific user.

This endpoint allows us to filter the visibility of the response fields if necessary. It also supports pagination, which allows us to retrieve a specific range of resources from a complete and sorted list of the returned resources.

Moreover, this endpoint supports object expansion, which lets us optimize API calls and response sizes because it allows us to specify which objects to expand from those returned in the response. For example, as part of the response, this endpoint returns the token of the user who owns the card. We can specify if we want to retrieve the complete user object that corresponds to the returned token as part of the response. This gives us the card object data and the user data with a one API call instead of two.

Request Parameters

Parameter

Type

Category

Description

token

string

required

Token of the user whose cards we want to retrieve

Note: This is a path parameter.

count

integer

optional

Number of cards to retrieve

Allowable values: 1–10

Note: This is a query parameter.

sort_by

string

optional

Sorts and filters by the given value

Note: This is a query parameter. By default, the sorting is done in ascending order. To sort in descending order, add a hyphen (-) to the field name.

start_index

integer

optional

Sort order index of the first object in the array of returned resources

Note: This is a query parameter.

fields

string

optional

Comma-separated list of fields we want to retrieve

Note: This is a query parameter. All fields are returned if this parameter is not supplied with a value.

Line 1: We use the stored USER_TOKEN value for token, the required path parameter.

Note: You may append any of the optional query parameters given in the table above to the url in line 3 to fine-tune your search.

Click the “Run” button in the code widget below to see the output.

Press + to interact
token = '{{USER_TOKEN}}'
url = '{{BASE_URL}}cards/user/' + token
response = requests.get(url, headers=headers)
printResponse(response)

When the code is executed successfully, the output displays the requested number of card objects associated with the specified user. It also displays the total amount of cards as well as other information.

In case of failure, an appropriate error message is displayed.

Get card information

We can get information about a specific card by making a GET request to the {BASE_URL}/cards/{token} endpoint. The path parameter ({token}) refers to the token of the card that we want to retrieve.

This endpoint allows us to filter the visibility of the response fields if necessary. It also supports object expansion, which allows us to optimize API calls and response sizes. Object expansion enables us to specify which objects to expand from those returned in the response.

Request Parameters

Parameter

Type

Category

Description

token

string

required

Token of the card we want to retrieve

Note: This is a path parameter.

fields

string

optional

Comma-separated list of fields we would like to retrieve

Note: This is a query parameter. All fields are returned if this parameter is not supplied.

expand

string

optional

Type of object to include in the response

Allowable values: user, cardproduct

Note: This is a query parameter.

Line 1: We use the value of token (that we saved in the last lesson) for the required path parameter.

Note: You may append any of the optional query parameters given in the table above to the url in line 3 to fine-tune your search.

Click the “Run” button in the code widget below to see the output.

Press + to interact
token = '{{CARD_TOKEN}}'
url = '{{BASE_URL}}cards/' + token
response = requests.get(url, headers=headers)
printResponse(response)

When the code is executed successfully, the output displays the card object that corresponds to the given token with all of the requested data fields.

In case of failure, an appropriate error message is displayed.