Doctypes join in rest api erpnext

hello!
i am new to frappe erpnext and i am shifting my admin panel to erpnext by api’s.
i want to join three doctypes on some condition to get data to save time by rest api php.
but i don’t found any help to get data by join.

any help will be appreciated.
Thanks

Hi @Arslan_dixeam,

One way to accomplish this is by writing a custom API.

  1. Write a SQL query (with joins) that produces the results you need.
  2. Create a new function in your App.
  3. Within your function, call the SQL query:
    result = frappe.db.sql(<your_query>)
    
  4. Transform your result as necessary. Then return the result.
  5. Make your function accessible by decorating it with @frappe.whitelist()

You can then call your function using the REST API.

GET https://yourdomain.com/api/method/path.to.your.function

See this documentation for more details:
https://frappeframework.com/docs/user/en/api/rest#remote-method-calls

1 Like

thanks @brian_pond . i am trying this way.