Get information of doctype which in relation of another doctype in api

How can I (for example) get the information of order with the customer who is in relation to the order in API:
I want the response of API something like:
order: {
name: ‘ORDER-12’,
date: ‘2020-12-01’,
order_type: ‘sales’,

customer: {
name: ‘Ali’,
phone: ‘01215454xxxx’,
country: ‘Egypt’
email: ‘’

Is any way to can response the API like this or I need to create custom API for me for this.
If I need to create custom API for me, how can I do this?

You can use get_all with filters to filter out all orders of a particular customer, any customer could have multiple orders so you would get an array of order. You could also get a specific order by using more filters.

Once you get your order by the customer you could use get_doc or get_value with required fields to get the details of the order. Using customer you could get customer details from Customer in the same way.

I would suggest you read through documentation.