Welcome to the Electric Distro API!
The API is implemented over standard HTTPS requests. You should post formatted XML via HTTPS request with parameter name "xmldata".
Please follow the guideline to integrate with your applications.
Last modified: 2017/4/21
Catalogue
Data Feeds
There are 2 data feeds:
- https://electricdistro.com/export/phe_xr_eel.xml - XML feed contains all items data.
- https://electricdistro.com/export/inventory_feed.xml - XML feed for inventory only.
Order Submission
API URL: https://www.electricdistro.com/distribution/order/submit
The Order Submission API call is used to submit an order to electricdistro.
You should refer to Appendix B to understand what the API will return using this call.
Example of XML:
<?xml version="1.0" encoding="utf-8"?> <createOrder> <account>[email protected]</account> <password>******</password> <order> <reference>X89895109</reference> <shipping_method>P003</shipping_method> <items> <item> <sku>HH151</sku> <qty>1</qty> </item> <item> <sku>HH151-RED</sku> <qty>1</qty> </item> </items> <lastname>Smith</lastname> <firstname>John</firstname> <street1>191 Wild Turkey Drive</street1> <street2></street2> <city>Holiday Island</city> <state>AZ</state> <postcode>72631</postcode> <country_id>US</country_id> <telephone>(123) 555-1212</telephone> <comment>Special instructions provided by customer for order.</comment> </order> </createOrder>
Response XML - Success:
<?xml version="1.0" encoding="UTF-8"?> <createOrder> <ACK>SUCCESS</ACK> </createOrder>
Response XML - Error:
<?xml version="1.0" encoding="UTF-8"?> <createOrder> <ACK>ERROR</ACK> <message>Shipping method 'P003' is unavailable for worldwide shipment.</message> </createOrder>
Test Mode:
If you submit an order with a "reference" (your order number) starts with the letters "TEST-" (case insensitive),
API will handle your request in test mode. The order will NOT be processed and it will be marked as shipped with a tracking # of "9405511699000699000002".
Example of reference field: <reference>TEST-X89895109</reference>
Payment Method:
Only accept offline payment at this moment.
Order Status
API URL: https://www.electricdistro.com/distribution/order/status
This API call is used to get the status of an previously submitted order. Please send XML with format as following:
Example:
<?xml version="1.0" encoding="utf-8"?> <orderStatus> <account>[email protected]</account> <password>******</password> <reference>X89895109 (Your order reference number)</reference> </orderStatus>
If the order has shipped, the API will return:
<?xml version="1.0" encoding="UTF-8"?> <orderStatus> <ACK>SUCCESS</ACK> <order_number>ED042017W7800040</order_number> <status>complete</status> <trackings> <tracking> <carrier>ups</carrier> <service>United Parcel Service-UPS</service> <track_number>1ZA1529703404000000</track_number> <shipped_date>2016-11-25</shipped_date> </tracking> </trackings> </orderStatus>
If the order has not yet shipped, the API will return:
<?xml version="1.0" encoding="UTF-8"?> <orderStatus> <ACK>SUCCESS</ACK> <order_number>ED042017W7800040</order_number> <status>pending</status> <message>Oder is not shipped yet.</message> </orderStatus>
Item Information
API URL: https://www.electricdistro.com/distribution/product/mainInfo
You can check item stock,UPC,price via this API.
There is a limit of 30 items in a single call.
Example:
<?xml version="1.0" encoding="UTF-8"?> <checkItem> <account>[email protected]</account> <password>******</password> <skus> <sku>HH151</sku> <sku>HH152</sku> </skus> </checkItem>
You will get XML includes SKU,price,QTY and UPC in response.
Example:
<?xml version="1.0"encoding="UTF-8"?> <checkItem> <ACK>SUCCESS</ACK> <items> <item> <sku>HH151</sku> <price>12.00</price> <exact_price>9.60</exact_price> <qty>354.0000</qty> <upc>4890808169117</upc> </item> <item> <sku>HH152</sku> <price>10.00</price> <exact_price>8.00</exact_price> <qty>974.0000</qty> <upc>4890808169131</upc> </item> </items> </checkItem>
Appendix A: Shipping Options
Carrier | Service | API Code |
---|---|---|
UPS/USPS | Cheapest Best Rate | BEST_RATE |
UPS | Ground | UPS01 |
UPS | Three-Day Select | UPS02 |
UPS | Second Day Air | UPS03 |
UPS | Next Day Air | UPS04 |
UPS | Standard (Canada) | UPS06 |
UPS | Worldwide Expedited | UPS25 |
UPS | Saver | UPS26 |
USPS | First Class (< 13oz) | P001 |
USPS | Retail Ground | P002 |
USPS | Priority Mail | P003 |
USPS | Priority Mail Express | P004 |
USPS | International First Class | P021 |
USPS | International Express Mail | P022 |
USPS | International Priority Mail | P023 |
Appendix B: API Error Codes
API will return formatted XML with certain fields as handling result for each call. If no errors, you will get ACK value "SUCCESS". Otherwise, "ERROR" will be in ACK field. In addition, there is a field "error_code" with number to let you know more detail about the error or exception.
Example:
<?xml version="1.0" encoding="UTF-8"?> <orderStatus> <ACK>SUCCESS</ACK> <order_number>ED042017W7800040</order_number> <status>pending</status> <message>Oder is not shipped yet.</message> </orderStatus>
If you submitted an invalid shipping method,you will get back an error:
Example:
<?xml version="1.0" encoding="UTF-8"?> <createOrder> <ACK>ERROR</ACK> <error_code>1001</error_code> <message>Shipping method 'P003' is unavailable for worldwide shipment.</message> </createOrder>
List of Codes and Details:
Error Code | Detail |
---|---|
1001 | Account name or password is invalid. Please make sure your are able to login with this account/password at page https://www.electricdistro.com/customer/account/login/. |
1002 | Your account is not approved to use API. |
1003 | "state" is invalid. |
1004 | The XML you send is invalid. |
1005 | Invalid country_id |
1006 | Invalid shippping method. |
1007 | No items data in your XML. |
1008 | Item SKU or QTY invalid. |
1009 | Reference number is not found. |
1010 | Your billing address is missing. Please set up default billing address on customer account page. |
1011 | Some filed value is missing. |
Appendix C: List of country ID and State/Region
The API only accept ISO Alpha-2 letters for country_id field in XML. You will get error code 1005 if post invalid country ID.
About state field, the API only accept 2 letters for country US and CA:
You may get error code 1003 if state value invalid.
Appendix D: Sample Code
Example PHP code:
Submit your XML to API url with the data encapsulated in the query parameter "xmldata".
<?php $url = "https://www.electricdistro.com/distribution/product/mainInfo"; $post_xml = '<?xml version="1.0" encoding="UTF-8"?> <checkItem> <account>[email protected]</account> <password>******</password> <skus> <sku>HH151</sku> <sku>HH152</sku> </skus> </checkItem>'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, "xmldata=".$post_xml); $data = curl_exec($ch); $info = curl_getinfo($ch); if ($data === false || $info['http_code'] != 200) { $data = "No cURL data returned for ".$url." [". $info['http_code']. "]"; if (curl_error($ch)) { $data .= "\n". curl_error($ch); } echo $data; exit(); }else{ header("Content-Type: text/xml; charset=utf-8"); echo $data; } curl_close($ch);