List Users

Learn how to retrieve Marqeta users’ information.

Overview

In this lesson, we’ll look at a couple of useful endpoints that allow us to retrieve a list of all registered Marqeta users as well as a single Marqeta user’s information.

Endpoints

Get all users

We can get a list of all users by making a GET request to the {BASE_URL}/users endpoint. This enlists all the active and non-active users. This endpoint allows us to filter the visibility of the response fields if required. This endpoint also supports pagination, which allows us to retrieve a specific range of resources from a complete and sorted list of returned resources.

Get user information

Similarly, we can retrieve the information of a single Marqeta user by making a GET request to the {BASE_URL}/users/{token} endpoint. The path parameter ({token}) refers to the token of the user whose information we want to retrieve. This endpoint allows us to filter the visibility of the response fields if required.

Request parameters

Parameter

Type

Category

Description

token

string

required

Token of the user whose information we want to retrieve

Note: This is a path parameter to get a single user.

fields

string

optional

A comma-separated list of fields we want like to retrieve

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

count

integer

optional

Number of users to retrieve

Allowable values: 1–10

Note: This is a query parameter to get all users.

search_type

string

optional

Type of search

Allowable values: query_then_fetch, dfs_query_then_fetch

Note: This is a query parameter to get all users.

sort_by

string

optional

Sorts by the given value

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

start_index

integer

optional

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

Note: This is a query parameter to get all users.

Sample codes

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

Click the “Run” button in the code widget below to see the list of all users.

Press + to interact
url = '{{BASE_URL}}users'
response = requests.get(url, headers=headers)
printResponse(response)

Line 1: We have the value for {token}, which is a required path parameter, that we stored in the previous lesson. However, we may also use any token value from the output of the code above.

Line 3: We append the optional query parameter, fields, to the url in order to specify the fields we want to retrieve. E.g., we can use the following URL to retrieve the first_name of the user instead of the complete user object, as shown below:

{BASE_URL}/users/{token}?fields=first_name

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

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

Output

When the first block of code is successfully executed, the output displays the requested number of user objects with their attributes. This is in addition to the total amount of users as well as other information.

For the second block of code, the output displays the complete user object that corresponds to the given token with all of the requested data fields.

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