The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.
 
 
Thread Tools Display Modes
  #1  
Old 04-07-2011, 05:15 PM
info720's Avatar
info720 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 5
Default

API Questions


Hi, I searched the forum for "API", but that search does not return any results... So I'm sorry for raising questions that might have been responded before. I plan on signing up for a Silver account, mainly because of the API.

But before I do, I have some questions about it:

-Will I be able to code some caching - so that I do not need to access the API to show categories/products? Has this been done before? Or does every page needs to connect to the API directly in orde to show data?

-Will I be able to code an import/export feature for products? Can I edit/add/delete categories/products via the API?

-Does the API change from one version of Ecwid to the other? Will my code ever break with a new release?

Can I add some more

-Does the API support all things you can do with the Ecwid control panel, or does it only cover a subset (viewing mainly) of its features?

Thx, Pieter

Last edited by info720; 04-07-2011 at 05:23 PM.
  #2  
Old 04-07-2011, 05:42 PM
Eugene Rimmer's Avatar
Eugene Rimmer Eugene Rimmer is offline
Senior Member
 
Join Date: Jan 2011
Location: Ecwid headquarters
Posts: 7,765
Default

Our search is available in the top right of every site page and returns quite useable results on the 'API' query.

The Product API is described here: http://kb.ecwid.com/Product-API , there are also other APIs in making.

The Product API allows you to read the inventory in your store. Hence you can do the export of your products or categories. The import of information into Ecwid is only possible currently via our import interface in the Ecwid control panel manually, but you may use Product API in your custom scripts to prepare the CSV files for such import. Editing the store inventory through API will be implemented in one of our future releases. Right now the Product API is read-only.

Caching is highly recommended for the cases when you retrieve the same information over and over again (like listing the products on your site for your visitors in your own custom format). The exact strategy of caching depends on what technologies you have at hand and what exactly you are trying to do, varying from saving the results into plain text files to maintaining your own database to storing things in a memcached storage and so on.

Product API will certainly be improved over time. However, we do our best to release every update for Ecwid in backward-compatible way that doesn't break anything. The Product API from its current state may only be added to, but not changed in its existing part. So, as the new abilities will appear in the Product API, your existing scripts relying on what was already possible will still continue to work.

And even if any issues arise, we are always here to help you overcome it.
  #3  
Old 04-07-2011, 05:49 PM
info720's Avatar
info720 info720 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 5
Default

Thx for the quick reply. I used the search facility on the forum toolbar rather than the one at the top-right. Thanks for clarifying that.

Thanks for the clear answers. I would use the classic ASP application object, or just a database for caching purposes.

I will try the 1003 shop to see what I can come up with. I'll report back over here.

thx again, Pieter
  #4  
Old 04-07-2011, 09:23 PM
info720's Avatar
info720 info720 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 5
Default

Just tried out one the urls from the API for shop 1003. Why did you not use XML to export data? All major web technologies have adopted XML ages ago. Why reinvent the wheel?
  #5  
Old 04-08-2011, 09:08 AM
info720's Avatar
info720 info720 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 5
Default

This is what I did so far: http://www.ecwid.quickersite.com

It took this (rather clunky) ASP script (xml would have been easier):

################################################## #######

dim shopid
shopid=1003

Set objHTTP = server.CreateObject("WinHttp.WinHttpRequest.5.1")

objHTTP.Open "GET", "http://app.ecwid.com/api/v1/1003/categories", False
objHTTP.Send

dim prep
prep=objHTTP.responseText
prep=replace(prep,"[","",1,-1,1)
prep=replace(prep,"]","",1,-1,1)

dim fields
set fields=server.createobject("scripting.dictionary")
fields.add "id",""
fields.add "thumbnailUrl",""
fields.add "name",""
fields.add "url",""

dim catArr
catArr=split(prep,"{")

for c=lbound(catArr) to ubound(catArr)
catline=catArr(c)
catline=replace(catline,"}","",1,-1,1)
response.write "<ul>"
'list all fields
for each field in fields
startpos=instr(catline,"""" & field & """:")
if startpos>0 then
endpos=instr(startpos,catline,",")
if endpos=0 then endpos=len(prep)
response.write "<li>" & field & ": " & mid(catline,startpos+len(field)+3,endpos-startpos-len(field)-3) & "</li>"
end if
next
response.write "</ul><hr />"
next

Set objHTTP = Nothing
################################################## ######""

I have some more questions after this first attempt:
-what if there are double quotes, "[]" or "{}" in category names? that would break my script

-why do you not put the category ID between double quotes. This type of inconsistenties make an API useless (imho). Worst thing: i guess you cannot change that anymore, since quite a few users have worked around this inconsistency...

I continue my efforts now... I'll be back
  #6  
Old 04-08-2011, 11:14 AM
Eugene Rimmer's Avatar
Eugene Rimmer Eugene Rimmer is offline
Senior Member
 
Join Date: Jan 2011
Location: Ecwid headquarters
Posts: 7,765
Default

It's JSON there, and JSON is the new XML - it is still a plain text, it is less syntactically bloated, and it maps 1:1 to a programming data structure without questions on how to interpret the text of reply.

JSON was adopted by majority of programming languages, so there's practically no problem parsing it in any language.

Eventually, for a programmer the only thing that really matters is how something is represented in memory, not the way how it is being stored in the transition. You don't need to create a schema or transformation for the API reply - you just parse the JSON that came out and snap, it's in memory as a data structure of your language!

So we believe JSON is quite enough for now. For ASP there are already a couple of solutions to parse JSON: http://code.google.com/p/aspjson/ and a guide at http://www.webdevbros.net/2007/04/26...asp-datatypes/
  #7  
Old 04-08-2011, 08:18 PM
info720's Avatar
info720 info720 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 5
Default

Eugene, thx for that. I need to do my homework better. Working on it now. I'll report back when I have "something".
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:57 AM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.