Hi everyone,
I am working on a new module and would like to integrate an API function to fetch data from an external service. I was wondering if there is a best way to do this without affecting the performance of the existing module? Has anyone done something similar and can share their experience or sample code?
Thanks a lot!
Integrate API into new module
-
- New Member
- Posts: 1
- Joined: Sat Nov 02, 2024 4:53 am
Re: Integrate API into new module
I do that a lot, but it is not a small task, depending quite a bit on the size and number of features the API offers, and the ones you want to deploy with the API.
Also the methodology may vary depending on which technology you use to access the endpoints and any webhooks that may provide. The access of documentation and code samples (or even complete libs) is paramount to how you choose to organize your code.
Typically I create a number of classes under my module's lib folder, which CMSMS can auto load without having to worry with that and, if there is already a lib for PHP I put it on another folder under lib and explicitly include it. Whether I create or not a wrapper class of my own is a matter of assessing the characteristics of the lib, if I use just a sub-set of features or all of them, etc.
There is no "one size fits all" solution but this is my usual approach.
Also the methodology may vary depending on which technology you use to access the endpoints and any webhooks that may provide. The access of documentation and code samples (or even complete libs) is paramount to how you choose to organize your code.
Typically I create a number of classes under my module's lib folder, which CMSMS can auto load without having to worry with that and, if there is already a lib for PHP I put it on another folder under lib and explicitly include it. Whether I create or not a wrapper class of my own is a matter of assessing the characteristics of the lib, if I use just a sub-set of features or all of them, etc.
There is no "one size fits all" solution but this is my usual approach.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!