# `getSafeOperationsByAddress`

Returns the list of Safe operations associated to a Safe account.

<Callout type="info" emoji="ℹ️">
The SafeOperations methods are currently compatible with Entrypoint v0.6, which corresponds to `safeModuleVersion` v0.2.0. If you need to use v0.7, you should use the `relay-kit` `Safe4337Pack` class with `safeModuleVersion` v0.3.0, and collect the signatures yourself.

Examples of how to use the `Safe4337Pack` are provided in the following links:
- [Playgrounds](https://github.com/safe-global/safe-core-sdk/tree/main/playground/relay-kit)
- [Guide](https://docs.safe.global/sdk/relay-kit/guides/4337-safe-sdk)
</Callout>

## Usage


<Tabs items={['example.ts', 'setup.ts']}>
  <Tabs.Tab>
    ```typescript
    import { GetSafeOperationListProps } from '@safe-global/api-kit'
    import { apiKit } from './setup.ts'

    const safeAddress = '0x...'
    const options: GetSafeOperationListOptions = {      
      executed: false, // Optional,
      hasConfirmations: true, // Optional,
      ordering: 'created', // Optional      
      limit: '10', // Optional
      offset: '50' // Optional
    }

    const safeOperationsResponse = await apiKit.getSafeOperationsByAddress(safeAddress, options)
    ```
  </Tabs.Tab>
  <Tabs.Tab>
    ```typescript
    import SafeApiKit from '@safe-global/api-kit'

    // How to get an Api key => http://docs.safe.global/core-api/how-to-use-api-keys
    export const apiKit = new SafeApiKit({
      chainId: 1n, // Mainnet
      apiKey: 'YOUR_API_KEY'
    })
    ```
  </Tabs.Tab>
</Tabs>


## Returns

`Promise<GetSafeOperationListResponse>`

The paginated list of Safe operations.

## Parameters

### `safeAddress`

- **Type:** `string`

The Safe address.

```typescript focus=2
const safeOperationsResponse = await apiKit.getSafeOperationsByAddress({
  safeAddress: '0x...'
})
```

### `options.executed` (Optional)

- **Type:** `boolean`

When `true` it will return the Safe operations whose associated User Operation was already executed in the bundler.
When `false` it will return the Safe operations that are pending to execute.

If omitted, it will return all the Safe operations.

```typescript focus=4
const safeOperationsResponse = await apiKit.getSafeOperationsByAddress(
  {
    safeAddress: '0x...',
    executed: true,
    ordering: 'created'
  }
)
```

### `options.hasConfirmations` (Optional)

- **Type:** `string`

When `true` it will return the Safe operations that have confirmations from any owner.
When `false` it will return the Safe operations that don't have confirmations.

If omitted, it will return all the Safe operations.

```typescript focus=4
const safeOperationsResponse = await apiKit.getSafeOperationsByAddress(
  {
    safeAddress: '0x...',
    hasConfirmations: true,
    ordering: 'created'
  }
)
```

### `options.ordering` (Optional)

- **Type:** `string`
- **Default:** `-user_operation__nonce`

The field used when ordering the results.

Can be one of: `-user_operation__nonce`, `-created`, `created`.

```typescript focus=4
const safeOperationsResponse = await apiKit.getSafeOperationsByAddress(
  {
    safeAddress: '0x...',
    ordering: 'created'
  }
)
```

### `options.limit` (Optional)

- **Type:** `number`

The number of results to return per page.

```typescript focus=4
const safeOperationsResponse = await apiKit.getSafeOperationsByAddress(
  {
    safeAddress: '0x...',
    limit: 10
  }
)
```

### `options.offset` (Optional)

- **Type:** `number`

The initial index from which to return the results.

```typescript focus=4
const safeOperationsResponse = await apiKit.getSafeOperationsByAddress(
  {
    safeAddress: '0x...',
    offset: 50
  }
)
```
