I created module for that, You can follow this steps for that :
Step 1 : Create registration.php file at app/code/RH/OrderStatus
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'RH_OrderStatus',
__DIR__
);
Step 2 : Create module.xml file at app/code/RH/OrderStatus/etc
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="RH_OrderStatus" setup_version="1.0.0"/>
</config>
Step 3 : Create webapi.xml file at app/code/RH/OrderStatus/etc
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd">
<route url="/V1/getorderstatus" method="GET">
<service class="RH\OrderStatus\Api\Getorderstatus" method="getorderstatusarray"/>
<resources>
<resource ref="admin"/>
</resources>
</route>
</routes>
Step 4 : Create di.xml file at app/code/RH/OrderStatus/etc
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="RH\OrderStatus\Api\Getorderstatus" type="RH\OrderStatus\Model\GetorderstatusModel" />
</config>
Step 5 : Create Getorderstatus.php file at app/code/RH/OrderStatus/Api
<?php
namespace RH\OrderStatus\Api;
interface Getorderstatus {
/**
* @api
* @return array
*/
public function getorderstatusarray();
}
Step 6 : Create GetorderstatusModel.php file at app/code/RH/OrderStatus/Model
<?php
namespace RH\OrderStatus\Model;
use RH\OrderStatus\Api\Getorderstatus;
class GetorderstatusModel implements Getorderstatus {
protected $statusCollectionFactory;
public function __construct(
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $statusCollectionFactory
) {
$this->statusCollectionFactory = $statusCollectionFactory;
}
public function getorderstatusarray() {
$options = $this->statusCollectionFactory->create()->toOptionArray();
return $options;
}
}
Now, Go to Admin -> System -> Integrations and Get Access Token value and set authorization value into postman application.
Then, execute {base_url}/rest/V1/getorderstatus
this URL in postman.
You will get all order status.
Hope, It will helpful for you.