Home

PHP

Merchants API

You can use this API call to search or browse through all available merchants in our catalog. You can query a merchant alongside with its associated programs and cashback offers. Each merchant has an unique ID, a name, a logo, a description and an URL. A merchant can have one or several programs associated to it, each of them having their own affiliate link and their own unique ID. The programs have cashback offers associated to them. By using this API call you will also get the cashback offers for each program, that can be identified by an offer ID, a title, currency and the value of the cashback offer. Each cashback offer has an affiliate link. This API call can help you develop your eCommerce shopping services, being an important tool for affiliate marketing developers. The data offered by this API is well structured and easy to integrate with websites, apps or other types of reward platforms.

API Function: get_merchants

Parameters:

Name Type Description
username string Your API username. You should have received this with your account
subscription_id string Your Subscription ID. You can copy or regenerate it from your API management interface.
network_id numeric Enter a network's ID to display merchants having programs in that particular network only.
country_id numeric The ID of the country to return descriptions for. This field must be always equal or greater than 1
category_id numeric

The ID of the category for which you want to return the list of merchants.

exclude_network_id numeric

The ID of the network you want to exclude from the response

 

Response fields:

Name Type Description
merchant_id numeric The unique ID associated with the merchant
merchant_name string The merchant's name
merchant_description string The merchant's description
merchant_url string A link pointing to the merchant's website
merchant_logo string The logo url of the merchant
has_cashback numeric Can be {0,1} and tell if the merchant has cashback offers
count_products numeric Count products available in get_products call for the merchant









              
              

                  
                import java.io.File;
                import java.io.FileOutputStream;
                import java.io.OutputStream;

                import javax.xml.parsers.DocumentBuilder;
                import javax.xml.parsers.DocumentBuilderFactory;
                import javax.xml.soap.MessageFactory;
                import javax.xml.soap.MimeHeaders;
                import javax.xml.soap.SOAPBody;
                import javax.xml.soap.SOAPConnection;
                import javax.xml.soap.SOAPConnectionFactory;
                import javax.xml.soap.SOAPElement;
                import javax.xml.soap.SOAPEnvelope;
                import javax.xml.soap.SOAPMessage;
                import javax.xml.soap.SOAPPart;

                import org.w3c.dom.Document;
                import org.w3c.dom.NodeList;

                public class client {

                        public static void main(String[] args) {

                                readFromSoap();
                                pharse();

                        }

                        private static void readFromSoap()
                        {
                                SOAPConnection soapConnection;
                        SOAPConnectionFactory soapConnectionFactory;
                        SOAPMessage soapResponse;        

                        try {
                                        soapConnectionFactory = SOAPConnectionFactory.newInstance();
                                        soapConnection = soapConnectionFactory.createConnection();

                                    // Send SOAP Message to SOAP Server
                                String url = "https://synced.io/api/v2";
                                soapResponse = soapConnection.call(createSOAPRequest(), url);	

                                // print SOAP Response
                                System.out.print("Response SOAP Message:");
                                OutputStream out = new FileOutputStream("get_merchants.xml");
                                soapResponse.writeTo(out);

                                soapConnection.close();		        


                                } catch (Exception e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                        }

                        private static void pharse()
                        {
                                try {	
                                 File inputFile = new File("get_merchants.xml");
                                 DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
                                 DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
                                 Document doc = dBuilder.parse(inputFile);
                                 doc.getDocumentElement().normalize();

                                 System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

                                 NodeList nList = doc.getElementsByTagName("merchant");
                                 System.out.println("----------------------------");
                                 System.out.println(nList.getLength());

                                 for (int k = 0; k < nList.getLength(); k++)
                                 {
                                         NodeList nodes = nList.item(k).getChildNodes();

                                         for (int j=0; j < nodes.getLength(); j++)
                                         {

                                                 String nodeName = nodes.item(j).getNodeName();
                                                 String value = nodes.item(j).getTextContent();

                                                 switch (nodeName) {
                                                        case "merchant_id":
                                                                System.out.print(" id :" + value);
                                                                break;
                                                        case "merchant_name":
                                                                System.out.print(" name :" + value);
                                                                break;
                                                        default:
                                                                break;
                                                        }

                                         }
                                         System.out.println("");
                                         System.out.println("-----------------------------------");
                                 }



                              } catch (Exception e) {
                                 e.printStackTrace();
                              }		
                        }

                        private static SOAPMessage createSOAPRequest() throws Exception {
                        MessageFactory messageFactory = MessageFactory.newInstance();
                        SOAPMessage soapMessage = messageFactory.createMessage();
                        SOAPPart soapPart = soapMessage.getSOAPPart();

                        String serverURI = "https://synced.io/api/v2/";

                        // SOAP Envelope
                        SOAPEnvelope envelope = soapPart.getEnvelope();
                        envelope.addNamespaceDeclaration("v2", serverURI);


                        // SOAP Body
                        SOAPBody soapBody = envelope.getBody();

                        SOAPElement soapBodyElem = soapBody.addChildElement("get_merchants", "v2");

                        SOAPElement soapBodyElem0  = soapBodyElem.addChildElement("username");
                        soapBodyElem0.addTextNode("*******");

                        SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("subscription_id");
                        soapBodyElem1.addTextNode("*******");

                        SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("network_id");
                        soapBodyElem2.addTextNode("0");

                        SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("country_id");
                        soapBodyElem3.addTextNode("221");        

                        MimeHeaders headers = soapMessage.getMimeHeaders();
                        headers.addHeader("SOAPAction", serverURI  + "get_merchants");

                        soapMessage.saveChanges();

                        /* Print the request message */
                        System.out.print("Request SOAP Message:");
                        soapMessage.writeTo(System.out);

                        System.out.println();
                        return soapMessage;
                    }	

                }
                  
                  
                  
                  
              
              
              
<?php   
$api_username      = '*******';
$api_subscription  = '*******';

$api_network_id    = 0;   // replace with your network id
$api_category_id   = 0;   // replace with your category id
$api_country_id    = 221; // replace with your country id

$api_exclude_network_id = 0; // replace with network id you want to exclude

try
{
        $client    = new SoapClient('https://synced.io/api/v2?wsdl');
        $merchants = $client->get_merchants($api_username, $api_subscription, $api_network_id, $api_country_id, $api_category_id, $api_exclude_network_id);			
}
catch(Exception $e)
{
        echo $e->getMessage();
}    


if(!empty($merchants))
{
    print_r($merchants);
}
?>