Just a non-official SDK for Chatwork

0.4.0 2021-06-25 08:30 UTC

This package is auto-updated.

Last update: 2021-07-25 08:47:41 UTC


API Docs
Remember that this SDK is non-official. It may not work when Chatwork update their APIs in the feature.
(However, I will try to cover all the changes from Chatwork. If something goes wrong, please let me know)

StyleCI Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Chatwork SDK now supports Chatwork API version 2
Check the Chatwork API Document here


  • PHP >= 5.4
  • PHP cURL


You can install and manage Chatwork SDK for PHP by using Composer

composer require wataridori/chatwork-sdk

Or add wataridori/chatwork-sdk into the require section of your composer.json file then run composer update


Firstly, to use Chatwork API, you must register an API Key.
Pass your key to ChatworkSDK class.

If you have problems with the SSL Certificate Verification, you can turn it off by the following setting.

// Not recommend. Only do this when you have problems with the request

Now you can easily use many functions to access Chatwork API Endpoints.

ChatworkSDK's Classes

ChatworkAPI: This is the class that contains base API. You can use it to send request to Chatwork and receive the response in array.

$api = new ChatworkApi();
// Get user own information

// Get user own statics information

// Get user rooms list
ChatworkSDK also provides many others class that help you to work in more object oriented way.
  • ChatworkRoom: Use for store Room Information, with many functions to work with Room
  • ChatworkUser: Use for store User Information.
  • ChatworkMessage: Use for store Message Information.
$room = new ChatworkRoom($roomId);
// The following function will return an array of ChatworkUser
$members = $room->getMembers();
foreach ($members as $member) {
    // Print out User Information

// Send Message to All Members in the Room
$room->sendMessageToAll('Test Message');

// Send Message to list of members in the room
$room->sendMessageToList([$member_1, $member_2], 'Another Test Message');

The 3 classes above are extended from the ChatworkBase class. ChatworkBase provides you some useful function to work with messages. You can easily build a TO message, REPLY or QUOTE message.

$room = new ChatworkRoom($roomId);
$messages = $room->getMessages();
if ($messages & !empty($messages[0])) {
    $lastMessage = $messages[0];
    // Reset Message to null string
    // Append the REPLY text to current message
    // Append the QUOTE text to current message
    // Append the Information Text to the current message
    $room->appendInfo('Test Quote, Reply, Info text', 'Test from Chatwork-SDK');
    // Send current message into the Room
Check ChatworkSDK functions list here for further details and usages.

Run test

  • Create a file named config.json inside the tests/fixtures/ folder.
  • Input your API Key, and a test Room into config.json file. It should look like this:
  "apiKey": "YOUR-API-KEY-HERE",
  • Then run phpunit to start testing.


View contribution guidelines here