All Projects → SerafimArts → Gitter Api

SerafimArts / Gitter Api

[production-ready] Gitter API implementation for php 7.0+ allowing sync, async and streaming access.

Projects that are alternatives of or similar to Gitter Api

Restless
Express.js api, type safe validations and more
Stars: ✭ 32 (+190.91%)
Mutual labels:  api, async, library
Bt
BitTorrent library and client with DHT, magnet links, encryption and more
Stars: ✭ 2,011 (+18181.82%)
Mutual labels:  library, streaming, client
Deeply
PHP client for the DeepL.com translation API (unofficial)
Stars: ✭ 152 (+1281.82%)
Mutual labels:  api, library, client
Pyrogram
Telegram MTProto API Client Library and Framework in Pure Python for Users and Bots
Stars: ✭ 2,252 (+20372.73%)
Mutual labels:  async, library, client
Adrestia
APIs & SDK for interacting with Cardano.
Stars: ✭ 56 (+409.09%)
Mutual labels:  api, library, client
Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (+745.45%)
Mutual labels:  api, async, client
Mtproto Core
Telegram API JS (MTProto) client library for browser and nodejs
Stars: ✭ 242 (+2100%)
Mutual labels:  api, library, client
Libtmux
⚙️ python api for tmux
Stars: ✭ 599 (+5345.45%)
Mutual labels:  api, library
Instagram Api
Instagram's private API
Stars: ✭ 5,168 (+46881.82%)
Mutual labels:  api, library
Vibora
Fast, asynchronous and elegant Python web framework.
Stars: ✭ 5,734 (+52027.27%)
Mutual labels:  async, client
Parallec
Fast Parallel Async HTTP/SSH/TCP/UDP/Ping Client Java Library. Aggregate 100,000 APIs & send anywhere in 20 lines of code. Ping/HTTP Calls 8000 servers in 12 seconds. (Akka) www.parallec.io
Stars: ✭ 777 (+6963.64%)
Mutual labels:  api, async
Pycraft
Minecraft-client networking library in Python
Stars: ✭ 574 (+5118.18%)
Mutual labels:  library, client
Jikan
Unofficial MyAnimeList PHP+REST API which provides functions other than the official API
Stars: ✭ 531 (+4727.27%)
Mutual labels:  api, library
Unifi Api Client
A PHP API client class to interact with Ubiquiti's UniFi Controller API
Stars: ✭ 602 (+5372.73%)
Mutual labels:  api, client
Twitchlib
C# Twitch Chat, Whisper, API and PubSub Library. Allows for chatting, whispering, stream event subscription and channel/account modification. Supports .NET Core 2.0
Stars: ✭ 519 (+4618.18%)
Mutual labels:  api, client
Instagram Web Api
🤳 Instagram Private Web API client for Node
Stars: ✭ 694 (+6209.09%)
Mutual labels:  api, client
Swell
Swell: API development tool that enables developers to test endpoints served over streaming technologies including Server-Sent Events (SSE), WebSockets, HTTP2, GraphQL, and gRPC.
Stars: ✭ 517 (+4600%)
Mutual labels:  api, streaming
Simple Websocket Server
A very simple, fast, multithreaded, platform independent WebSocket (WS) and WebSocket Secure (WSS) server and client library implemented using C++11, Boost.Asio and OpenSSL. Created to be an easy way to make WebSocket endpoints in C++.
Stars: ✭ 685 (+6127.27%)
Mutual labels:  library, client
Yasumi
The easy PHP Library for calculating holidays
Stars: ✭ 788 (+7063.64%)
Mutual labels:  api, library
Swaddle
Automagically create API clients/wrappers in JavaScript
Stars: ✭ 23 (+109.09%)
Mutual labels:  api, client

Gitter API Client 4.0

Latest Stable Version https://travis-ci.org/SerafimArts/gitter-api Scrutinizer Code Quality License Total Downloads

Installation

composer require serafim/gitter-api

Creating a Gitter Client

use Gitter\Client;

$client = new Client($token); 
// OR
$client = new Client($token, $logger); // $logger are instance of \Psr\Log\LoggerInterface

// ... SOME ACTIONS ...

$client->connect(); // Locks current runtime and starts an EventLoop (for streaming requests)

Resources

// $client = new \Gitter\Client('token');

$client->groups;   // Groups resource (Traversable)
$client->messages; // Messages resource
$client->rooms;    // Rooms resource (Traversable)
$client->users;    // Users resource

Example

foreach ($client->rooms as $room) {
    var_dump($room);
}

