Scheduled update of exchange rates
Due to the Riksbank (Sweden's central bank) updating their API from SOAP to REST, a new limit of a maximum of 5 requests per minute from the same IP address has been introduced. This means that those of you who update exchange rates via the scheduler in Monitor ERP are affected by this limitation if you:
-
Update more than 5 currencies at the same time, in the same company, either via the scheduler or manually via the “Update now” button.
-
Have several companies on the same server (same IP address) which update more than 5 currencies in total.
Please note that the limit applies per IP address. The limit can therefore be reached in each company, despite not updating more than 5 currencies at the same time if you update more than 5 currencies for all companies. If Company 1 updates 3 currencies and Company 2 updates 3 currencies, the limit will be reached as the companies have the same IP address.
Read more about the Riksbank’s changes on their website.
Features to facilitate the updating of exchange rates
The following features help with the updating of exchange rates with regard to the request limit:

A registered API key allows 200 requests per minute from the same IP address.
By registering in the Riksbank’s API portal, you receive an API key. Enter the key in the API key field under the Scheduling tab in the Currencies procedure.
Please note that the same API key can be entered in multiple companies.
Click here to go to the Riksbank’s API portal. On their website you register by clicking Sign up in the upper right hand corner.

If more than 5 currencies will be updated in a company, a queue system is used. This means that when the planned update is run, Monitor ERP automatically separates the currencies into groups of 5, these groups then are placed into a queue which is run with an interval of one minute.
The queue system is used even if the currencies are updated manually via the Update now button in cases where more than 5 currencies are selected to be updated.
If the scheduling is preset to update at 23:00, you will be able to see in the table that all currencies are updated, but that some currencies will have a one minute interval from when the first run started.
Here is an example of how a planned update of 7 currencies at 10:25 works:
At 10:25 the result of the first run is can be seen:
1 minute later, at 10:26, the result of the second run can be seen:
In the currency table we can see the result of the update:
From version 24.2 onwards, a message is shown letting you know that an update will be run in the background. When you click OK, the update procedure closes. The result of the currency update can be seen in the procedure within a couple of minutes (as soon as the currencies are updated).

When there are multiple companies in the same system (server IP address) using a scheduled update of exchange rates at the same time (e.g. preset to 23:00), the companies will receive an error messages from Riksbank API that the request limit of 5 requests per minute has been reached. This is because each company is going to update their currencies (groups of 5 if more than 5 currencies are selected) at the same time, 23:00, which results in more than 5 requests totally within the same minute. In cases like this, Monitor ERP will place the unsuccessful currency update in a queue and attempt to update it again at a new time within a randomized time interval. This is done until all currencies are updated in the company.
For Company 1, the run of the 5 currencies starts at 11:55, which immediately results in 2 failed currency updates. One minute later the following group is run, and the remaining 2 currencies will be updated. At the same time, the 2 failed currency updates from the first run (11:55) are added to a queue and attempt to update again at 11:56. A currency is updated while the other fails and queued again, due to the failed currency update a new run starts at 11:58 which updates the remaining currency. Within 3 minutes, the scheduler has updated 7 of the company’s currencies, but 14 currencies in total in the system (the same IP address).
The result for Company 1:


For company 2, the update of the first 5 currencies begins at 11:55, however 2 of the 5 currencies fail to update. One minute later the next group is run, and the remaining 2 currencies will be updated. The 2 failed updates from the first run are placed in a queue and a new attempt will be made at 11:56, and again at 11:57, but on both occasions the request limit is reached. At 11:58 a new attempt is made, and the currency updates successfully.
The result for Company 2:


Recommendations when updating several exchange rates
-
One company (one server)
If you only have one company on the server and update more than 5 currencies, no action needs to be taken. This is because the scheduler will automatically divide the currencies into groups of 5 and update one group at a time until all values are updated.
It is possible to enter an API key via Riksbank API and increase the limit to 200 requests/minute, but it is not necessary to do so.
-
Several companies on the same server (same IP address)
If you have multiple companies on the same server and are using scheduled updates, it is recommended to use an API key in order to simplify the updating process. The same API key can be entered for multiple companies, it is not unique to a company.
If you don't enter an API key, it is recommended that the time for the scheduler is set with an interval of a few minutes between each company, so that each company updates its currencies at a different time. E.g. If you have 5 companies which each update 10 currencies (please note that the update is in two groups), the below setting would work without any issues:
Company 1 23:00 Company 2 23:05 Company 3 23:10 Company 4 23:15 Company 5 23:20 In this case, there is a decent time margin between the companies’ currency update.
Please note that the smallest margin between the companies is 2 minutes if up to 10 currencies will be updated for each company as each group of currencies is run once every minute.
When choosing a time for the scheduled update, you should ensure that no currency update is scheduled for after the 24 hour cut off as this will result in the wrong exchange rate being loaded (the exchange that should be loaded is that of the following day).If you have multiple companies on the same server (IP address) and are updating so many currencies that even the 200 requests/minute is not enough, it is recommended to combine the above two methods. That being that you use an API key as well as setting the scheduling time for the companies.