PHPackages                             adrii/whatsapp-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. adrii/whatsapp-api

ActiveLibrary[API Development](/categories/api)

adrii/whatsapp-api
==================

WhatsApp-Api is a lightweight library to easily interact with cloud APIs of the WhatsApp Business Platform.

0.7.0(3y ago)304.6k↓62.1%71MITPHP

Since Nov 18Pushed 2y ago6 watchersCompare

[ Source](https://github.com/AdrianVillamayor/Whatsapp-Api)[ Packagist](https://packagist.org/packages/adrii/whatsapp-api)[ RSS](/packages/adrii-whatsapp-api/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (1)Versions (5)Used By (1)

Whatsapp-Api
============

[](#whatsapp-api)

[![Latest Stable Version](https://camo.githubusercontent.com/498c8cd4d2cb6c242df774259017fe6586569c5590371eb75ca55c346c918ef3/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61647269692f77686174736170702d6170692e737667)](https://packagist.org/packages/adrii/whatsapp-api)[![Total Downloads](https://camo.githubusercontent.com/b0d4df6625bf223d518dbd0047cddcc743f32a0f8d5bfc32742f4f8ab05f17c1/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61647269692f77686174736170702d6170692e737667)](https://packagist.org/packages/adrii/whatsapp-api)[![License](https://camo.githubusercontent.com/eba90eefe62ea1ad8459a1167fc170e7e1919841d0c07a964dca6127fc0f0fce/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61647269692f77686174736170702d6170692e737667)](https://packagist.org/packages/adrii/whatsapp-api)

WhatsApp-Api is a lightweight library to easily interact with cloud APIs of the [WhatsApp Business Platform](https://developers.facebook.com/docs/whatsapp/business-management-api/get-started).

INDEX[Installation](https://github.com/AdrianVillamayor/Whatsapp-Api#installation)[Configutation](https://github.com/AdrianVillamayor/Whatsapp-Api#configutation)[Webhook](https://github.com/AdrianVillamayor/Whatsapp-Api#webhook)[Messages](https://github.com/AdrianVillamayor/Whatsapp-Api#messages)[License](https://github.com/AdrianVillamayor/Whatsapp-Api#license)Installation
------------

[](#installation)

Use [Composer](https://getcomposer.org/) to install the library.

```
composer require adrii/whatsapp-api
```

### Composer

[](#composer)

```
use Adrii\Whatsapp\Whatsapp;
```

Configutation
-------------

[](#configutation)

```
$graph_version    = "v15.0";
$phone_number_id  = "{phone_number_id}";
$access_token     = "{access_token}";
$recipient_id     = "{recipient_id}";

$ws = new Whatsapp($phone_number_id, $access_token, $graph_version);
```

Webhook
-------

[](#webhook)

To be alerted when you receive a message or when the status of a message changes, you need to set up a webhook connection point for your app.

This method handles the entire connection request on its own. The access\_token is used to validate the connection.

```
$ws->webhook()->connect($_GET);
```

Messages
--------

[](#messages)

StatusType✅[Text](https://github.com/AdrianVillamayor/Whatsapp-Api#text)✅[Template](https://github.com/AdrianVillamayor/Whatsapp-Api#template)✅[Location](https://github.com/AdrianVillamayor/Whatsapp-Api#location)✅[Contact](https://github.com/AdrianVillamayor/Whatsapp-Api#contact)✅[Media](https://github.com/AdrianVillamayor/Whatsapp-Api#media)✅[Interactive](https://github.com/AdrianVillamayor/Whatsapp-Api#interactive)### Text

[](#text)

Send basic text (emojis allowed).

```
$ws->send_message()->text("Aloha 🍍", $recipient_id);
```

### Template

[](#template)

Send message templates defined in the Meta manager.

```
$ws->send_message()->template("hello_world", $recipient_id);
```

Send message templates defined in the Meta manager with parameters

```
$component_header = array(
    "type" => "header",
    "parameters" => array(
        array(
            "type" => "image",
            "image" => array(
                "link" => "https://avatars.githubusercontent.com/u/29653964?v=4"
            )
        ),
    )
);

$component_body = array(
    "type" => "body",
    "parameters" => array(
        array(
            "type" => "text",
            "text" => "Adrii 🍍"
        )
    )
);

$component_button = array(
    "type"      => "button",
    "sub_type"  => "url",
    "index"     => 0,
    "parameters" => array(
        array(
            "type" => "text",
            "text" => "https://github.com/AdrianVillamayor/Whatsapp-Api"
        )
    )
);

$ws->send_message()->addComponent($component_header, $component_body, $component_button);

$response = $ws->send_message()->template("sample_purchase_feedback", $recipient_id);
```

### Location

[](#location)

Sends a location, through a longitude, latitude and an address.

```
$ws->send_message()->location("41.403191", "2.174840", "La Sagrada Família", "C/ De Mallorca, 401, 08013 Barcelona", $recipient_id);
```

### Contact

[](#contact)

Send a contact message

The name is the only required parameter, the other data are optional.

```
    $contact = array(
        "addresses" => array(
            array(
                "city"          => "city name",
                "country"       => "country name",
                "country_code"  => "code",
                "state"         => "Contact's State",
                "street"        => "Contact's Street",
                "type"          => "Contact's Address Type",
                "zip"           => "Contact's Zip Code"
            )
        ),

        "birthday" => "14-02-1997",
        "emails" => array(
            array(
                "email" => "email",
                "type" => "HOME"
            ),
            array(
                "email" => "email",
                "type" => "WORK"
            )
        ),
        "name" => array(
            "formatted_name" => "formatted name value",
            "middle_name" => "last name value",
        ),
        "phones" => array(
            array(
                "phone" => "654034823",
                "type" => "MAIN"
            ),
            array(
                "phone" => "Phone number",
                "type" => "HOME"
            ),
            array(
                "phone" => "Phone number",
                "type" => "WORK"
            )
        ),
        "urls" => array(
            array(
                "url" => "some url",
                "type" => "WORK"
            )
        )
    );

$ws->send_message()->addContact($contact);

$response = $ws->send_message()->contact($recipient_id);
```

You can concatenate as many contacts as you want

```
$ws->send_message()->addContact($contact_0, $contact_1, ...);
```

### Media

[](#media)

Send a media, as a link or id

```
$ws->send_message()->media("image", "https://avatars.githubusercontent.com/u/29653964?v=4", $recipient_id);

$ws->send_message()->media("video", "https://file-examples.com/storage/fe4658769b6331540b05587/2017/04/file_example_MP4_480_1_5MG.mp4", $recipient_id);

$ws->send_message()->media("document", "https://file-examples.com/storage/fe4658769b6331540b05587/2017/10/file-sample_150kB.pdf", $recipient_id);

$ws->send_message()->media("audio", "https://file-examples.com/storage/fe4658769b6331540b05587/2017/11/file_example_MP3_700KB.mp3", $recipient_id);

$ws->send_message()->media("sticker", "https://img-03.stickers.cloud/packs/210a9e68-b249-405f-8ea1-9af015ef074a/webp/c5b7bded-e0f0-4f79-86aa-ffd825aba680.webp", $recipient_id);
```

Describes the specified image or video media with caption.

```
$ws->send_message()->media("image", "https://avatars.githubusercontent.com/u/29653964?v=4", $recipient_id, "individual", true, "your-image-caption-to-be-sent");

$ws->send_message()->media("video", "https://file-examples.com/storage/fe4658769b6331540b05587/2017/04/file_example_MP4_480_1_5MG.mp4", $recipient_id, "individual", true, "your-video-caption-to-be-sent");
```

Describes the filename for the specific document.

```
$ws->send_message()->media("document", "https://file-examples.com/storage/fe4658769b6331540b05587/2017/10/file-sample_150kB.pdf", $recipient_id, "individual", true, null, "example_filename.pdf");
```

### Interactive

[](#interactive)

Send an interactive message with reply buttons

```
$button = [
        "header" => "Header",
        "body"   => "Body",
        "footer" => "Footer",
        "action" => [
            "buttons" => [
                [
                    "type" => "reply",
                    "reply" => [
                        "id" => "UNIQUE_BUTTON_ID_1",
                        "title" => "BUTTON_TITLE_1"
                    ]
                ],
                [
                    "type" => "reply",
                    "reply" => [
                        "id" => "UNIQUE_BUTTON_ID_2",
                        "title" => "BUTTON_TITLE_2"
                    ]
                ]
            ]
        ]
    ];

$ws->send_message()->interactive($button, $recipient_id, "button");
```

Send an interactive message with list of buttons

```
$list = [
    "header" => "Test Header",
    "body"   => "Test Body",
    "footer" => "Test Footer",
    "action" => [
        "button" => "BUTTON_TEXT",
        "sections" => [
            [
                "title" => "SECTION_1_TITLE",
                "rows" =>
                [
                    [
                        "id" => "SECTION_1_ROW_1_ID",
                        "title" => "SECTION_1_ROW_1_TITLE",
                        "description" => "SECTION_1_ROW_1_DESCRIPTION"
                    ],
                    [
                        "id" => "SECTION_1_ROW_2_ID",
                        "title" => "SECTION_1_ROW_2_TITLE",
                        "description" => "SECTION_1_ROW_2_DESCRIPTION"
                    ]
                ]
            ],
            [
                "title" => "SECTION_2_TITLE",
                "rows" => [
                    [
                        "id" => "SECTION_2_ROW_1_ID",
                        "title" => "SECTION_2_ROW_1_TITLE",
                        "description" => "SECTION_2_ROW_1_DESCRIPTION"
                    ],
                    [
                        "id" => "SECTION_2_ROW_2_ID",
                        "title" => "SECTION_2_ROW_2_TITLE",
                        "description" => "SECTION_2_ROW_2_DESCRIPTION"
                    ]
                ]
            ]
        ]
    ]
];

$ws->send_message()->interactive($list, $recipient_id, "list");
```

> ### [Data examples for each message](https://developers.facebook.com/docs/whatsapp/on-premises/webhooks/inbound#mentions)
>
> [](#data-examples-for-each-message)

Contributing
============

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
=======

[](#license)

[MIT](https://github.com/AdrianVillamayor/Whatsapp-Api/blob/master/LICENSE)

### Thanks for your help! 🎉

[](#thanks-for-your-help-)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Total

4

Last Release

1141d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2afdfe629e9e97324ca5336998290b7dc4653901af41b33a215702ed09374ac?d=identicon)[Adrii](/maintainers/Adrii)

---

Top Contributors

[![AdrianVillamayor](https://avatars.githubusercontent.com/u/29653964?v=4)](https://github.com/AdrianVillamayor "AdrianVillamayor (42 commits)")

---

Tags

lightweightphpwhatsappwhatsapp-api

### Embed Badge

![Health badge](/badges/adrii-whatsapp-api/health.svg)

```
[![Health](https://phpackages.com/badges/adrii-whatsapp-api/health.svg)](https://phpackages.com/packages/adrii-whatsapp-api)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
