Knowing an account online status is still a Private API. So you could not do that in a "legal" way.
But of course WhatsApp and the other Apps you are mentioning at do that. So they know how to do it.
You have to reverse engineered them if you want to know how they do what you are asking for.
What you can do is know if a number is a valid WhatsApp user or not.
According to the documentation, you must have your Facebook WhatsApp Buisiness API:
https://developers.facebook.com/docs/whatsapp/api/reference/
WhatsApp is a fast, secure, and reliable way for businesses to reach
their customers all over the world. This guide describes how
businesses can use the WhatsApp Business API to interact with their
customers.
This version of the WhatsApp Business API uses a REST API Architecture
with JSON data formats. The API follows the standard HTTP
request-response exchange.
Once you have a valid business account you could then query the Contacts
(Contacts) node
Use the contacts node for the following purposes:
To verify that a phone number in your database belongs to a valid
WhatsApp account. You must ensure that status is valid before you can
message a user. To get the WhatsApp ID for a phone number. WhatsApp
IDs are needed to send messages, use notifications, and work with
groups.
From doc doing a POST request like that:
POST /v1/contacts
{
"blocking": "wait",
"contacts": [
"16315551003",
"1-631-555-1002",
"+54 9 11 5612-1008",
"+1 (516) 283-7151"
]
}
You can obtain such info:
Response After you send the request to check contacts you will receive
a response with the current status of the requested numbers. Contacts
that are new will typically have a status of processing as the
application asynchronously determines if the numbers belong to a valid
WhatsApp account.
If you use the "blocking": "wait" option in the request, the response
is now synchronous, so the response is generated only once the status
of all of the numbers has been determined. This implies that the
request will take a longer time to return if there are new contacts,
but you will not see the "processing" value returned. The example code
below demonstrates this behavior.
{
"contacts": [
{
"input": "1-631-555-1002",
"status": "invalid"
},
{
"input": "6315551003",
"status": "valid"
"wa_id": "16315551003"
},
{
"input": "+54 9 11 5612-1008",
"status": "invalid"
},
{
"input": "+1 (516) 283-7151",
"status": "valid"
"wa_id": "15162837151"
}
]
}