Get Customer Detail Using Email ID in Magento 2 REST API

When we make a mobile application, then we need many types of API at that time. In order to develop a mobile application, there is a Magento 2 Customer Detail REST API named order detail generation using email.

Whatever product is ordered on the magento2 eCommerce platform, if you want to extract that product order details using email id, then you can use the rest API given below.

If we want to get customer order details through email id, then you can easily get the detail via email id rest API.

Under the order details, all the payment details will be shown and the status of the order will show how many products you have ordered so far.

What is the status of your every order i.e. if ever your status has been successful then it will appear as successful and if your order was pending or you have canceled your order then that order will also show you in the response?

 

Get Order Detail REST API Magento 2

There are two ways to get the Magento 2 customer order details via rest API while developing the mobile application.

  • Get customer order detail via Email ID
  • Get customer detail via Order ID

Here, We will try to get the order details in both ways and check both the APIs alternately on postman.com to see what response we are getting.

 

Magento 2 Get Customer Detail REST API Via Email ID

As you can see in the response below I have entered the customer email parameter id inside of REST API Prams and all the products ordered from this email id are easily visible in the response.

Total count is also showing via using this resp API, Payment information is also visible by whom the payment has been made and billing address shipping address is also visible.

You can also get the method used while ordering the product using order detail rest api.

Endpoint:

http://wishusucess.com/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=customer_email&searchCriteria[filter_groups][0][filters][0][value]=cs.hemantsingh@gmail.com

Method: GET

Header:

  • Authorization: bearer <admin_token>
  • content-type: application/json

Body:

Not Required

Customer Detail Using Email ID in Magento 2

 

Response:

