Frappe API Documentation

Hi All,

I was wondering is there any documentation for the Frappe API?
Where can I find the latest / current Frappe API documentation?

I want to get an understanding of the API / Functions that are provided by the Frappe Framework.

Thanks.

1 Like

Hi.

Have a look at the following as a starting point:

https://frappe.io/docs/user/en/guides/integration/rest_api

Thanks.

I have tried to find a comprehensive Frappe API documentation too, and I haven’t found anything but the link provided above, but that is a very basic starting point. Everything else I have no idea where do people get the information from. I guess they read the code, but not all of us have enough knowledge to do that.

1 Like

If you have idea about REST services it should be easy for you to grasp it. Each doctype in ERPNext has a REST api call for CRUD operations.

And about reading the code, it’s all about figuring out.

I understand, but I see in the forum questions about this that never get answered, and since we are here to ask questions and give answers, I thought it would be a good idea to have a more comprehensive documentation on the matter.

A couple of simple problems arise when you only have the docs mentioned, e.g, there are examples of single-worded doctypes, like Item, Customer, but what to do with Item Price, for example? Is it Item_Price, ItemPrice, Item-Price? This is something very basic that is not specified in the docs

I hope I can get the knowledge right in order to help others. That’s all

2 Likes

To explore the code is to discover conventions, perhaps this may help

frappe@ubuntu:~/frappe-bench$ find . -name '*.py' | xargs grep item_price
[snip]
./apps/erpnext/erpnext/stock/get_item_details.py:def insert_item_price(args):
./apps/erpnext/erpnext/stock/get_item_details.py:			item_price = frappe.get_doc({
./apps/erpnext/erpnext/stock/get_item_details.py:				item_price = frappe.get_doc('Item Price', name)
./apps/erpnext/erpnext/stock/get_item_details.py:				item_price.price_list_rate = price_list_rate
./apps/erpnext/erpnext/stock/get_item_details.py:				item_price.save()
./apps/erpnext/erpnext/stock/get_item_details.py:				item_price.insert()
frappe@ubuntu:~/frappe-bench$ bench mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 186615
Server version: 10.2.13-MariaDB-10.2.13+maria~xenial-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [d56cb677eaab3383]> desc `tabItem Price`;
+------------------+---------------+------+-----+----------+-------+
| Field            | Type          | Null | Key | Default  | Extra |
+------------------+---------------+------+-----+----------+-------+
| name             | varchar(140)  | NO   | PRI | NULL     |       |
| creation         | datetime(6)   | YES  |     | NULL     |       |
| modified         | datetime(6)   | YES  |     | NULL     |       |
| modified_by      | varchar(140)  | YES  |     | NULL     |       |
| owner            | varchar(140)  | YES  |     | NULL     |       |
| docstatus        | int(1)        | NO   |     | 0        |       |
| parent           | varchar(140)  | YES  | MUL | NULL     |       |
| parentfield      | varchar(140)  | YES  |     | NULL     |       |
| parenttype       | varchar(140)  | YES  |     | NULL     |       |
| idx              | int(8)        | NO   |     | 0        |       |
| price_list_rate  | decimal(18,6) | NO   |     | 0.000000 |       |
| selling          | int(1)        | NO   |     | 0        |       |
| item_name        | varchar(140)  | YES  |     | NULL     |       |
| _assign          | text          | YES  |     | NULL     |       |
| price_list       | varchar(140)  | YES  |     | NULL     |       |
| item_code        | varchar(140)  | YES  | MUL | NULL     |       |
| currency         | varchar(140)  | YES  |     | NULL     |       |
| _liked_by        | text          | YES  |     | NULL     |       |
| _comments        | text          | YES  |     | NULL     |       |
| buying           | int(1)        | NO   |     | 0        |       |
| _user_tags       | text          | YES  |     | NULL     |       |
| item_description | text          | YES  |     | NULL     |       |
+------------------+---------------+------+-----+----------+-------+
22 rows in set (0.00 sec)

I think @clarkej explained it very nicely about what to do with doctype with spaces. Besides document has clearly mentioned {doctype} at all places. Spaces should work.

And the best about open source documentation is that you contribute to what you discover. Contributing will not only improve your knowledge but also help others. So try these tweaks and if you feel you can contribute to it feel free to send a pull request for documentation. :+1:

1 Like

Thanks @clarkej.

I appreciate your guidance. Sometimes one doesn’t know where to start :slight_smile:

1 Like

@abbas Thanks for the Info, but what I am looking for is actually the Frappe API (fuctions or methods) or maybe the Frappe Database API. For example:

  • frappe.db.count(‘User’)
  • frappe.db.sql(“select * from tabUser”, as_dict=True)
  • frappe.get_doc(‘Timesheet’, data.time_sheet)
  • frappe.sendmail(recipients=email_address, subject=“Subject of the email”, message= “Content of the email”)

Something like those methods where there is a documentation on explanation of each function provided by Frappe (like input parameters, output result, what is the use of the function, where to find all those functions, etc.)

This will be very helpful in development process.

1 Like

There used to be one earlier which I think has been moved.

This one is a squized version which might help you:

@joshiparthin so the complete version of the Frappe API Reference for server side dan client side no longer exists?

What happened to the reference API documentation?
Maybe the owners of the Frappe Technologies can provide some insights.

Yes that went away a version or two ago, my guess perhaps a technical debt maintenance bottleneck?

For documentation not to forget their is always the actual code -

For eg frappe.get_doc(‘Timesheet’, data.time_sheet) is implemented here

https://github.com/frappe/frappe/blob/develop/frappe/\_\_init\_\_.py#L707

The code for frappe.db.sql(“select * from tabUser”, as_dict=True) lives here I figure

And thanks joshiparthin that cheatsheet is new to me…

3 Likes

Ok. Thanks for the info.
I guess I have to go through the code one by one to understand it.

1 Like

I try to document my findings here: ERPNext Custom DocTypes, Actions, and Links | About Lovia

I hope it’s useful to you.

1 Like