I can't seem to find a way to get the shipping address for an order though the REST API. Does anyone have an idea?


Looks like methods for retrieval of order addresses are not exposed via web API for some reason. You can expose them in you module simply by declaring in VendorName/ModuleName/etc/webapi.xml:

<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <route url="/V1/orderAddresses" method="GET">
        <service class="Magento\Sales\Api\OrderAddressRepositoryInterface" method="getList"/>
            <resource ref="Magento_Sales::sales" />

Then use search criteria to specify filter by parent_id (as for any other list operation)

  • I'm running into the same problem, however, I'm not that much of a Magento module developer. All I need to do is obtain orders from Magento in C#. Can you explain in a bit more detail what I need to do to expose the missing API or where I have to put above lines exactly? Feb 8 '16 at 16:30
  • 1
    If it is possible in your case, I would recommend to wait for Magento 2.1.0 release in April, this web API should be available then. If not, look for how to create new Magento module on Magento dev docs, and then expose missing API as described in current answer. Feb 9 '16 at 6:52
  • Thank you! This worked for me as well. Any idea what would happen if our customer updates Magento to a version where the API is published by default? Would there be a problem or would it continue working? If we disabled the module I've just created, would that be enough? Feb 9 '16 at 11:15
  • 1
    It will depend how it will be exposed by the Magento team (new interface might be introduced). However, you should still be able to use your endpoint, just make sure to use unique resource name, which will not conflict with the core one, e.g. /V1/yourModuleNameOrderAddresses. Feb 9 '16 at 11:20

You can also get the shipping address via the extension attributes of the order (that you have gotten via rest)

  1. Transform your order object to an array

    $magentoOrder = json_decode(json_encode($magentoOrderStd), true);
  2. Use this function to extract the shipping address

    private function getShippingAddressFromExtensionAttributes($magentoOrder)
       if (!isset($magentoOrder['extension_attributes']['shipping_assignments'])) return null;
       $shippingAssignments = $magentoOrder['extension_attributes']['shipping_assignments'];
       foreach ($shippingAssignments as $shippingAssignment) {
          if (!isset($shippingAssignment['shipping']['address'])) continue;
          return $shippingAssignment['shipping']['address'];
       return null;

It works well for me, but it can be, that it doesn't work with all shipping method. If there will occur any issue, I will let you know here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.