{
"items": [
{
"base_currency_code": "USD",
"base_discount_amount": 0,
"base_discount_invoiced": 0,
"base_grand_total": 200,
"base_discount_tax_compensation_amount": 0,
"base_discount_tax_compensation_invoiced": 0,
"base_shipping_amount": 0,
"base_shipping_discount_amount": 0,
"base_shipping_discount_tax_compensation_amnt": 0,
"base_shipping_incl_tax": 0,
"base_shipping_invoiced": 0,
"base_shipping_tax_amount": 0,
"base_subtotal": 200,
"base_subtotal_incl_tax": 200,
"base_subtotal_invoiced": 200,
"base_tax_amount": 0,
"base_tax_invoiced": 0,
"base_total_due": 0,
"base_total_invoiced": 200,
"base_total_invoiced_cost": 0,
"base_total_paid": 200,
"base_to_global_rate": 1,
"base_to_order_rate": 1,
"billing_address_id": 198,
"created_at": "2022-01-13 06:46:19",
"customer_email": "cs.hemantsingh@gmail.com",
"customer_group_id": 0,
"customer_is_guest": 1,
"customer_note_notify": 1,
"discount_amount": 0,
"discount_invoiced": 0,
"email_sent": 1,
"entity_id": 99,
"global_currency_code": "USD",
"grand_total": 200,
"discount_tax_compensation_amount": 0,
"discount_tax_compensation_invoiced": 0,
"increment_id": "000000138",
"is_virtual": 0,
"order_currency_code": "USD",
"protect_code": "a04608837596c6736a143b98497134a1",
"quote_id": 1110,
"remote_ip": "14.102.51.229",
"shipping_amount": 0,
"shipping_description": "By DEN - By DEN",
"shipping_discount_amount": 0,
"shipping_discount_tax_compensation_amount": 0,
"shipping_incl_tax": 0,
"shipping_invoiced": 0,
"shipping_tax_amount": 0,
"state": "processing",
"status": "processing",
"store_currency_code": "USD",
"store_id": 1,
"store_name": "Main Website\nMain Website Store\nDefault Store View",
"store_to_base_rate": 0,
"store_to_order_rate": 0,
"subtotal": 200,
"subtotal_incl_tax": 200,
"subtotal_invoiced": 200,
"tax_amount": 0,
"tax_invoiced": 0,
"total_due": 0,
"total_invoiced": 200,
"total_item_count": 1,
"total_paid": 200,
"total_qty_ordered": 2,
"updated_at": "2022-01-13 06:47:13",
"weight": 200,
"x_forwarded_for": "14.102.51.229",
"items": [
{
"amount_refunded": 0,
"base_amount_refunded": 0,
"base_discount_amount": 0,
"base_discount_invoiced": 0,
"base_discount_tax_compensation_amount": 0,
"base_discount_tax_compensation_invoiced": 0,
"base_original_price": 100,
"base_price": 100,
"base_price_incl_tax": 100,
"base_row_invoiced": 200,
"base_row_total": 200,
"base_row_total_incl_tax": 200,
"base_tax_amount": 0,
"base_tax_invoiced": 0,
"created_at": "2022-01-13 06:46:19",
"discount_amount": 0,
"discount_invoiced": 0,
"discount_percent": 0,
"free_shipping": 0,
"discount_tax_compensation_amount": 0,
"discount_tax_compensation_invoiced": 0,
"is_qty_decimal": 0,
"is_virtual": 0,
"item_id": 144,
"name": "Accessories monogram D",
"no_discount": 0,
"order_id": 99,
"original_price": 100,
"price": 100,
"price_incl_tax": 100,
"product_id": 17,
"product_type": "simple",
"qty_canceled": 0,
"qty_invoiced": 2,
"qty_ordered": 2,
"qty_refunded": 0,
"qty_shipped": 0,
"quote_item_id": 568,
"row_invoiced": 200,
"row_total": 200,
"row_total_incl_tax": 200,
"row_weight": 200,
"sku": "Accessories monogram D",
"store_id": 1,
"tax_amount": 0,
"tax_invoiced": 0,
"tax_percent": 0,
"updated_at": "2022-01-13 06:46:19",
"weee_tax_applied": "[]",
"weight": 100
}
],
"billing_address": {
"address_type": "billing",
"city": "Noida",
"country_id": "IN",
"email": "cs.hemantsingh@gmail.com",
"entity_id": 198,
"firstname": "Hemant",
"lastname": "Singh",
"parent_id": 99,
"postcode": "95070",
"region": "Uttar Pradesh",
"region_code": "UP",
"region_id": 566,
"street": [
"New test"
],
"telephone": null
},
"payment": {
"account_status": null,
"additional_information": [
"0",
"1",
"",
"TUZYUGM3ERY3Q",
"cs.hemantsingh@gmail.com",
"unverified",
"confirmed",
"133ea25fc4520",
"TUZYUGM3ERY3Q",
"EC-98T36492VK521913U",
"PayPal Express Checkout",
null,
"Eligible",
"completed",
"None"
],
"amount_authorized": 200,
"amount_ordered": 200,
"amount_paid": 200,
"base_amount_authorized": 200,
"base_amount_ordered": 200,
"base_amount_paid": 200,
"base_amount_paid_online": 200,
"base_shipping_amount": 0,
"base_shipping_captured": 0,
"cc_exp_year": "0",
"cc_last4": null,
"cc_ss_start_month": "0",
"cc_ss_start_year": "0",
"entity_id": 99,
"last_trans_id": "9LN125666F286773U",
"method": "paypal_express",
"parent_id": 99,
"shipping_amount": 0,
"shipping_captured": 0
},
"status_histories": [
{
"comment": "IPN \"Completed\" Registered notification about captured amount of $200.00. Transaction ID: \"<a target=\"_blank\" href=\"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=9LN125666F286773U\">9LN125666F286773U</a>\"",
"created_at": "2022-01-13 06:46:37",
"entity_id": 44,
"entity_name": "order",
"is_customer_notified": null,
"is_visible_on_front": 0,
"parent_id": 99,
"status": "processing"
},
{
"comment": "Captured amount of $200.00 online. Transaction ID: \"<a target=\"_blank\" href=\"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=9LN125666F286773U\">9LN125666F286773U</a>\"",
"created_at": "2022-01-13 06:46:19",
"entity_id": 43,
"entity_name": "invoice",
"is_customer_notified": null,
"is_visible_on_front": 0,
"parent_id": 99,
"status": "processing"
}
],
"extension_attributes": {
"shipping_assignments": [
{
"shipping": {
"address": {
"address_type": "shipping",
"city": "Noida",
"country_id": "IN",
"email": "cs.hemantsingh@gmail.com",
"entity_id": 197,
"firstname": "Hemant",
"lastname": "Singh",
"parent_id": 99,
"postcode": "302021",
"region": "Uttar Pradesh",
"region_code": "UP",
"region_id": 566,
"street": [
"New test"
],
"telephone": null
},
"method": "flatrate_flatrate",
"total": {
"base_shipping_amount": 0,
"base_shipping_discount_amount": 0,
"base_shipping_discount_tax_compensation_amnt": 0,
"base_shipping_incl_tax": 0,
"base_shipping_invoiced": 0,
"base_shipping_tax_amount": 0,
"shipping_amount": 0,
"shipping_discount_amount": 0,
"shipping_discount_tax_compensation_amount": 0,
"shipping_incl_tax": 0,
"shipping_invoiced": 0,
"shipping_tax_amount": 0
}
},
"items": [
{
"amount_refunded": 0,
"base_amount_refunded": 0,
"base_discount_amount": 0,
"base_discount_invoiced": 0,
"base_discount_tax_compensation_amount": 0,
"base_discount_tax_compensation_invoiced": 0,
"base_original_price": 100,
"base_price": 100,
"base_price_incl_tax": 100,
"base_row_invoiced": 200,
"base_row_total": 200,
"base_row_total_incl_tax": 200,
"base_tax_amount": 0,
"base_tax_invoiced": 0,
"created_at": "2022-01-13 06:46:19",
"discount_amount": 0,
"discount_invoiced": 0,
"discount_percent": 0,
"free_shipping": 0,
"discount_tax_compensation_amount": 0,
"discount_tax_compensation_invoiced": 0,
"is_qty_decimal": 0,
"is_virtual": 0,
"item_id": 144,
"name": "Accessories monogram D",
"no_discount": 0,
"order_id": 99,
"original_price": 100,
"price": 100,
"price_incl_tax": 100,
"product_id": 17,
"product_type": "simple",
"qty_canceled": 0,
"qty_invoiced": 2,
"qty_ordered": 2,
"qty_refunded": 0,
"qty_shipped": 0,
"quote_item_id": 568,
"row_invoiced": 200,
"row_total": 200,
"row_total_incl_tax": 200,
"row_weight": 200,
"sku": "Accessories monogram D",
"store_id": 1,
"tax_amount": 0,
"tax_invoiced": 0,
"tax_percent": 0,
"updated_at": "2022-01-13 06:46:19",
"weee_tax_applied": "[]",
"weight": 100
}
]
}
],
"payment_additional_info": [
{
"key": "paypal_express_checkout_shipping_overridden",
"value": "0"
},
{
"key": "button",
"value": "1"
},
{
"key": "paypal_express_checkout_shipping_method",
"value": ""
},
{
"key": "paypal_payer_id",
"value": "TUZYUGM3ERY3Q"
},
{
"key": "paypal_payer_email",
"value": "cs.hemantsingh@gmail.com"
},
{
"key": "paypal_payer_status",
"value": "unverified"
},
{
"key": "paypal_address_status",
"value": "confirmed"
},
{
"key": "paypal_correlation_id",
"value": "133ea25fc4520"
},
{
"key": "paypal_express_checkout_payer_id",
"value": "TUZYUGM3ERY3Q"
},
{
"key": "paypal_express_checkout_token",
"value": "EC-98T36492VK521913U"
},
{
"key": "method_title",
"value": "PayPal Express Checkout"
},
{
"key": "paypal_express_checkout_redirect_required",
"value": "null"
},
{
"key": "paypal_protection_eligibility",
"value": "Eligible"
},
{
"key": "paypal_payment_status",
"value": "completed"
},
{
"key": "paypal_pending_reason",
"value": "None"
}
],
"applied_taxes": [],
"item_applied_taxes": []
}
}
],
"search_criteria": {
"filter_groups": [
{
"filters": [
{
"field": "customer_email",
"value": "cs.hemantsingh@gmail.com",
"condition_type": "eq"
}
]
}
]
},
"total_count": 1
}

 

 

