# Fuel API doesn't support reverse pagination for transactions

**URL:** <https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605>\
**Category:** General\
**Created:** [November 13, 2023, 4:58pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605 "2023-11-13T16:58:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpoplavkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/mpoplavkov/32/399_2.png) [@mpoplavkov](https://forum.fuel.network/u/mpoplavkov)\
**Post date:** [November 13, 2023, 4:58pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/1 "2023-11-13T16:58:56Z")

</div>

I’m trying execute the following request in Fuel’s graphQL API:

```auto
query TransactionsByOwner($address: Address) {
  transactionsByOwner(owner: $address, last: 10) {
    nodes {
      id
    }
  }
}

```

And I’m getting the following error:

```auto
{
  "data": null,
  "errors": [
    {
      "message": "reverse pagination isn't supported for this resource",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "transactionsByOwner"
      ]
    }
  ]
}

```

The same request with the `first` parameter instead of `last` works, but shows the oldest transactions first:

```auto
query TransactionsByOwner($address: Address) {
  transactionsByOwner(owner: $address, first: 10) {
    nodes {
      id
    }
  }
}

```

That means that the only direction the pagination for transactions work is from oldest transactions to the newest. That makes it impossible or inefficient to make a proper pagination of transactions, requesting pages of transactions from newest to oldest.

Please add support for query parameters `last` and `before`

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [November 16, 2023, 4:33pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/2 "2023-11-16T16:33:44Z")

</div>

Fuel’s client leverages RocksDB for data storage, and as evidenced in the source code at [FuelLabs/fuel-core](https://github.com/FuelLabs/fuel-core/blob/2a3b385095beecd8340ce3e5c5349a19c5ca0443/crates/fuel-core/src/schema/tx.rs#L174), RocksDB does not inherently support reverse iteration over a prefix. This limitation can be observed in the way the data is managed within the system.

But I totally get that this is a big deal and a useful feature to have. I’m going to bring this up with the client team and see what we can do about it. Thanks for pointing it out – it’s really helpful feedback. 🙂

---

<div class="post-metadata">

**Author:** ![mpoplavkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/mpoplavkov/32/399_2.png) [@mpoplavkov](https://forum.fuel.network/u/mpoplavkov)\
**Post date:** [November 16, 2023, 5:35pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/3 "2023-11-16T17:35:27Z")

</div>

Great, thank you! We’re having this issue since beta-2 and were hoping that it’s an obvious problem and were waiting for the fix which didn’t come 😃 Next time will file such problems right away

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [November 16, 2023, 5:39pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/4 "2023-11-16T17:39:48Z")

</div>

I do apologize for this, @mpoplavkov and I really appreciate you guys for being patient with us 🙏

---

<div class="post-metadata">

**Author:** ![mpoplavkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/mpoplavkov/32/399_2.png) [@mpoplavkov](https://forum.fuel.network/u/mpoplavkov)\
**Post date:** [November 16, 2023, 5:41pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/5 "2023-11-16T17:41:57Z")

</div>

It’s impossible to avoid such problems in an actively developing project, there is nothing to apologize for 🙌 It’s our bad that we haven’t filed this issue earlier 🙂

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [November 16, 2023, 9:49pm UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/6 "2023-11-16T21:49:04Z")

</div>

Green from our client team is the GOAT

👀 👀 👀

> <https://github.com/FuelLabs/fuel-core/pull/1492>
>
> Reverting the change https://github.com/FuelLabs/fuel-core/pull/1004 and adds su…pport for reverse prefix iteration in the RocksDB.

---

<div class="post-metadata">

**Author:** ![mpoplavkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/mpoplavkov/32/399_2.png) [@mpoplavkov](https://forum.fuel.network/u/mpoplavkov)\
**Post date:** [November 17, 2023, 9:58am UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/7 "2023-11-17T09:58:44Z")

</div>

Awesome! Hope to see this change in the API soon!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [December 8, 2023, 5:58am UTC](https://forum.fuel.network/t/fuel-api-doesnt-support-reverse-pagination-for-transactions/3605/8 "2023-12-08T05:58:45Z")

</div>

Closed on December 8, 2023, 5:58am UTC

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