Streaming

$observer = $client->rooms->messages('roomId'); // Observer

$observer->subscribe(function ($message) {
    var_dump($message);
});

// Connect to stream!
$client->connect();

Available resources

Groups

List groups the current user is in.

  • $client->groups->all(): array

List of rooms nested under the specified group.

  • $client->groups->rooms(string $roomId): array

Messages

List of messages in a room in historical reversed order.

  • $client->messages->all(string $roomId[, string $query]): \Generator

There is also a way to retrieve a single message using its id.

  • $client->messages->find(string $roomId, string $messageId): array

Send a message to a room.

  • $client->messages->create(string $roomId, string $content): array

Update a message.

  • $client->messages->update(string $roomId, string $messageId, string $content): array

Delete a message.

  • $client->messages->delete(string $roomId, string $messageId): array

Rooms

List rooms the current user is in.

  • $client->rooms->all([string $query]): array

Join user into a room.

  • $client->rooms->joinUser(string $roomId, string $userId): array

Join current user into a room.

  • $client->rooms->join(string $roomId): array

Join current user into a room by room name (URI).

  • $client->rooms->joinByName(string $name): array

Find room by room name (URI).

  • $client->rooms->findByName(string $name): array

Kick user from target room.

  • $client->rooms->kick(string $roomId, string $userId): array

This can be self-inflicted to leave the the room and remove room from your left menu.

  • $client->rooms->leave(string $roomId): array

Sets up a new topic of target room.

  • $client->rooms->topic(string $roomId, string $topic): array

Sets the room is indexed by search engines.

  • $client->rooms->searchIndex(string $roomId, bool $enabled): array

Sets the tags that define the room

  • $client->rooms->tags(string $roomId, array $tags): array

If you hate one of the rooms - you can destroy it!

  • $client->rooms->delete(string $roomId): array

List of users currently in the room.

  • $client->rooms->users(string $roomId[, string $query]: \Generator

Use the streaming API to listen events.

  • $client->rooms->events(string $roomId): Observer

Use the streaming API to listen messages.

  • $client->rooms->messages(string $roomId): Observer

Users

Returns the current user logged in.

  • $client->users->current(): array
  • $client->users->currentUserId(): string

List of Rooms the user is part of.

  • $client->users->rooms([string $userId]): array

You can retrieve unread items and mentions using the following endpoint.

  • $client->users->unreadItems(string $roomId[, string $userId]): array

There is an additional endpoint nested under rooms that you can use to mark chat messages as read

  • $client->users->markAsRead(string $roomId, array $messageIds[, string $userId]): array

List of the user's GitHub Organisations and their respective Room if available.

  • $client->users->orgs([string $userId]): array

List of the user's GitHub Repositories and their respective Room if available.

  • $client->users->repos([string $userId]): array

List of Gitter channels nested under the user.

  • $client->users->channels([string $userId]): array

Custom WebHook Notifications

Create a "Custom Webhook":

  • Open your chat
  • Click on "Room Settings" button
  • Click on "Integrations"
  • Select "Custom"
  • Remember yor Hook Id, like 2b66cf4653faa342bbe8 inside https://webhooks.gitter.im/e/ url.
$client->notify($hookId)
    // ->error($message) - Send "Error" message
    // ->info($message) - Send "Info" message
    // ->withLevel(...) - Sets up level
    ->send('Your message with markdown'); // Send message with markdown content

Custom routing

$route = Route::get('rooms/{roomId}/chatMessages')
    ->with('roomId', $roomId)
    ->toStream();
    
// Contains "GET https://stream.gitter.im/v1/rooms/.../chatMessages" url

$client->viaStream()->request($route)->subscribe(function($message) {
     var_dump($message);
    // Subscribe on every message in target room (Realtime subscribtion)
});

$client->connect();

Available route methods:

  • Route::get(string $route) - GET http method
  • Route::post(string $route) - POST http method
  • Route::put(string $route) - PUT http method
  • Route::patch(string $route) - PATCH http method
  • Route::delete(string $route) - DELETE http method
  • Route::options(string $route) - OPTIONS http method
  • Route::head(string $route) - HEAD http method
  • Route::connect(string $route) - CONNECT http method
  • Route::trace(string $route) - TRACE http method

Route arguments:

  • $route->with(string $key, string $value) - Add route or GET query parameter
  • $route->withMany(array $parameters) - Add route or GET query parameters
  • $route->withBody(string $key, string $value) - Add POST, PUT, DELETE, etc body parameter

See more info about API into Documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].