How to use Rules to limit the number of searches to pull data from a remote API? I have a custom views query plugin that pull data from a remote API.
I use this plugin to save all information so user don't have to enter all details anymore.

User inputs value to search filter and all mapped data is displayed on the page.

I want to limit the number of attempt allowed to a user of 3 searches every 24 hours. So in a day, user can have 3 attempts to make a successful query of data from the remote api. Then, there might me a warning message that appears on the page after those failure attempts. Each day is equivalent to a calendar date. 

$vats is where user input value is set in the view search filter. This value is an integer.

$vats = isset($filters['vat']) ? $filters['vat'] : NULL;
$Vid = $vats[0];

$result = CVRClient::get($Vid, $country, 'Unit Testing');


Here's the path of my view page with arguments:  query/query?vat=12345678, 1st 'query' is the sitename and 2nd is the menu path name.

Can this be achieve by Rules? If yes, I would appreciate if someone can guide me ways to do it.
Preface
You added an interesting comment below your question, part of it is like so:

All users is registered via Keycloak and page will redirect to Drupal site after its successful registration. This redirected page is the custom view plugin created. For users to be able to add its company details. And so users will enter their VAT # to get data from the CVR Register. ...

Followed by this extra comment:

query/query?vat=12345678. First 'query' is the sitename, then 2nd is the menu path name

So you have a relative path like in this example /query?vat=12345678. And therefor the answer to your question (= Can this be achieve by Rules?) is Yes, Si, Oui, Ja ... Read on for more details to guide you ...
Solution
You may want to try the &quot;Rules URL argument&quot; module. Here is a quote about it (from its project page):

... provides two rules conditions based on URL arguments:

check if a URL argument is present.
compare the value of an URL argument.

It also provides an action that makes the value of an URL argument available as new variable to Rules.

The newly provided Rules actions and conditions can be found under the &quot;URL Argument&quot; conditions and actions groups in the rule configuration interface.
For an example of how to use it, refer to Comment # 3 in issue # 1686360 which is about &quot;Pass an amount to the url, ie; site/content/node-title?amount=10 or /node-title?=amount:10&quot;. Here is the relevant part of it:


add a &quot;Check if URL argument exist&quot; condition to your rule and set the &quot;ARGUMENT&quot; value to &quot;amount&quot;.
add &quot;Provide URL argument value&quot; action to the rule and set &quot;URL ARGUMENT NAME&quot; value to &quot;amount&quot; and in the &quot;Provided variables&quot; section &quot;ARGUMENT FROM URL - Variable name&quot; to e.g. &quot;amount_from_url&quot;.

You will now be able to use the amount value as a variable &quot;amount-from-url&quot; for other actions in this rule.

So with that you can use Rules to (let's say) &quot;monitor&quot; the usage of that path by an authenticated user. Some more details about the custom rule you could create for this:

Rules Event: drupal is initializing (sorry, that's probably the only one that you would be able to use).

Rules Conditions (pick whatever fits, and/or mix however you want):

user has a specific role (or the negation of it).
check the current path (verify if it starts with query).
check if URL argument vat= is present.



The only thing left to do is to think of something appropriate for some Rules Action(s) to be performed, knowing that you do have these crucial data available:

the current user who tries to use this path again.
the actual value (=12345678) that was used.

Obviously, at a minimum you'd want to add a Rules Action to perform an appropriate &quot;redirect&quot; if the 3 attempts have been used on the same day already.
You'd have to do some more homework/refinements, but here is a blueprint of a basic solution that could work:

Solution 1 (easiest approach to implement):

Use the Flag module (eg with 3 none-global flags labeled like attempt 1, attempt 2 and attempt 3).
Add a Rules Action to flag the user with the relevant flag (corresponding to the number of succeeded attempts before).
Add an extra Rules Condition to verify that not all flags have been used (with the same flagging date!).


Solution 2 (= my recommended approach, though a bit tougher to implement): Use the Message module to create a custom activity log, to log each event where the actual URL has been used (with success). And improve the Rule above to add a rules condition to count the number of such messages (= custom activity log records) created already in the last 24 hours.


PS: I'm assuming this is about D7 ...