Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Advice with REST API

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-01-2017, 06:10 AM
  johngwms's Avatar 
johngwms johngwms is offline
 

Senior Member
  
Join Date: Mar 2013
Location: North Wales
Posts: 191
 

Default Advice with REST API

Hi

I am in the process of evaluating the implications of moving from XC 4.7.5 to XC 5.3.

I plan to use the REST API of XC5 for synchronisation of stock information and the export of new Sales Orders. Order processing will be carried out externally with Zoho Inventory (ZI), and the transfer of data to and from Zoho Inventory will be done using Zapier.

I need to know what is possible and if a Custom Module needs to be written.

Products
Many products will need attributes defined in XC5 and I would like to keep the master versions of these in ZI. The documentation for the REST API does not mention attributes. Does this mean that product attribute data cannot be transferred via the REST API?

Sales Orders
When a customer order is placed on XC5, how can the REST API be used to push the order to ZI? Will it be necessary for ZI to poll the REST API to check for a new order instead?

Access to Custom Module
Can the REST API be used to communicate with a Custom Module?

Any help or suggestions will be warmly received.
__________________
John Legg
www.TheDebugStore.com

5.4.1.18 Business, Crisp White Skin Template
Backorder-Preorder Module
X-Cart to Zoho Creator (in progress)
Zoho Creator <-> Zoho Inventory for order processing
NGINX hosted - XC virtual server
Reply With Quote
  #2  
Old 04-02-2017, 11:27 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Advice with REST API

Quote:
Originally Posted by johngwms
Products
Many products will need attributes defined in XC5 and I would like to keep the master versions of these in ZI. The documentation for the REST API does not mention attributes. Does this mean that product attribute data cannot be transferred via the REST API?

It is possible to retrieve product attributes, but not in a single REST API request.

First, you should get the product information:
https://[YOUR_STIE]/admin.php?target=RESTAPI&_key=[YOUR_KEY]&_path=product/[PRODUCT_ID]

Then you should iterate over product attributes and get information on every product attribute:
https://[YOUR_SITE]/admin.php?target=RESTAPI&_key=[YOUR_KEY]&_path=attribute/[ATTRIBUTE_ID]

Perhaps, you also should run other requests to get information on which attribute options the product has available.

You will end up with a lot requests per product, so it may make sense to customise the REST API module and add a custom API function that will return all the product's attributes in a single request.

Quote:
Originally Posted by johngwms
Sales Orders
When a customer order is placed on XC5, how can the REST API be used to push the order to ZI? Will it be necessary for ZI to poll the REST API to check for a new order instead?

REST API can be used for pull requests only. Yes, you should poll the API to check for new orders.

Quote:
Originally Posted by johngwms
Access to Custom Module
Can the REST API be used to communicate with a Custom Module?

REST API provides an interface to access the database from third-party applications. You can access database records and fields added by a custom module, but you can't communicate with the module's functions directly (all requests translate to methods defined in Model/Repo classes).
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 04-28-2017, 11:29 PM
 
Ashish Ashish is offline
 

Newbie
  
Join Date: Apr 2017
Posts: 6
 

Default Re: Advice with REST API

How can I modify REST API to get configurable product information?
I have created one order which has configurable product.
Now I want to read that product attributes. How can I read?
__________________
ashish

Xcart version :-X-Cart
Business 5.3.2.8
Reply With Quote
  #4  
Old 05-03-2017, 04:19 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Advice with REST API

REST API is an interface to manipulate data in the database through Repository classes.

So, first you should check the source code and understand what Models (subclasses of \XLite\Model\AEntity) you want to retrieve and how they relate to each other.
They you should run a series of API requests to retrieve the necessary models by their identifiers.
The exact list of requests depends on what exact information you require, so I'm not sure if I can guess it and post there.

When sending a search request, you may filter the data with the _cnd parameters. To find what parameters are available for your models look for prepareCnd***() methods defined in the Repository classes (subclasses of \XLite\Model\Repo\ARepo) that handle operations on models which you need.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #5  
Old 01-01-2019, 02:39 AM
 
fonefun fonefun is offline
 

Member
  
Join Date: May 2008
Posts: 10
 

Default Re: Advice with REST API

i already use rest api,

but im installing the Announce module now, and that requires a rest api key (read only)


when i go to the settings on rest api, it does not display any keys


i have 2 questions.

1. do i enter a key manually and match that in my announce login for it to work?

2. if i do the above will it break other connections that i use rest api for, like amazon and ebay. as i dont want to overwrite a working key with the one i enter to get announce working


im asking this as i cannot see anywhere on xcart 5 where any current keys are being used, and im not sure if i can simply add another without affecting existing keys

i hope this make sense

i hope this makes sense
__________________
4.1.11


www.fonefunshop.biz
Reply With Quote
  #6  
Old 01-05-2019, 11:39 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Advice with REST API

Quote:
Originally Posted by fonefun
i already use rest api,

but im installing the Announce module now, and that requires a rest api key (read only)


when i go to the settings on rest api, it does not display any keys


i have 2 questions.

1. do i enter a key manually and match that in my announce login for it to work?

2. if i do the above will it break other connections that i use rest api for, like amazon and ebay. as i dont want to overwrite a working key with the one i enter to get announce working


1. Yes, you specify your API keys manually, it can be anything you want, if otherwise is not stated in Announce's documentation.

2. I don't think eBay or Amazon use REST API to work with your store. Since you don't have any REST API key specified in the module settings, you are free to enter any key you want.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:23 PM.

   

 
X-Cart forums © 2001-2020