{"id":15672682,"url":"https://github.com/serafimarts/gitter-api","last_synced_at":"2025-05-06T21:44:09.516Z","repository":{"id":62542307,"uuid":"50363597","full_name":"SerafimArts/gitter-api","owner":"SerafimArts","description":"[production-ready] Gitter API implementation for php 7.0+ allowing sync, async and streaming access.","archived":false,"fork":false,"pushed_at":"2018-09-01T23:07:56.000Z","size":240,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T03:13:39.131Z","etag":null,"topics":["api","async","client","gitter","library","php7","streaming"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SerafimArts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-25T16:21:13.000Z","updated_at":"2022-11-28T08:23:30.000Z","dependencies_parsed_at":"2022-11-02T16:16:11.541Z","dependency_job_id":null,"html_url":"https://github.com/SerafimArts/gitter-api","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fgitter-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fgitter-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fgitter-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2Fgitter-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SerafimArts","download_url":"https://codeload.github.com/SerafimArts/gitter-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776314,"owners_count":21802459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","async","client","gitter","library","php7","streaming"],"created_at":"2024-10-03T15:30:06.745Z","updated_at":"2025-05-06T21:44:09.463Z","avatar_url":"https://github.com/SerafimArts.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitter API Client 4.0 \n\n[![Latest Stable Version](https://poser.pugx.org/serafim/gitter-api/v/stable)](https://packagist.org/packages/serafim/gitter-api)\n[![https://travis-ci.org/SerafimArts/gitter-api](https://travis-ci.org/SerafimArts/gitter-api.svg)](https://travis-ci.org/SerafimArts/gitter-api/builds)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/SerafimArts/gitter-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/SerafimArts/gitter-api/?branch=master)\n[![License](https://poser.pugx.org/serafim/gitter-api/license)](https://packagist.org/packages/serafim/gitter-api)\n[![Total Downloads](https://poser.pugx.org/serafim/gitter-api/downloads)](https://packagist.org/packages/serafim/gitter-api)\n\n\n- [Version 3.0.x](https://github.com/SerafimArts/gitter-api/tree/5bf22f2b5bbc517600937fbbaa44037a89688a82)\n- [Version 2.1.x](https://github.com/SerafimArts/gitter-api/tree/967ef646afa3181fbb10ec6669538c4911866731)\n- [Version 2.0.x](https://github.com/SerafimArts/gitter-api/tree/8ad7f4d06c5f8196ada5798799cd8c1d5f55a974)\n- [Version 1.1.x](https://github.com/SerafimArts/gitter-api/tree/26c3640a1d933db8ad27bd3c10f8bc42ff936c47)\n- [Version 1.0.x](https://github.com/SerafimArts/gitter-api/tree/f955ade02128e868d494baf0acc021bc257c1807)\n\n## Installation\n\n`composer require serafim/gitter-api`\n\n## Creating a Gitter Client\n\n\n```php\nuse Gitter\\Client;\n\n$client = new Client($token); \n// OR\n$client = new Client($token, $logger); // $logger are instance of \\Psr\\Log\\LoggerInterface\n\n// ... SOME ACTIONS ...\n\n$client-\u003econnect(); // Locks current runtime and starts an EventLoop (for streaming requests)\n```\n\n## Resources\n\n```php\n// $client = new \\Gitter\\Client('token');\n\n$client-\u003egroups;   // Groups resource (Traversable)\n$client-\u003emessages; // Messages resource\n$client-\u003erooms;    // Rooms resource (Traversable)\n$client-\u003eusers;    // Users resource\n```\n\n### Example\n\n```php\nforeach ($client-\u003erooms as $room) {\n    var_dump($room);\n}\n```\n\n### Streaming \n\n```php\n$observer = $client-\u003erooms-\u003emessages('roomId'); // Observer\n\n$observer-\u003esubscribe(function ($message) {\n    var_dump($message);\n});\n\n// Connect to stream!\n$client-\u003econnect();\n```\n\n## Available resources\n\n### Groups\n\nList groups the current user is in.\n\n- `$client-\u003egroups-\u003eall(): array`\n\nList of rooms nested under the specified group.\n\n- `$client-\u003egroups-\u003erooms(string $roomId): array`\n\n### Messages\n\nList of messages in a room in historical reversed order.\n\n- `$client-\u003emessages-\u003eall(string $roomId[, string $query]): \\Generator`\n\nThere is also a way to retrieve a single message using its id.\n\n- `$client-\u003emessages-\u003efind(string $roomId, string $messageId): array`\n\nSend a message to a room.\n\n- `$client-\u003emessages-\u003ecreate(string $roomId, string $content): array`\n\nUpdate a message.\n\n- `$client-\u003emessages-\u003eupdate(string $roomId, string $messageId, string $content): array`\n\nDelete a message.\n\n- `$client-\u003emessages-\u003edelete(string $roomId, string $messageId): array`\n\n### Rooms\n\nList rooms the current user is in.\n\n- `$client-\u003erooms-\u003eall([string $query]): array`\n\nJoin user into a room.\n\n- `$client-\u003erooms-\u003ejoinUser(string $roomId, string $userId): array`\n\nJoin current user into a room.\n\n- `$client-\u003erooms-\u003ejoin(string $roomId): array`\n\nJoin current user into a room by room name (URI).\n\n- `$client-\u003erooms-\u003ejoinByName(string $name): array`\n\nFind room by room name (URI).\n\n- `$client-\u003erooms-\u003efindByName(string $name): array`\n\nKick user from target room.\n\n- `$client-\u003erooms-\u003ekick(string $roomId, string $userId): array`\n\nThis can be self-inflicted to leave the the room and remove room from your left menu.\n\n- `$client-\u003erooms-\u003eleave(string $roomId): array`\n\nSets up a new topic of target room.\n\n- `$client-\u003erooms-\u003etopic(string $roomId, string $topic): array`\n\nSets the room is indexed by search engines.\n\n- `$client-\u003erooms-\u003esearchIndex(string $roomId, bool $enabled): array`\n\nSets the tags that define the room\n\n- `$client-\u003erooms-\u003etags(string $roomId, array $tags): array`\n\nIf you hate one of the rooms - you can destroy it!\n\n- `$client-\u003erooms-\u003edelete(string $roomId): array`\n\nList of users currently in the room. \n\n- `$client-\u003erooms-\u003eusers(string $roomId[, string $query]: \\Generator`\n\nUse the streaming API to listen events. \n\n- `$client-\u003erooms-\u003eevents(string $roomId): Observer`\n\nUse the streaming API to listen messages. \n\n- `$client-\u003erooms-\u003emessages(string $roomId): Observer`\n\n### Users\n\nReturns the current user logged in.\n\n- `$client-\u003eusers-\u003ecurrent(): array`\n- `$client-\u003eusers-\u003ecurrentUserId(): string`\n\nList of Rooms the user is part of.\n\n- `$client-\u003eusers-\u003erooms([string $userId]): array`\n\nYou can retrieve unread items and mentions using the following endpoint.\n\n- `$client-\u003eusers-\u003eunreadItems(string $roomId[, string $userId]): array`\n\nThere is an additional endpoint nested under rooms that you can use to mark chat messages as read\n\n- `$client-\u003eusers-\u003emarkAsRead(string $roomId, array $messageIds[, string $userId]): array`\n\nList of the user's GitHub Organisations and their respective Room if available.\n\n- `$client-\u003eusers-\u003eorgs([string $userId]): array`\n\nList of the user's GitHub Repositories and their respective Room if available.\n\n- `$client-\u003eusers-\u003erepos([string $userId]): array`\n\nList of Gitter channels nested under the user.\n\n- `$client-\u003eusers-\u003echannels([string $userId]): array`\n\n## Custom WebHook Notifications\n\nCreate a \"Custom Webhook\": \n- Open your chat\n- Click on \"Room Settings\" button\n- Click on \"Integrations\"\n- Select \"Custom\"\n- Remember yor Hook Id, like `2b66cf4653faa342bbe8` inside `https://webhooks.gitter.im/e/` url.\n\n```php\n$client-\u003enotify($hookId)\n    // -\u003eerror($message) - Send \"Error\" message\n    // -\u003einfo($message) - Send \"Info\" message\n    // -\u003ewithLevel(...) - Sets up level\n    -\u003esend('Your message with markdown'); // Send message with markdown content\n```\n\n## Custom routing\n\n```php\n$route = Route::get('rooms/{roomId}/chatMessages')\n    -\u003ewith('roomId', $roomId)\n    -\u003etoStream();\n    \n// Contains \"GET https://stream.gitter.im/v1/rooms/.../chatMessages\" url\n\n$client-\u003eviaStream()-\u003erequest($route)-\u003esubscribe(function($message) {\n     var_dump($message);\n    // Subscribe on every message in target room (Realtime subscribtion)\n});\n\n$client-\u003econnect();\n```\n\nAvailable route methods:\n\n- `Route::get(string $route)` - GET http method\n- `Route::post(string $route)` - POST http method\n- `Route::put(string $route)` - PUT http method\n- `Route::patch(string $route)` - PATCH http method\n- `Route::delete(string $route)` - DELETE http method\n- `Route::options(string $route)` - OPTIONS http method\n- `Route::head(string $route)` - HEAD http method\n- `Route::connect(string $route)` - CONNECT http method\n- `Route::trace(string $route)` - TRACE http method\n\nRoute arguments:\n\n- `$route-\u003ewith(string $key, string $value)` - Add route or GET query parameter\n- `$route-\u003ewithMany(array $parameters)` - Add route or GET query parameters\n- `$route-\u003ewithBody(string $key, string $value)` - Add POST, PUT, DELETE, etc body parameter\n\n\nSee more info about API into [Documentation](https://developer.gitter.im/docs/welcome)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fgitter-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserafimarts%2Fgitter-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fgitter-api/lists"}