Learn to Set Rest API with Example in Magento 1


In this blog, Magento expert explains the very simple steps to RUN your Magento 1 REST API.

What is the REST API? To obtain it easy, REST API represents a set of functions to the developers that can perform requests and receive responses.

We assume that you already have created the new custom consumer and assign the role to it.
From that user, you will get the consumer key and consumer secret key which is useful on the REST API.

Planning for REST API

These steps are designed by Magento certified developer and it’s required utilizing REST API resources:

  1. Set up permissions for REST resource operations from the Magento Admin Panel.
  2. Configure the properties for different users types in Magento Admin Panel. Total 3 different types of users in accessing the data: Admin, Customer, and Guest. Admin is the backend logged in user, Customer is the fronted logged in user, and Guest is a non-logged in fronted user.

Planning REST API for the Third-Party Application

  1. Register the third-party application (Consumer) in Magento Admin Panel.
  2. The third-party application will utilize the provided consumer credentials to call the Magento store for getting the access token to access the data.

Using Rest API if you want to get all products, orders, customers, etc. data first you need to authorize Magento application or in other words, you need to get the access token of your Magento store.

Quick Tip:- How to Show All Categories on System Configuration Field?

To achieve those authentication endpoints you need to follow 3 steps:

Step 1: Magento initiate

Method: POST

URL: http://your-domain.com/oauth/initiate

(consumer key of user which you created via admin panel)


Step 2: Authorize

Method: POST

URL: http://your-domain.com/admin/oauth_authorize


To running the URL in the browser it opens the Magento admin panel.
You have to log in and then authorize the request.
Once authorized, note down the URL in the address bar:

Step 3: Final Permanent Token & Token Secret

Method: POST

URL: http://your-domain.com/oauth/token


consumer_key: 1cc517b6cb7594c7fc5d57a596**
consumer_secret: 2dfbb639db9d15bee86e47cf4**
oauth_token: 5aac4eac990cc680375f4a724**
oauth_token_secret: 0256cb206666e8bd7684d6da4**

The final permanent token and token secret to be used to access Magento Rest API Resources like products, orders, customers, etc.

The above-mentioned tokens are to be sent as Oauth1.0 Authorization Headers along Oauth_version as 1.0 and randomly generated nonce, timestamp, and oauth_signature.

Let’s see an example of getting products.

Method: GET

URL: http://your-domain.com/api/rest/products

content-type = application/json
Authorization = OAuth oauth_signature_method=”HMAC-SHA1″,
oauth_nonce = rltCs
oauth_timestamp = 1533556177
oauth_consumer_key = d27be60b6589a812171ff9e8e734fea2
oauth_token = 24471d629f7ce06ba527fc5f520b4
oauth_version = 1.0
oauth_signature = GB68762cd2348JFK61986sd

Note: nonce and timestamp are randomly generated unique values.

Return the list of all product data in JSON.

Magento CMS is not only a content management system, but also supporting the frontend multiple applications by managing on the same platforms, handling the customer information on e-commerce platforms, management of commodity litany, order dispensation and payment transactions handling all are the functions provided by it.

In addition to this, magneto provides CMS provides sturdy performance with continuous improvements in the software. With each release, requirements and customer satisfaction are integrated into the software.

It is a highly secured e-storage that supports many currencies, languages and different pricing structures. Upgrading to a new website through Magento is a simpler task as it handles various tasks automatically.

Detailed reporting and analytics are provided to the companies through a dashboard to take decisions by observing last year’s patterns. Marketing is an area where business spends a ton of money and magneto CMS offers various marketing and promotional tools such as landing page creation, poll creation, etc.

Mobile commerce is an emerging trend and magneto CMS is compatible with all the mobile devices and highly responsive on it. The low financial cost can be used to get extensive features of the CMS.

To generate random string in PHP, multiple predefined functions can be used from the library. Function str_shuffle($String) can be used to get a random alphanumeric string or random_bytes( $length) can be used.

Str_shuffle($string) is not a cryptographically secure string and the program produces different strings every time.

Below is the example of generating a random string:

This program may generate string 54rtydr4mf as an output.

Another PHP function, randombytes($length) is a cryptographically secure function. The length parameter of the function defines how long a string can be generated.

It is explained with an example:


echo bin2hex(random_bytes(15));
echo bin2hex(random_bytes(20));

The output of first-string could be ew34er2sy67u8se and the second one is also a random alphanumeric code.

One of the major operations which are performed on the database in update new entries or data into it. Mostly, programming languages use an update query to do this task and the same is applied to update query MySQL.

It includes the name of the columns or rows to be updated with where clause which defines a criterion to fetch and update the records. It can be done by using an object-oriented or procedural approach.

Let’s say the table name is Customer with fields name, address, house no and street number.

If the records where street number is 10, address needs to be updated then the below query needs to be executed.

UPDATE Customer SET address 14A WHERE streetnumber = ‘10’.

Many java developers face the issues of jQuery is not defined and unable to find the root cause of the same. These issues appear on the live system and there could be more than one reason behind it.

If the system is based on CDN hosted service, and if it is blocked by the proxies or a filter on the internet connection then java throws the above error.

Another case could be the CDN hosting is not working or taking too much loading time then the system throws an error after trying for 30 seconds maximum.

One of the solutions, which users can opt, is to install the jQuery with npm or another package manager, run the npm install query first then load the jQuery later to avoid the problem.

To track awb FedEx or aftership USPS, the official website provides a direct link for the customers or businesses. Single or multiple tracking numbers can be checked at a single time and notifications are also sent to the registered numbers once it moves from station to another.

These shipping websites offer reports and delivery confirmation for seamless movements and to become a trustworthy service. Real-time updates are provided about the packages and ensure zero damage to the products.

About the author

I’m Magento Certified Developer having quite 5 years of commercial development expertise in Magento as well as in Shopify. I’ve worked primarily with the Magento and Shopify e-commerce platform, managing the complexities concerned in building e-commerce solutions tailored to a client’s specific desires.

Related Posts

Leave a Reply