Recently I have created a eshop website using prestashop
https://www.prestashop.com/en/
And since I am going to build the android app for it. What includes in apps are only some basic function
e.g. create customer account / list product / order product / pay / view order etc..common eshop functions...
The problem is it seems there are few resources around. Is there any library already there/ offical one / or I need to start create the API from stratch?
read http://doc.prestashop.com/display/PS16/Developer+Guide for a while but no clue what I need to start with so far.
This is quite abstract problem but since the community is not so popular and the resource is limit I hope this can learn from the other's experience and help any others with the same request.
Thanks a lot for helping
The problem is it seems there are few resources around. Is there any library already there/ offical one / or I need to start create the API from stratch?
In contrast to one of the comments on your question, Prestashop does actually offer a REST service. In the documentation is it referred to by "web service".
Quick links:
There are a few open source API implementations available, but none specifically for Android/Java. You may find them useful as a guideline though.
A few things to take note of:
The web service feature appears to be disabled by default. So in order to use it, you'll have to enable it first in the back-office. Copied from the docs:
Enabling the webservice feature
Go in the PrestaShop back-office, open the "Webservice" page under the "Advanced Parameters" menu, and then choose "Yes" for the "Enable PrestaShop's webservice". Save your change: you're done!
Communicating with the web service requires an API key. You'll have to generate one for your Android app, again using the back-office:
Creating an access key
Open the "Webservice" page under the "Advanced Parameters" menu, and then click the "Add New" button to access the account configuration section. A long form appears:
- Key. The API key serves as the main identifier for the webservice account you are creating. Click the "Generate" button to get an unique authentication key. You can also create your own (which must be 32 characters long), but using a generated key prevents wrong-doers from guessing your key too easily. Using this key, you and other selected users will be able to access the webservice.
Key description. Helps you remember who you created that key for, what are the access rights assigned to it, etc. The description is not public, but make sure to put all the keywords pertaining to the user, so that you can find their key more quickly.
Status. You can disable any key at any time.
- Permissions. This section is very important, as it enables you to assign rights for each resource you want to make available to this key. Indeed, you might want a user to have read and write access on some resources, but only read access on others – and no access to the more important ones. In the list of permissions, the checkbox most on the left enables you to define all the rights for a given resource. Likewise, the checkbox at the top of each column enables you to give the select right (View, Modify, etc.) to all the resources. Make sure to only select the rights needed for the usage of that key. Do not give all the rights for all resources to any key, keep that to yours and yours only. Shop association. This only appears in multistore mode. It enables you to choose which of your stores the key owner should have access to.
If you choose to use a custom passkey instead of a generated one, make sure it is very secure and that its rights are limited – and that it is 32characters long!
Finally, to get an overview of the API methods:
Accessing the webservice from the browser
The endpoint to your store's webservice is located in the
/api/
folder at the root of your installation of Prestashop:
- If PrestaShop is installed at the root of your server, you can access the API here: http://example.com/api/
- If PrestaShop is installed in a subfolder of your server, you can access the API here: http://example.com/prestashop/api/
To access it, you need to provide your API key when request. There is no password, providing your API key is enough – and therefore the key should be kept secret by the user! You can either type the API endpoint address directly then enter your API key, or indicate your API key in the address. Here is an example, with
UCCLLQ9N2ARSHWCXLT74KUKSSK34BFKX
being the API key.
- At the root of the server: http://[email protected]/api/
- In a subfolder of the server: http://[email protected]/prestasshop/api/
You can test this with any browser that supports XML. If no permission has been set for the key, then the browser will keep asking you to enter the key indefinitely.
The result should look somewhat like this (for version 1.5.4.1 of PrestaShop):
<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<api shop_name="MYSHOP">
<addresses>...</addresses>
<carriers>...</carriers>
<cart_rules>...</cart_rules>
<carts>...</carts>
<categories>...</categories>
<combinations>...</combinations>
<configurations>...</configurations>
<contacts>...</contacts>
<content_management_system>...</content_management_system>
<countries>...</countries>
<currencies>...</currencies>
<customer_messages>...</customer_messages>
<customer_threads>...</customer_threads>
<customers>...</customers>
<deliveries>...</deliveries>
<employees>...</employees>
<groups>...</groups>
<guests>...</guests>
<image_types>...</image_types>
<images>...</images>
<languages>...</languages>
<manufacturers>...</manufacturers>
<order_carriers>...</order_carriers>
<order_details>...</order_details>
<order_discounts>...</order_discounts>
<order_histories>...</order_histories>
<order_invoices>...</order_invoices>
<order_payments>...</order_payments>
<order_states>...</order_states>
<orders>...</orders>
<price_ranges>...</price_ranges>
<product_feature_values>...</product_feature_values>
<product_features>...</product_features>
<product_option_values>...</product_option_values>
<product_options>...</product_options>
<product_suppliers>...</product_suppliers>
<products>...</products>
<search >...</search>
<shop_groups>...</shop_groups>
<shops>...</shops>
<specific_price_rules>...</specific_price_rules>
<specific_prices>...</specific_prices>
<states>...</states>
<stock_availables>...</stock_availables>
<stock_movement_reasons>...</stock_movement_reasons>
<stock_movements>...</stock_movements>
<stocks>...</stocks>
<stores>...</stores>
<suppliers>...</suppliers>
<supply_order_details>...</supply_order_details>
<supply_order_histories>...</supply_order_histories>
<supply_order_receipt_histories>...</supply_order_receipt_histories>
<supply_order_states>...</supply_order_states>
<supply_orders>...</supply_orders>
<tags>...</tags>
<tax_rule_groups>...</tax_rule_groups>
<tax_rules>...</tax_rules>
<taxes>...</taxes>
<translated_configurations>...</translated_configurations>
<warehouse_product_locations>...</warehouse_product_locations>
<warehouses>...</warehouses>
<weight_ranges>...</weight_ranges>
<zones>...</zones>
</api>
<api shop_name="MYOTHERSHOP">...</api>
<api shop_name="YETANOTHERSHOP">...</api>
</prestashop>
Since you mention you're mainly interested in supporting basic/core functionality in the Android app, I'm inclined to say this probably fits your needs. :)
If you're not looking for a native app, you may want to try a responsive mobile template addon or paid themes. If you need a native app and would like to reuse APIs from your prestashop store, you will have to create an access to Prestashop REST webservices
To test if you have properly configured your access to the web service, go to the page http://[email protected]/api/, where "mypasskey" is replaced by your key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With