Fetch Doctype List included childtable by rest API

Hi everyone, I wonder to fetch list of doctype including their childtable using REST API, is that possible ?
I found core frappe function to retrieves doctype list with childtable, but cors-origin occurs, the method is api/method/frappe.desk.reportview.get?doctype=...but working properly with postman.

Thanks in advance for each suggestions,
cc: @rmeyer

Hi,

Child table rows are stored in a separate table. To fetch them, you need to know the name of the Database table. You can find the DocType name via customize form. Search for the Table field and check the “Options”.

For example, let’s get the UOMs and conversion details of an Item. The child table DocType is called UOM Conversion Detail. To get the database table name, just prepend “tab”: "tabUOM Conversion Detail". Now we can construct our query like this:

GET /api/resource/Item?fields=["name","`tabUOM Conversion Detail`.uom","`tabUOM Conversion Detail`.conversion_factor"]
5 Likes

Wow! That is awesome! For the past year I’ve been using ERPNext, I’ve been loading the whole resource just to get some data in a child table.

Thank you very much, you save my day, this is awesome !!!

I tried implementing your code on my end but its output is quite different from what i was expecting.

The present output forces a duplicate record with the childtable field specified in each of the duplicate as seen in the picture bellow.

What i was expecting is the value of the childTable to be added to each record as an array.

The way i do it now is to

  • First Load all records using get_list from one end point
  • Then hit another endpoint with the needed docname to get the childTable record

So i am looking for how i would get this two records in one Endpoint JSON output

I humbly await your response.

I don’t know how to achieve what you want.