View Order By Order Id via Magento 2 REST API

Magento 2 provides a REST API to get the order detail like payment information, payment status, payment method, shipping address, billing address, etc. using order id.

If order detail information is to be retrieved on the basis of order id, then we will use order view via order id API for that.

Lastly, we will enter the order id and hit the API, then we will get all the details of the order as our response

Endpoint:

http://wishusucess.com/rest/V1/orders/99

Method: GET

  • Authorization: Bearer admin_token
  • Content-Type: application/json

Body:

Not required

Customer Detail REST API

Response:

{
"base_currency_code": "USD",
"base_discount_amount": 0,
"base_discount_invoiced": 0,
"base_grand_total": 200,
"base_discount_tax_compensation_amount": 0,
"base_discount_tax_compensation_invoiced": 0,
"base_shipping_amount": 0,
"base_shipping_discount_amount": 0,
"base_shipping_discount_tax_compensation_amnt": 0,
"base_shipping_incl_tax": 0,
"base_shipping_invoiced": 0,
"base_shipping_tax_amount": 0,
"base_subtotal": 200,
"base_subtotal_incl_tax": 200,
"base_subtotal_invoiced": 200,
"base_tax_amount": 0,
"base_tax_invoiced": 0,
"base_total_due": 0,
"base_total_invoiced": 200,
"base_total_invoiced_cost": 0,
"base_total_paid": 200,
"base_to_global_rate": 1,
"base_to_order_rate": 1,
"billing_address_id": 198,
"created_at": "2022-01-13 06:46:19",
"customer_email": "test456@tech9logy.in",
"customer_group_id": 0,
"customer_is_guest": 1,
"customer_note_notify": 1,
"discount_amount": 0,
"discount_invoiced": 0,
"email_sent": 1,
"entity_id": 99,
"global_currency_code": "USD",
"grand_total": 200,
"discount_tax_compensation_amount": 0,
"discount_tax_compensation_invoiced": 0,
"increment_id": "000000138",
"is_virtual": 0,
"order_currency_code": "USD",
"protect_code": "a04608837596c6736a143b98497134a1",
"quote_id": 1110,
"remote_ip": "14.102.51.229",
"shipping_amount": 0,
"shipping_description": "By DEN - By DEN",
"shipping_discount_amount": 0,
"shipping_discount_tax_compensation_amount": 0,
"shipping_incl_tax": 0,
"shipping_invoiced": 0,
"shipping_tax_amount": 0,
"state": "processing",
"status": "processing",
"store_currency_code": "USD",
"store_id": 1,
"store_name": "Main Website\nMain Website Store\nDefault Store View",
"store_to_base_rate": 0,
"store_to_order_rate": 0,
"subtotal": 200,
"subtotal_incl_tax": 200,
"subtotal_invoiced": 200,
"tax_amount": 0,
"tax_invoiced": 0,
"total_due": 0,
"total_invoiced": 200,
"total_item_count": 1,
"total_paid": 200,
"total_qty_ordered": 2,
"updated_at": "2022-01-13 06:47:13",
"weight": 200,
"x_forwarded_for": "14.102.51.229",
"items": [
{
"amount_refunded": 0,
"base_amount_refunded": 0,
"base_discount_amount": 0,
"base_discount_invoiced": 0,
"base_discount_tax_compensation_amount": 0,
"base_discount_tax_compensation_invoiced": 0,
"base_original_price": 100,
"base_price": 100,
"base_price_incl_tax": 100,
"base_row_invoiced": 200,
"base_row_total": 200,
"base_row_total_incl_tax": 200,
"base_tax_amount": 0,
"base_tax_invoiced": 0,
"created_at": "2022-01-13 06:46:19",
"discount_amount": 0,
"discount_invoiced": 0,
"discount_percent": 0,
"free_shipping": 0,
"discount_tax_compensation_amount": 0,
"discount_tax_compensation_invoiced": 0,
"is_qty_decimal": 0,
"is_virtual": 0,
"item_id": 144,
"name": "Accessories monogram D",
"no_discount": 0,
"order_id": 99,
"original_price": 100,
"price": 100,
"price_incl_tax": 100,
"product_id": 17,
"product_type": "simple",
"qty_canceled": 0,
"qty_invoiced": 2,
"qty_ordered": 2,
"qty_refunded": 0,
"qty_shipped": 0,
"quote_item_id": 568,
"row_invoiced": 200,
"row_total": 200,
"row_total_incl_tax": 200,
"row_weight": 200,
"sku": "Accessories monogram D",
"store_id": 1,
"tax_amount": 0,
"tax_invoiced": 0,
"tax_percent": 0,
"updated_at": "2022-01-13 06:46:19",
"weee_tax_applied": "[]",
"weight": 100
}
],
"billing_address": {
"address_type": "billing",
"city": "Noida",
"country_id": "US",
"email": "cs.hemantsingh@gmail.com",
"entity_id": 198,
"firstname": "Hemant",
"lastname": "Singh",
"parent_id": 99,
"postcode": "302021",
"region": "Uttar Pradesh",
"region_code": "UP",
"region_id": 566,
"street": [
"New test"
],
"telephone": null
},
"payment": {
"account_status": null,
"additional_information": [
"0",
"1",
"",
"TUZYUGM3ERY3Q",
"cs.hemantsingh@gmail.com",
"unverified",
"confirmed",
"133ea25fc4520",
"TUZYUGM3ERY3Q",
"EC-98T36492VK521913U",
"PayPal Express Checkout",
null,
"Eligible",
"completed",
"None"
],
"amount_authorized": 200,
"amount_ordered": 200,
"amount_paid": 200,
"base_amount_authorized": 200,
"base_amount_ordered": 200,
"base_amount_paid": 200,
"base_amount_paid_online": 200,
"base_shipping_amount": 0,
"base_shipping_captured": 0,
"cc_exp_year": "0",
"cc_last4": null,
"cc_ss_start_month": "0",
"cc_ss_start_year": "0",
"entity_id": 99,
"last_trans_id": "9LN125666F286773U",
"method": "paypal_express",
"parent_id": 99,
"shipping_amount": 0,
"shipping_captured": 0
},
"status_histories": [
{
"comment": "IPN \"Completed\" Registered notification about captured amount of $200.00. Transaction ID: \"<a target=\"_blank\" href=\"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=9LN125666F286773U\">9LN125666F286773U</a>\"",
"created_at": "2022-01-13 06:46:37",
"entity_id": 44,
"entity_name": "order",
"is_customer_notified": null,
"is_visible_on_front": 0,
"parent_id": 99,
"status": "processing"
},
{
"comment": "Captured amount of $200.00 online. Transaction ID: \"<a target=\"_blank\" href=\"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=9LN125666F286773U\">9LN125666F286773U</a>\"",
"created_at": "2022-01-13 06:46:19",
"entity_id": 43,
"entity_name": "invoice",
"is_customer_notified": null,
"is_visible_on_front": 0,
"parent_id": 99,
"status": "processing"
}
],
"extension_attributes": {
"shipping_assignments": [
{
"shipping": {
"address": {
"address_type": "shipping",
"city": "Noida",
"country_id": "IN",
"email": "cs.hemantsingh@gmail.com",
"entity_id": 197,
"firstname": "Hemant",
"lastname": "Singh",
"parent_id": 99,
"postcode": "302021",
"region": "Uttar Pradesh",
"region_code": "UP",
"region_id": 566,
"street": [
"New test"
],
"telephone": null
},
"method": "flatrate_flatrate",
"total": {
"base_shipping_amount": 0,
"base_shipping_discount_amount": 0,
"base_shipping_discount_tax_compensation_amnt": 0,
"base_shipping_incl_tax": 0,
"base_shipping_invoiced": 0,
"base_shipping_tax_amount": 0,
"shipping_amount": 0,
"shipping_discount_amount": 0,
"shipping_discount_tax_compensation_amount": 0,
"shipping_incl_tax": 0,
"shipping_invoiced": 0,
"shipping_tax_amount": 0
}
},
"items": [
{
"amount_refunded": 0,
"base_amount_refunded": 0,
"base_discount_amount": 0,
"base_discount_invoiced": 0,
"base_discount_tax_compensation_amount": 0,
"base_discount_tax_compensation_invoiced": 0,
"base_original_price": 100,
"base_price": 100,
"base_price_incl_tax": 100,
"base_row_invoiced": 200,
"base_row_total": 200,
"base_row_total_incl_tax": 200,
"base_tax_amount": 0,
"base_tax_invoiced": 0,
"created_at": "2022-01-13 06:46:19",
"discount_amount": 0,
"discount_invoiced": 0,
"discount_percent": 0,
"free_shipping": 0,
"discount_tax_compensation_amount": 0,
"discount_tax_compensation_invoiced": 0,
"is_qty_decimal": 0,
"is_virtual": 0,
"item_id": 144,
"name": "Accessories monogram D",
"no_discount": 0,
"order_id": 99,
"original_price": 100,
"price": 100,
"price_incl_tax": 100,
"product_id": 17,
"product_type": "simple",
"qty_canceled": 0,
"qty_invoiced": 2,
"qty_ordered": 2,
"qty_refunded": 0,
"qty_shipped": 0,
"quote_item_id": 568,
"row_invoiced": 200,
"row_total": 200,
"row_total_incl_tax": 200,
"row_weight": 200,
"sku": "Accessories monogram D",
"store_id": 1,
"tax_amount": 0,
"tax_invoiced": 0,
"tax_percent": 0,
"updated_at": "2022-01-13 06:46:19",
"weee_tax_applied": "[]",
"weight": 100
}
]
}
],
"payment_additional_info": [
{
"key": "paypal_express_checkout_shipping_overridden",
"value": "0"
},
{
"key": "button",
"value": "1"
},
{
"key": "paypal_express_checkout_shipping_method",
"value": ""
},
{
"key": "paypal_payer_id",
"value": "TUZYUGM3ERY3Q"
},
{
"key": "paypal_payer_email",
"value": "cs.hemantsingh@gmail.com"
},
{
"key": "paypal_payer_status",
"value": "unverified"
},
{
"key": "paypal_address_status",
"value": "confirmed"
},
{
"key": "paypal_correlation_id",
"value": "133ea25fc4520"
},
{
"key": "paypal_express_checkout_payer_id",
"value": "TUZYUGM3ERY3Q"
},
{
"key": "paypal_express_checkout_token",
"value": "EC-98T36492VK521913U"
},
{
"key": "method_title",
"value": "PayPal Express Checkout"
},
{
"key": "paypal_express_checkout_redirect_required",
"value": "null"
},
{
"key": "paypal_protection_eligibility",
"value": "Eligible"
},
{
"key": "paypal_payment_status",
"value": "completed"
},
{
"key": "paypal_pending_reason",
"value": "None"
}
],
"applied_taxes": [],
"item_applied_taxes": []
}
}

 

Conclusion:

If you want to get order information of customers then you can use the default rest API of Magento 2 for that.

We can get the order details in two ways one is on the basis of email id and the other on the basis of order id.

 

 

Related Posts:

Product Search REST API: List of REST APIs in Magento 2

How to Create REST API in Magento 2, For Beginners Guide