Whatsapp does not officially provide an API, some devs have reversed engineered the service to provide some sort of API, however, most of them get shut down with legal threats from whatsapp themselves.
at the moment whatsapp does not give you information or some code for this, maybe in a not too distant time you can do what you are looking for, giving solutions with some actualizar whatsapp. let's hope it goes to what you're looking for luck.