3

I am new to Magento and learing it. I am working on a Magento store and I have been successful in creating store with required features. But now i was asked to create an REST API for mobile application for accessing product and all required data. I have had experience creating API in CodeIgniter, but don't know how to do it in Magento. SO what would be the steps or is there any good tutorial for it.

Thanks in advance.

4

Magento 1.7 already comes with a REST API. Check system->web services-> REST * admin menu to see if it fits your needs.
Also check this for documentation

  • Thanks for your reply but can you guide me like how can i configure REST API if i want to give all customer and products data to mobile app. – Maulik Goswami Jul 10 '13 at 8:52
  • Unfortunately I cannot. My experience with the Magento REST API is really close to zero. You can use the examples from the link I posted. Maybe it will guide you on the right path. – Marius Jul 10 '13 at 9:06
2

The sort of simple REST API you're after (as opposed to Magento more robust oAuth) API can be implemented very similarly to what you'd do in Code Igniter.

Since "How to implement an API" is a big question, the basic steps I'd take are

  1. Create a new Magento Module

  2. Create a controller for your module

  3. Add logic in this controller to query the objects you'd like and build JSON or XML response objects.

If you google around on those topic you'll start to find the tutorials you're looking for. If you get stuck you can always come back and ask a new question.

  • Ok i'll surely do that, thanks for your guidance. – Maulik Goswami Aug 7 '13 at 10:46
2

If you have an option regarding the type of API that you have to create, I would not recommend REST. Magento's default REST API is not feature complete. If you want to extend it, you'll have to create your own extension (with custom controllers).

You can have a look at Magento's SOAP API (http://www.magentocommerce.com/api/soap/create_your_own_api.html).

However, all the above may require a lot of work from your end. You may want to have a look at MobStac (http://developer.mobstac.com/). We have an iOS SDK and a Magento plugin that abstract a lot of "missing" functions in Magento's API.

2

As Alan Storm mentioned, it is a very vast question but for magento you can do it several ways.

1) Create a magento module, and create controllers for each part of the API. For example, create controllers for catalog, customers, orders etc etc. Then call the appropriate objects and methods in those controllers.

2) The other way is not that good but i used it to fetch products from magento for an other website and is working perfectly. You will need to create a controller and handle all the API logic in that controller. Now, instead of creating controllers for each part, you will create helper classes for each part. During calling api, you have to pass class name and method name. In your API controller logic, you have to fetch that class and methods and check for its availability, load the class if available and call the method if in that helper class.

Hope this will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.