PHPackages                             legionth/serin - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. legionth/serin

ActiveLibrary[HTTP &amp; Networking](/categories/http)

legionth/serin
==============

Asynchronous Twitter API Client built on top of ReactPHP

v0.1.0(5y ago)54[2 issues](https://github.com/legionth/serin/issues)[1 PRs](https://github.com/legionth/serin/pulls)MITPHPCI passing

Since May 22Pushed 3w ago1 watchersCompare

[ Source](https://github.com/legionth/serin)[ Packagist](https://packagist.org/packages/legionth/serin)[ RSS](/packages/legionth-serin/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

Serin
=====

[](#serin)

Serin is an asynchronous Twitter API CLient built on top of ReactPHP

**Table of Contents**

- [Quickstart](#quickstart)
- [What is different from other libraries?](#what-is-different-from-other-libraries)
- [How to use this library](#how-to-use-this-library)
    - [Endpoints](#endpoints)
    - [Custom Requests](#custom-requests)
- [Authentication](#authentication)
- [Install](#install)
- [License](#license)

Quickstart
----------

[](#quickstart)

```
useReact\EventLoop\Factory;

require_once __DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();

$oauthConsumerKey = 'SyCz6mFj7992Wy9tAcM1zQQci';
$consumerSecret = 'm349wE5VEkS3PM2FdS5eeptxoXz4o6jPHVyS1JVpGCZmYyPMqf';

$oauthToken = '3019738408-5wkZjXGk02TfyjWpMMolQHHdkQ3fr8APdkkTluk';
$tokenSecret = 'bo34Dph9tQGQC7cEk7ZBir5f9Du608FylevCAUwzw33sG';

$client = new \Legionth\Serin\Client(
    $loop,
    $oauthConsumerKey,
    $consumerSecret,
    $oauthToken,
    $tokenSecret
);

$response = $client->tweet('does this work?');

$response->then(function (\Psr\Http\Message\ResponseInterface $response) use ($client) {
    echo \RingCentral\Psr7\str($response);
}, function (Exception $exception) {
    echo(\RingCentral\Psr7\str($exception->getResponse()));
});

$loop->run();
```

The code above will create a tweet on the designated account.

What is different from other libraries?
---------------------------------------

[](#what-is-different-from-other-libraries)

While other Twitter API Clients written in PHP use extension like [Curl](https://www.php.net/manual/de/book.curl.php)to send HTTP Requests, this library uses 100% pure PHP instead. The usage of [ReactPHP](https://github.com/reactphp) is used to make this library entirely asynchronous.

How to use this library
-----------------------

[](#how-to-use-this-library)

The `Client` class is all needed to communicate with Twitter API. Just enter the Twitter secrets and tokens and use the `Client` to interact with Twitter.

Never used the Twitter API before? Use the official [Twitter Developer Guide](https://developer.twitter.com/en)to create the tokens and secrets needed for this library.

This library uses [ReactPHP](https://github.com/reactphp/)so the entire library is based on a non-blocking concept. That's why every Client method will Return a [Promise](https://github.com/reactphp/promise)which will result in an [PSR-7 Response](https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface)when the server answered the request. In the meantime other requests can be sent without waiting for previous ones to be finished (unless you want to :) ).

```
$response = $client->tweet('does this work?');
$responseSecondTweet = $client->tweet('of course it does');

$response->then(function (\Psr\Http\Message\ResponseInterface $response) use ($client) {
    echo \RingCentral\Psr7\str($response);
}, function (Exception $exception) {
    echo(\RingCentral\Psr7\str($exception->getResponse()));
});

$responseSecondTweet->then(function (\Psr\Http\Message\ResponseInterface $response) use ($client) {
    echo \RingCentral\Psr7\str($response);
}, function (Exception $exception) {
    echo(\RingCentral\Psr7\str($exception->getResponse()));
});
```

### Endpoints

[](#endpoints)

Have a look at the Client methods to get an overview of all possible endpoints. This library tried to be as near as possible on the actual wording of the [offical Twitter API](https://developer.twitter.com/en/docs).

### Custom Requests

[](#custom-requests)

Is some endpoint missing? No worries create a PSR-7 request containing all necessary data.

The client will authenticate your request with the required OAuth 1.0a authentication.

```
$client = new \Legionth\Serin\Client(
    $loop,
    $oauthConsumerKey,
    $consumerSecret,
    $oauthToken,
    $tokenSecret
);

$request = new RingCentral\Psr7\ServerRequest(
    'POST',
    'https://api.twitter.com/1.1/statuses/update.json',
    [ 'Content-Type' => 'application/x-www-form-urlencoded'],
    'status=' . rawurlencode('Hello World'),
);

$response = $client->tweet($request);
```

Do you want to have an endpoint in the library? Open up a Pull Request or contact me!

Authentication
--------------

[](#authentication)

The OAuth 1.0a Authentication in this library will be used to send tweets, retweeting and get status information. That is why a registration at the Twitter API is required in order to use this library.

Install
-------

[](#install)

The recommended way to install this library is [through Composer](https://getcomposer.org).

[New to Composer?](https://getcomposer.org/doc/00-intro.md)

This will install the latest supported version:

```
$ composer require legionth/serin:^0.1.0
```

License
-------

[](#license)

See [License file](LICENSE)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance54

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

2184d ago

### Community

Maintainers

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

---

Top Contributors

[![legionth](https://avatars.githubusercontent.com/u/1578709?v=4)](https://github.com/legionth "legionth (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/legionth-serin/health.svg)

```
[![Health](https://phpackages.com/badges/legionth-serin/health.svg)](https://phpackages.com/packages/legionth-serin)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48247.0M384](/packages/php-http-curl-client)

PHPackages © 2026

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