# Look Up Checks

This tutorial shows how to look up [Checks](/es-es/docs/concepts/payment-types/checks) by their sender or recipient, in JavaScript.

## Prerequisites

- You should be familiar with the basics of using the [xrpl.js client library](/es-es/docs/tutorials/get-started/get-started-javascript).
- To get any results, the addresses you're looking up must have at least one Check entry in the ledger. See also: [Send a Check](/es-es/docs/tutorials/payments/send-a-check).


## Source Code

The complete source code for this tutorial is available in the source repository for this website:

Checks sample code

## Steps

### 1. Look up all Checks for the address

To get a list of all incoming and outgoing Checks for an account, use the `account_objects` command and set the `type` field of the request to `checks`. You may need to make multiple requests if the result is [paginated](/es-es/docs/references/http-websocket-apis/api-conventions/markers-and-pagination).


```js
// Loop through account objects until marker is undefined ----------------------

let currentMarker = null
let checksFound = []
do {
  const request = {
    command: 'account_objects',
    account: address,
    ledger_index: 'validated',
    type: 'check'
  }

  if (currentMarker) {
    request.marker = currentMarker
  }

  const response = await client.request(request)

  checksFound = checksFound.concat(response.result.account_objects)
  currentMarker = response.result.marker

} while (currentMarker)
```

### 2. Filter the responses by recipient

The response may include Checks where the account from the request is the sender or the recipient. Each member of the `account_objects` array of the response represents one Check. For each such Check object, the address in the `Destination` is address of that Check's recipient, such as in the following code:


```js
// Filter results by recipient ----------------------
// To filter by sender, check Account field instead of Destination

const checksByRecipient = []
for (const check of checksFound) {
  if (check.Destination == address) {
    checksByRecipient.push(check)
  }
}

// Print results ----------------------

if (checksByRecipient.length === 0) {
  console.log('No checks found.')
} else {
  console.log('Checks: \n', JSON.stringify(checksByRecipient, null, 2))
}
```

To filter by sender, check the address in the `Account` field of the Check instead.

For each Check entry in the results, the Check's ID is in the `index` field. You'll need this value to cash or cancel the Check.