API so that Android can interact with WhatsApp

Question:

The initial idea is to connect an Android application so that it can interact with WhatsApp (for example, send text to WhatsApp, activate or deactivate functions for a specific user, etc.).

I have looked for some API for this task but I could not find any, and the one I found is perhaps abandoned ( https://github.com/venomous0x/WhatsAPI ) and is not official.

Is there an official API for it?

On the other hand, the alternative that I am using is the following (for sending text):

After looking at this link

Intent sendIntent = new Intent();

sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");

startActivity(sendIntent);

More or less it would be something like this:

public void enviarMsgApp(View view) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent .setType("text/plain");
    String texto = "Mensaje para enviar aqui";
    intent .setPackage("com.whatsapp");
    if (intent != null) {
        intent .putExtra(Intent.EXTRA_TEXT, texto);
        startActivity(Intent.createChooser(intent, texto));
    } else {
        Toast.makeText(this,"Nooo whatsapp, whatsapp man",  
                       Toast.LENGTH_SHORT)
                       .show();
    }
}

There is an alternative to be able to modify the "behavior" of WhatsApp on a user.

For example something like that the application (that is being created) is told the name of the user, and this application can make the changes on that user. For example, change the photo that is shown, silence, etc., although for this it has to request permissions from the user or that WhatsApp alerts the user that an adjustment is being tried and he has to authorize it or something like that.

Pseudo code:

public void cambiarFotoApp(View view, String nombreUsuario) {
        //..    
        Intent intent = new Intent(Intent.ACTION_SEND);
        //..

        intent .setPackage("com.whatsapp"); 
        //..
        //cambiarFoto(nombreUsuario, jpgNuevaFoto); 
}

Answer:

At the moment there is no official API to interact with the application beyond the example that you show to send a message.

For a time a viable option was WhatsAPI but the author had legal problems over this repository and abandoned development.

Scroll to Top