In our October 2015 developer newsletter, we offered to assist you if you wanted to optimize the API usage of your integrations. We were really happy to see that a good number of you contacted us after the newsletter went out and asked us to help optimize your code – and even more happy to see the useful optimizations you have been able to make as a result of this.
We have also been contacting some of you directly when we could see from our logs that you made an excessive amount of API calls, which has also led to improved performance of your integrations and less load on our system.
In fact, the API usage optimizations you’ve made mean that we have seen a 20% reduction in API traffic purely from app optimizations – which is of course beneficial to both you, us and all our customers.
Case: How Daniel Bahl from v5.dk optimized his invoicing integration
Daniel Bahl was one of the integration partners who contacted us. He was working on an integration for creating and handling invoicing for his newly started e-learning portal v5.dk.
His integration used the CurrentInvoice_Create method to create one invoice at a time and then Set methods to set properties on the invoice (e.g., date, currency, payment terms, etc.). After this, he needed to create the invoice lines and set properties on these as well.
This approach resulted in the integration performing calls to e-conomic each time a property had to be set or an invoice or invoice line had to be created. In total, this amounted to a large number of calls, which in turn made the integration slow and resulted in poor performance.
Now to the good part: By using CreateFromDataArray methods instead, Daniel was able to reduce the amount of calls from his integration drastically.
With the CurrentInvoice_CreateFromDataArray method, the integration now includes multiple invoices and their properties in a single call by creating objects and including them in an array that is then sent to the server. Similarly, the CurrentInvoiceLine_CreateFromDataArray method makes is possible to include all lines for all draft invoices in the same call.
Going from 50 to 2.5 minutes in a day’s work
Looking at the entire invoicing flow from creating invoices and invoice lines, booking the invoices and retrieving PDFs, Daniel’s integration has gone from taking 50 minutes to process the invoices to just 2.5 minutes! And it has only taken him one day’s work to achieve this improvement.
In this case, the improvement not only results in a better-performing integration, it also adds real value for the customers who can now receive their invoices a lot faster than before, making the whole invoicing flow much smoother.
The obvious lesson here is that it is much faster and easier to create everything locally and then send one complete package to the server instead of continually sending small chunks back and forth.
As this example shows, the CreateFromDataArray method is really useful. It also works with a lot of other entities than just invoices and invoices lines – you can use it with e.g. cashbook entries, debtors and creditors, orders and quotations, employees, etc. In fact, most methods have a corresponding CreateFromDataArray call.
You can also use the CreateFromData method (without the Array part) if you just want to create a single object with all set properties in a single call.
Other ways of optimizing
Besides implementing DataArray methods, there are some other obvious candidates for optimizing your integration. If you’re using our .NET SDK, you should make sure that you’re using the latest version which includes a number of performance improvements – or even better, stop using it and start connecting to SOAP directly.
Also, using web hooks allows you to be automatically notified in case of e.g. product changes instead of having to frequently check whether this has happened, which will also help you save on your number of calls to e-conomic. You can read more on working with web hooks here.
Get in touch if you need assistance
If you have an integration that you feel could do with some optimizing, and you haven’t yet looked into doing it, please feel free to contact us at firstname.lastname@example.org to get assistance. We’ve been happy to help a lot of you already, and we will continue to be so.