# CIP Proposal 18 - Configuration flag to remove API query limit defaults

**URL:** <https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017>\
**Category:** Counterparty\
**Created:** [September 2, 2018, 8:57pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017 "2018-09-02T20:57:35Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 2, 2018, 8:57pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/1 "2018-09-02T20:57:36Z")

</div>

This is the discussion thread for the proposed CIP 18 to remove API query limits by configuration flags.

Link to the CIP: [https://github.com/CounterpartyXCP/cips/blob/cip18/cip-0018.md](https://github.com/CounterpartyXCP/cips/blob/cip18/cip-0018.md)

Please, discuss.

---

<div class="post-metadata">

**Author:** ![jdogresorg](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/jdogresorg/32/1349_2.png) [@jdogresorg](https://forums.counterparty.io/u/jdogresorg)\
**Post date:** [September 3, 2018, 3:21am UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/2 "2018-09-03T03:21:47Z")

</div>

Overall I think making API limit a configurable option is a good idea.

> Adding an API\_LIMIT\_1000 flag in config.py, making it configurable from the counterparty-cli code, and acting on its setting in api.py.

Rather than a boolean flag to indicate a limit of 1000 or no limit, I would prefer a API\_LIMIT flag which can be configured to any integer, with 0 indicating no limit .

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 3, 2018, 3:24am UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/3 "2018-09-03T03:24:30Z")

</div>

This could make sense, would there be any issue limiting queries below 1000? wouldn’t that be backwards incompatible? (software should be aware then that there’s a limit different than expected, maybe get that info on get\_running\_info call?)

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 3, 2018, 4:24am UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/4 "2018-09-03T04:24:52Z")

</div>

Changed the CIP to account for @jdogresorg suggestion, which seems reasonable.

---

<div class="post-metadata">

**Author:** ![mandelduck](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mandelduck](https://forums.counterparty.io/u/mandelduck)\
**Post date:** [September 4, 2018, 4:03pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/5 "2018-09-04T16:03:13Z")

</div>

@chiguireitor ch What would the default `API_LIMIT_ROWS` be in the config file?  
You mentioned in the CIP that care needs to be take so that no default configuration makes the node susceptible to DDOS attacks

---

<div class="post-metadata">

**Author:** ![jdogresorg](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/jdogresorg/32/1349_2.png) [@jdogresorg](https://forums.counterparty.io/u/jdogresorg)\
**Post date:** [September 4, 2018, 4:16pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/6 "2018-09-04T16:16:21Z")

</div>

IMO the default should be 1000 (same as it is now). The new feature is the ability to customize that limit or disable it entirely (set value to 0).

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 4, 2018, 7:41pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/7 "2018-09-04T19:41:53Z")

</div>

Indeed, default should be 1000 to allow non-configured-for-this-feature instances to continue working the same

---

<div class="post-metadata">

**Author:** ![jdogresorg](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/jdogresorg/32/1349_2.png) [@jdogresorg](https://forums.counterparty.io/u/jdogresorg)\
**Post date:** [September 4, 2018, 8:43pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/8 "2018-09-04T20:43:19Z")

</div>

A CIP bounty address has been requested for CIP-18.

Address `13CoTjbVaYzg9kQ2arjKcCmzT5WZmRfgdq` has been provisioned to hold donated funds for CIP-18

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 5, 2018, 4:32am UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/9 "2018-09-05T04:32:05Z")

</div>

Initial commits for CIP18 support

> **[CounterpartyXCP/counterparty-lib](https://github.com/CounterpartyXCP/counterparty-lib/tree/apilimit1000)**
>
> Counterparty Protocol Reference Implementation. Contribute to CounterpartyXCP/counterparty-lib development by creating an account on GitHub.

> **[CounterpartyXCP/counterparty-cli](https://github.com/CounterpartyXCP/counterparty-cli/tree/apilimit1000)**
>
> Counterparty Protocol Command‐Line Interface. Contribute to CounterpartyXCP/counterparty-cli development by creating an account on GitHub.

Testing underway

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 6, 2018, 5:26pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/10 "2018-09-06T17:26:31Z")

</div>

What should be the expected behaviour for a server with a limit lower than 1000 with a non-limited call? silently send the limited amount and pray for the best or fail fast so developers get informed about the non-standard limits (current coded behaviour)?

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 6, 2018, 5:40pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/11 "2018-09-06T17:40:41Z")

</div>

PRs merged to master:

> <https://github.com/CounterpartyXCP/counterparty-lib/pull/1042>

> <https://github.com/CounterpartyXCP/counterparty-cli/pull/118>

Milestone #1 achieved (although merged to master, won’t ask milestone #3 after testing #2) [https://github.com/CounterpartyXCP/cips/blob/master/cip-0018.md](https://github.com/CounterpartyXCP/cips/blob/master/cip-0018.md)

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 7, 2018, 3:59pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/12 "2018-09-07T15:59:05Z")

</div>

Installing mainnet server for the test atm. Sync up to block ~423k right now

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 11, 2018, 11:07pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/13 "2018-09-11T23:07:52Z")

</div>

Test server with on mainnet has been deployed and synced up (finally)

[http://mg.contimita.com:4000](http://mg.contimita.com:4000)

Username/Password: rpc/1234

Current api limit rows: 0

Limit should be specified explicitly in calls to prevent standard default behaviour (if not specified in the call, a limit of 1000 is applied).

Because of the size of some calls, unbounded queries over a non-local uplink will take a good time to complete, be sure about what you want to query before putting “limit”: 0

Also, just to note… some calls like “get\_issuances” with limit 0 are gona DoS the server for a very long time while replying stuff… if it happens hit me up here or in the telegram channel (same nick as here)

---

<div class="post-metadata">

**Author:** ![jdogresorg](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/jdogresorg/32/1349_2.png) [@jdogresorg](https://forums.counterparty.io/u/jdogresorg)\
**Post date:** [September 12, 2018, 4:36am UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/14 "2018-09-12T04:36:13Z")

</div>

I did a few simple tests using `get_issuances` and `get_balances` and passing 0 or a `limit` over 1000 returns more than 1000 results as expected.

`get_issuances` API call with 0 limit returns over 1000 results

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/counterpartytalk/original/2X/5/5e19bdd6852d5a47d1ce0f939b0a94e24031896b.png)

`get_balances` API call with 0 limit returns over 1000 results

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/counterpartytalk/original/2X/7/7c5e0f7f48526909542e129808f382905124522e.png)

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 12, 2018, 2:04pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/15 "2018-09-12T14:04:21Z")

</div>

Ok, restarting the xcp server with limit set to 100

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 12, 2018, 2:11pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/16 "2018-09-12T14:11:40Z")

</div>

Default behavior is to error out because of the lower limit.

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 12, 2018, 2:15pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/17 "2018-09-12T14:15:57Z")

</div>

Found a bug: Setting limit to 0 on a limited or default server returns the whole set.

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 12, 2018, 3:37pm UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/18 "2018-09-12T15:37:58Z")

</div>

Bugfix pushed to master

---

<div class="post-metadata">

**Author:** ![chiguireitor](https://yyz2.discourse-cdn.com/flex004/user_avatar/forums.counterparty.io/chiguireitor/32/675_2.png) [@chiguireitor](https://forums.counterparty.io/u/chiguireitor)\
**Post date:** [September 13, 2018, 2:21am UTC](https://forums.counterparty.io/t/cip-proposal-18-configuration-flag-to-remove-api-query-limit-defaults/5017/19 "2018-09-13T02:21:05Z")

</div>

Seems like the feature is done, slated for release on the next milestone (you can also pull from master to get the latest).
