Showing results for 
Search instead for 
Did you mean: 

Connect external 3rd API endpoint to Magento 2.4

Connect external 3rd API endpoint to Magento 2.4

Hello everyone, I’m new to this forum and also to the Magento platform.  I’m looking at using Magento for an online bookstore that requires connecting to a 3rd party Web Service via API.  The vendor has provided all of the necessary documents and resources (example files) for developing an API that connects to their product database endpoint. 


The Vendor supports REST or SOAP over a secure HTTP connection.  SOAP follows the HTTP request/response message model providing SOAP request parameters in an HTTPS request and SOAP response parameters in an HTTPS response.


They also support REST POST using a basic HTTP header formatted to follow the basic access authentication, with the username and password combined into a string "username: password". This string is then Base64 encoded using the iso-8859-1 character set. The results are returned in an XML format – which I must treat as an object, transform via a style sheet, and/or translate the XML into a temporary table for my shopping cart.


The vendor also provided a Web Services Definition Language (WSDL), which describes the operations, the data format, and data types for the query requests and responses. The application must interpret the WSDL to provide the application access to these operations.


Here is my scenario:  


Currently, Magento 2.4.3 is installed on a CentOS 7 Apache dedicated server with ElasticSearch, PHP 7.4, MySQL 8.0, Memcached, Varnish, and RabbitMQ as per Magento requirements. 


The Web Service is for dynamically populating WebPages therefore downloading data into a database is prohibited, my site will contain featured items and static marketing booklists, booklists that change occasionally, such as bestseller or book club readings and I can cache some data, including images so that the data is more easily accessible for faster page loading and to reduce server "hits".


As an alternative to pulling data for every item retrieved in a query result, I am allowed to cache the data for a limited period, refreshing at an interval that best fits my business requirements, e.g., 7 days, 30 days, 60 days, etc.


Depending on the type of product information requested, each query will need to pass a QueryType. The data received from the vendors’ database contains more data than what’s needed on the product description page and I need to understand how to parse this in Magento if possible.   


Any category page (i.e. Children’s books, Cook Books, etc.) can also have up to 25 cached products that are displayed on that page with pagination for more products each with 25 products.  


My questions are:


  1. Which API protocol (SOAP or REST) does the Magento application support for external endpoints?  
  2. How do I implement/interface the supported API with the 3rd party API connection on the Magento CMS?
  3. How do I filter the necessary data (attributes) from the API response for displaying on the website product page?
  4. As an alternative, can I implement the API onto ElasticSearch utilizing its indexing functions and have Magento process it for the frontend, and is so how?  
  5. Has anyone done this before and if so can you share the implementation?

     Thanks in advance.   


Re: Connect external 3rd API endpoint to Magento 2.4

Hello! Have you solved your question? I have the same issue. Thanks.