How to call RESTAPI in ERPNext?

At some point during the implementation, you may need to integrated some sort of 3rd party tool in your version of ERPNext. Fear not because they have it available, as they say \”Batteries Included\”.

For this article, I would be using Postman for calling their APIs. Like every normal APIs, we have GET, POST, PUT and the others. For this article, I would be demonstrating GET.

Creating a User

First of all, we need to create a token for Authorization of our API calls. I would prefer creating a dedicated user with the specific permissions on some documents. Let\’s call it our Store User API. On entering the data, save it.


Generating API Key

Once the user is created, we would scroll down to get the API access key. Once you click the Generate Keys button, copy the key as it would not appear twice.


You might have to refresh the page to see the API key.



Well, there you have the keys to authorize your API calls. Now in Postman, we would make a new Request. In the headers of the Request, we would add Authorization with value is token <APIKEY>:<SECRET>. Our URL would be our main domain appended by api/resource/<doctype>. Just like shown below:


You can press the Send button to see the result. The result may show similar to this:


The result would be an array as we are requesting all of the Items. If we would like to fetch one item, we would be creating the URL as as the last part is the name, which is the unique identification of the Item. The result would appear as:


Search and Filter

Sometimes, we would like to attempt a search on the items and for that we would format our URL as[[\"field1\", \"=\", \"value1\"], [\"field2\", \">\", \"value2\"]] where the fields will be mentioned and the filters that are applied. For searching with a keyword, you may format the URL as[[\"field1\", \"LIKE\", \"%value1%\"]] with the % character as a wildcard character.


But this search is resulting the identification field only. For showing the other fields as well, we would reformat the URL as:[[\"name\", \"LIKE\", \"%L%\"]]&fields=[\"name\", \"item_code\", \"item_name\", \"item_group\"] and the result should be:



If you are filtering from thousands of records, you can apply Pagination by reformatting the URL as:[[\"name\", \"LIKE\", \"%L%\"]]&fields=[\"name\", \"item_code\", \"item_name\", \"item_group\"]&limit_start=1&limit_page_length=1. We are using limit_start and limit_page_length as our parameters for pagination here.

The above example applies for other DocTypes as well. The only difference is if a DocType\’s name is two words, for example Material Request then the URL would like like api/resource/Material Request by just adding a space between the words.

This article is referred from Frappe Framework.

Thank you. If you have any questions or comments, feel free to ask.






3 responses to “How to call RESTAPI in ERPNext?”

  1. […] For ERPNext REST API calls please click here. […]

  2. Surabhi Avatar

    Hello sir,
    Can you please guide how can we upload single and multiple images ?

  3. Azhar UmarAzhar Umar Avatar

    Thank you. Was a helpful article.

Leave a Reply

Your email address will not be published. Required fields are marked *