To Retrieve Customer Default Shipping address by REST Webapi in Magento using Endpoint /V1/customers/:customerId/shippingAddress
Just Change the :customerId from the Endpoint with an Original customer ID to fetch the Shipping address of the Customer.
Action: GET
URL: <Host_Url>/rest/default/V1/customers/:customerId/shippingAddress
HEADER: Authorization:Bearer <ADMIN_TOKEN>
Get <ADMIN_TOKEN>
by link, Get Admin Token to use in the REST API header.
Request Payload: NULL
Response:
{ "id": 90366, "customer_id": 1866, "region": { "region_code": "MI", "region": "Michigan", "region_id": 33 }, "region_id": 33, "country_id": "US", "street": [ "Ear Guru Street" ], "company": "Samsung", "telephone": "49628-7978", "postcode": "70707", "city": "Ervin", "firstname": "John", "lastname": "Huges", "default_shipping": true, "default_billing": true }
If the Customer has a Default shipping address, the Result will be their default shipping address as an array on the output.
Same Way, You can Get the Default Billing address by Webapi using V1/customers/:customerId/billingAddress
I hope you can understand the logic to fetch the customer’s default shipping address.