# View Swap Feed

## Details

Get a historical feed of all swaps which have happened via your broker.

This call returns completed swaps from oldest to newest. A possible use case is for example the implementation of an information bot. 

To do this, you would query the endpoint starting with `offset=0`, iterate over all returned values and store the `feedId` value while you process the completed swaps. Then you can repeat this but with the `offset` being equal to the last processed `feedId + 1`, until you get an empty array as response.

Each feed entry also includes a `platform` field identifying the provider that handled the swap (e.g. `chainflip`).

## Parameters

You can control the swaps returned by providing the following parameters:

* `offset` - Feed id to return results from.
* `limit` - Number of results to return, defaults to 50, maximum 500.

## API Endpoint

* [`/feed`](https://chainflip-broker.io/docs/ui/index.html#tag/Swaps/operation/getSwapFeed) - View swaps feed, sorted oldest to newest.

## Example

> **Tip**
>
> Want to test first? Change the API base URL to `https://perseverance.chainflip-broker.io`. The [Testing](https://docs.chainflip-broker.io/environments/testing/) environment swaps testnet assets with no real value.
>
> Swap the API key in the examples for your own [production API key](https://chainflip-broker.io/register). Testing requires a separate [testnet API key](https://perseverance.chainflip-broker.io/register).

```bash
curl --location 'https://chainflip-broker.io/feed?apiKey=87517a91d5f34dbabfc1e410946a3a3c&offset=0&limit=35'
```

```json
[
  {
    "feedId": 1,
    "swapId": 3692,
    "platform": "chainflip",
    "status": {
      "state": "completed",
      "swapId": "202826",
      "sourceAsset": "flip.eth",
      "destinationAsset": "usdc.eth",
      "destinationAddress": "0x2c1f0390f27740257de9f3772d9a6bb46ec13fe3",
      "depositChannel": {
        "id": "5927204-Ethereum-890",
        "createdAt": 1735521930000,
        "createdAtDate": "2024-12-30T01:25:30+00:00",
        "brokerCommissionBps": 5,
        "depositAddress": "0x51d2de9fb3bd0fe97cc28906da5077a6d1f9f21a",
        "sourceChainExpiryBlock": "21518169",
        "estimatedExpiryTime": 1735596006000,
        "estimatedExpiryDate": "2024-12-30T22:00:06+00:00",
        "isExpired": false,
        "openedThroughBackend": false,
        "affiliateBrokers": [
          {
            "account": "cFJZVRaybb2PBwxTiAiRLiQfHY4KPB3RpJK22Q7Fhqk979aCH",
            "commissionBps": 10
          }
        ]
      },
      "estimatedDurationSeconds": 204,
      "sourceChainRequiredBlockConfirmations": 7,
      "fees": [
        {
          "type": "network",
          "asset": "usdc.eth",
          "amountNative": "13724",
          "amount": 0.013724
        },
        {
          "type": "liquidity",
          "asset": "flip.eth",
          "amountNative": "6836693899672849",
          "amount": 0.006836693899672849
        },
        {
          "type": "broker",
          "asset": "usdc.eth",
          "amountNative": "20565",
          "amount": 0.020565
        },
        {
          "type": "ingress",
          "asset": "flip.eth",
          "amountNative": "1326612200654300058",
          "amount": 1.326612200654300058
        },
        {
          "type": "egress",
          "asset": "usdc.eth",
          "amountNative": "1359884",
          "amount": 1.359884
        }
      ],
      "deposit": {
        "amountNative": "15000000000000000000",
        "amount": 15,
        "transactionReference": "0xfbf92a7004de733435a23675d35c81cdf9da160eac39ecc08213f55b1239258a",
        "witnessedAt": 1735522074000,
        "witnessedAtDate": "2024-12-30T01:27:54+00:00",
        "witnessedBlockIndex": "5927228-986"
      },
      "swap": {
        "originalInputAmountNative": "13673387799345699942",
        "originalInputAmount": 13.673387799345699942,
        "remainingInputAmountNative": "0",
        "remainingInputAmount": 0,
        "swappedInputAmountNative": "13673387799345699942",
        "swappedInputAmount": 13.673387799345699942,
        "swappedIntermediateAmountNative": "0",
        "swappedIntermediateAmount": 0,
        "swappedOutputAmountNative": "13689269",
        "swappedOutputAmount": 13.689269,
        "regular": {
          "inputAmountNative": "13673387799345699942",
          "inputAmount": 13.673387799345699942,
          "outputAmountNative": "13689269",
          "outputAmount": 13.689269,
          "scheduledAt": 1735522074000,
          "scheduledAtDate": "2024-12-30T01:27:54+00:00",
          "scheduledBlockIndex": "5927228-985",
          "executedAt": 1735522086001,
          "executedAtDate": "2024-12-30T01:28:06.001+00:00",
          "executedBlockIndex": "5927230-1734",
          "retryCount": 0
        }
      },
      "swapEgress": {
        "amountNative": "12329385",
        "amount": 12.329385,
        "scheduledAt": 1735522086001,
        "scheduledAtDate": "2024-12-30T01:28:06.001+00:00",
        "scheduledBlockIndex": "5927230-1737",
        "transactionReference": "0x9511afc91eed67b0ea3fce0cb5a71e06f95171744c1f87d1167648bb1f9afb2e",
        "witnessedAt": 1735522290000,
        "witnessedBlockIndex": "5927264-1037"
      },
      "lastStateChainUpdateAt": 1735522309469,
      "lastStateChainUpdateAtDate": "2024-12-30T01:31:49.469+00:00"
    }
  }
]
```
