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

ActivePhp-library[HTTP &amp; Networking](/categories/http)

mineur/twitter-stream-api
=========================

Collector of streaming twitter data

116621PHP

Since Jul 16Pushed 8y agoCompare

[ Source](https://github.com/mineur/twitter-stream-api)[ Packagist](https://packagist.org/packages/mineur/twitter-stream-api)[ RSS](/packages/mineur-twitter-stream-api/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (1)

Twitter Streaming API
=====================

[](#twitter-streaming-api)

[![License](https://camo.githubusercontent.com/6ca0e577868143b1e5a54c16a64b12a586617bcafcf7da3c7d69f180499024b3/68747470733a2f2f706f7365722e707567782e6f72672f6d696e6575722f747769747465722d73747265616d2d6170692f6c6963656e7365)](https://packagist.org/packages/mineur/twitter-stream-api)[![Build Status](https://camo.githubusercontent.com/dda51af0083086656a9c06e5f33eff09c8a21cf5e20c1f6b936caebc3845b9ca/68747470733a2f2f7472617669732d63692e6f72672f6d696e6575722f747769747465722d73747265616d2d6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mineur/twitter-stream-api)[![Code Climate](https://camo.githubusercontent.com/fa95c80c87f41f11c21eb69a7fbf867e7ca6aaa9db70d9f80bca78c59796b626/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d696e6575722f747769747465722d73747265616d2d6170692f6261646765732f6770612e737667)](https://codeclimate.com/github/mineur/twitter-stream-api)[![Latest Unstable Version](https://camo.githubusercontent.com/80c22f0e01ffde572c7082297b4ff49b94c6bc8bf21bbe7c58bf6de316a49aab/68747470733a2f2f706f7365722e707567782e6f72672f6d696e6575722f747769747465722d73747265616d2d6170692f762f756e737461626c65)](https://packagist.org/packages/mineur/twitter-stream-api)[![Total Downloads](https://camo.githubusercontent.com/5bc84000bc57566257b70c37802d4fdf05388a1436ded37b2c51fc7151787f1d/68747470733a2f2f706f7365722e707567782e6f72672f6d696e6575722f747769747465722d73747265616d2d6170692f646f776e6c6f616473)](https://packagist.org/packages/mineur/twitter-stream-api)

Another Twitter Stream PHP library. For now it just works on public stream, using the filter method.

Index
-----

[](#index)

- [Installation](#installation)
- [Basic init](#basic-initialization)
    - [Callback method](#callback-method)
    - [Filter by user](#filtering-tweets-by-user-id)
    - [Filter by language](#filtering-keywords-by-language)
- [The Tweet object](#the-tweet-object)
- [Integrations (Symfony)](#integrations)
- [Tests](#run-tests)
- [To-do](#todos)

Installation
------------

[](#installation)

```
composer require mineur/twitter-stream-api:dev-master
```

Basic initialization
--------------------

[](#basic-initialization)

Instantiate the GuzzleHttpClient adapter with your Twitter api tokens. And start consuming Twitter's Stream with some keywords! :)
If you don't have your Twitter API credentials, check this: [How to get your twitter access tokens ](https://dev.twitter.com/oauth/overview/application-owner-access-tokens)

```
use Mineur\TwitterStreamApi\Http\GuzzleStreamClient;
use Mineur\TwitterStreamApi\PublicStream;

$streamClient = new GuzzleStreamClient(
    'consumer_key',
    'consumer_secret',
    'access_token',
    'access_token_secret'
);
PublicStream::open($streamClient)
    ->listenFor([
        'your',
        'keywords',
        'list'
    ])
    ->consume();
```

> Working with the Twitter Stream you cannot open two stream lines with the same account. You should create another app account and raise a new instance of this library.

### Callback method

[](#callback-method)

You can also use a callback instead, if you want to modify the original output:

```
use Mineur\TwitterStreamApi\Tweet;

PublicStream::open($streamClient)
    ->listenFor([
        'your',
        'keywords',
        'list'
    ])
    ->do(function(Tweet $tweet) {
        echo "$tweet->getUser() tweeted: $tweet->getText()";
    });
```

### Filtering tweets by user ID

[](#filtering-tweets-by-user-id)

In this example you'll only get the tweets of a user corresponding to its ID.

```
$myTwitterId = '1234567';
PublicStream::open($streamClient)
    ->tweetedBy([
        $myTwitterId
    ])
    ->consume();
```

### Filtering keywords by language

[](#filtering-keywords-by-language)

In this example you'll only get the tweets on your keywords list write in spanish language.

```
PublicStream::open($streamClient)
    ->listenFor([
        'keywords',
        'list'
    ])
    ->setLanguage('es')
    ->consume();
```

The Tweet object
----------------

[](#the-tweet-object)

Once you receive the output from the PublicStream, let's say when you are using the `do`callback function, the output will always be an hydrated Tweet value object.
You can access it with the following methods:

- Using getters:

```
// Get specific data from the object
$tweet->getText();
```

- As an array:

```
// Transform object to an array, then access to the data
$aTweet = $tweet->toArray();
$aTweet['text'];
```

- Serialized:

```
// A complete serialized object to enqueue it, for example
$tweet->serialized();
```

Integrations
------------

[](#integrations)

For Symfony integrations you can refer to this bundle: [Mineur Twitter Stream Api Bundle](https://github.com/mineur/twitter-stream-api-bundle)

Run tests
---------

[](#run-tests)

```
composer install
./bin/phpunit
```

To check the coverage just add:

```
./bin/phpunit --coverage-text
```

Todo's
------

[](#todos)

- STREAMING\_ENDPOINT should be changed by client, using simple string injection
- Add links of the filters in documentation
- Test the first version of this library using Unit testing
- Handle when a user removes a tweet on the fly.
- Add `filter_level` feature
- Add track `location` feature

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c39d2aac6ac296199cfc57ef4712cf718af2d5906d05ec4b86acbba182edd45?d=identicon)[alexhoma](/maintainers/alexhoma)

---

Top Contributors

[![alexhoma](https://avatars.githubusercontent.com/u/7917771?v=4)](https://github.com/alexhoma "alexhoma (50 commits)")

---

Tags

guzzlemineurphp71streaming-apistreaming-datatwitter-streaming-api

### Embed Badge

![Health badge](/badges/mineur-twitter-stream-api/health.svg)

```
[![Health](https://phpackages.com/badges/mineur-twitter-stream-api/health.svg)](https://phpackages.com/packages/mineur-twitter-stream-api)
```

###  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)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[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)

PHPackages © 2026

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