You can certainly get this information through REST API. In fact, there are two different REST APIs using which you can get this information.
- Using Azure Resource Manager REST API - It is newer and recommended way to work with Service Bus Namespaces. The operation you would want to perform is
Queues - Get
. The response body will contain the details about the messages count. This API would require you to get an Azure AD access token which is then used for authorization.
- Using Old REST API - Though not recommended but you can use old Service Bus REST API to get the information. The operation you would to perform is
Get Entity
. This API would require you to use your Service Bus Namespace's shared access key for authorization.
Having said this, it is still recommended that you use the SDKs instead of consuming the REST API directly as SDKs are simply wrapper over REST APIs.