PHPackages                             apitube/news-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. apitube/news-api

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

apitube/news-api
================

PHP SDK for the APITube News API

1.2.0(1mo ago)1890MITPHPPHP ^8.1

Since Apr 1Pushed 1mo agoCompare

[ Source](https://github.com/apitube/news-api-php)[ Packagist](https://packagist.org/packages/apitube/news-api)[ RSS](/packages/apitube-news-api/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (5)Dependencies (24)Versions (6)Used By (0)

APITube News API PHP SDK
========================

[](#apitube-news-api-php-sdk)

[![GitHub Release](https://camo.githubusercontent.com/598f47f49a3b25e7f1d8e1312afa9c958aaf6d6efea4a07f4dc20b949c2613fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f617069747562652f6e6577732d6170692d706870)](https://github.com/apitube/news-api-php/releases)[![Latest Stable Version](https://camo.githubusercontent.com/36919587d8b98d191b4f1b5bfb64666e740a61d4c790e4bc8ae695cb74a90df5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617069747562652f6e6577732d617069)](https://packagist.org/packages/apitube/news-api)[![PHP Version Require](https://camo.githubusercontent.com/938283e5bb1656f97590780fe72969032ab9cb1d49d62df480b21df7296c34a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f617069747562652f6e6577732d6170692f706870)](https://packagist.org/packages/apitube/news-api)[![License](https://camo.githubusercontent.com/1b953a168591479c6eab3951d42ccc96688306b53938b92c9232e61fe12628a3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617069747562652f6e6577732d617069)](https://packagist.org/packages/apitube/news-api)[![PRs Welcome](https://camo.githubusercontent.com/dd0b24c1e6776719edb2c273548a510d6490d8d25269a043dfabbd38419905da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e737667)](https://github.com/apitube/news-api-php/pulls)[![PSR-18 Compatible](https://camo.githubusercontent.com/732c397d253b16876abf3b2f8cf01a7e65b5e96507a1a021596ece54e918bfc6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d31382d636f6d70617469626c652d626c75652e737667)](https://www.php-fig.org/psr/psr-18/)[![Made with Love](https://camo.githubusercontent.com/a9face83f44cf0e029f11823cce174dc4c54310f66f71263d7ba681ec3ddfabb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616465253230776974682d2545322539442541342d7265642e737667)](https://apitube.io)

PHP SDK for the [APITube News API](https://apitube.io) — access global news articles, headlines, stories, sentiment analysis, and more.

- [API Documentation](https://docs.apitube.io/)
- [Website](https://apitube.io)
- [More examples](https://github.com/apitube/news-api-workflows)
- [Cookbook](https://apitube.io/cookbook)

Requirements
------------

[](#requirements)

- PHP 8.1+
- A PSR-18 HTTP client (e.g. [Guzzle](https://docs.guzzlephp.org/en/stable/))
- A PSR-17 HTTP factory

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

[](#installation)

```
composer require apitube/news-api
```

Quick Start
-----------

[](#quick-start)

```
use APITube\Client;

$client = new Client(apiKey: 'your-api-key');

// Search news articles
$response = $client->news('everything', [
    'title' => 'artificial intelligence',
    'language.code' => 'en',
    'per_page' => 5,
]);

foreach ($response->articles as $article) {
    echo $article->title . "\n";
    echo $article->url . "\n\n";
}
```

Usage
-----

[](#usage)

### Initialize the client

[](#initialize-the-client)

```
use APITube\Client;

$client = new Client(
    apiKey: 'your-api-key',
    baseUrl: 'https://api.apitube.io', // optional, default value
);
```

You can pass any PSR-18 HTTP client:

```
$client = new Client(
    apiKey: 'your-api-key',
    httpClient: new \GuzzleHttp\Client(['timeout' => 30]),
);
```

### Search articles

[](#search-articles)

```
$response = $client->news('everything', [
    'title' => 'climate change',
    'language.code' => 'en',
    'per_page' => 10,
]);

echo "Page: {$response->page}\n";
echo "Has next page: " . ($response->hasNextPages ? 'yes' : 'no') . "\n";

foreach ($response->articles as $article) {
    echo "{$article->title}\n";
    echo "Source: {$article->source?->domain}\n";
    echo "Sentiment: {$article->sentiment?->overall?->polarity}\n\n";
}
```

### Specify API version

[](#specify-api-version)

```
$response = $client->news('everything', [
    'title' => 'artificial intelligence',
    'per_page' => 5,
], version: 'v1');
```

By default, the SDK uses `v1`.

### Top headlines

[](#top-headlines)

```
$response = $client->news('top-headlines', [
    'language.code' => 'en',
    'per_page' => 10,
]);

foreach ($response->articles as $article) {
    echo "{$article->title} — {$article->source?->domain}\n";
}
```

### Get a single article

[](#get-a-single-article)

```
$response = $client->news('article', [
    'id' => 'article-id',
]);

$article = $response->articles[0];
echo $article->title . "\n";
echo $article->body . "\n";
```

### Get articles by story

[](#get-articles-by-story)

```
$response = $client->news('story', [
    'id' => 'story-id',
]);

foreach ($response->articles as $article) {
    echo "{$article->title}\n";
}
```

### Raw articles

[](#raw-articles)

Fetch recently discovered articles before parsing and enrichment:

```
$response = $client->news('raw', [
    'per_page' => 50,
    'sort.by' => 'published_at',
    'sort.order' => 'desc',
]);

foreach ($response->articles as $article) {
    echo "{$article->title}\n";
}
```

### Count articles

[](#count-articles)

Count articles matching the same filters as `everything`:

```
$count = $client->count([
    'title' => 'artificial intelligence',
    'language.code' => 'en',
]);

echo "Matching articles: {$count}\n";
```

### Autocomplete suggestions

[](#autocomplete-suggestions)

Supported types: `categories`, `topics`, `industries`, `entities`.

```
$items = $client->suggest('categories', 'spo');

foreach ($items as $item) {
    echo "{$item['name']} (id: {$item['id']})\n";
}
```

### Reference data (people, companies, sources, journalists)

[](#reference-data-people-companies-sources-journalists)

Each entity exposes a paginated list method and a profile method by ID:

```
// List
$people = $client->people(['name' => 'Elon', 'per_page' => 5]);
foreach ($people->results as $person) {
    echo "{$person['name']} (id: {$person['id']})\n";
}

// Profile with coverage statistics
$profile = $client->person($people->results[0]['id']);
echo "Articles: {$profile['coverage']['article_count']}\n";

// Same shape for the other entities:
$client->companies(['name' => 'Tesla']);
$client->company($id);
$client->sources(['country' => 1]);
$client->source($id);
$client->journalists(['name' => 'Smith']);
$client->journalist($id);
```

### Check balance

[](#check-balance)

```
$balance = $client->balance();

echo "Plan: {$balance->plan}\n";
echo "Points: {$balance->points}\n";
```

### Ping

[](#ping)

```
$isAvailable = $client->ping();
echo $isAvailable ? 'API is available' : 'API is unavailable';
```

Error Handling
--------------

[](#error-handling)

The SDK throws typed exceptions:

```
use APITube\Exceptions\ApiException;
use APITube\Exceptions\AuthenticationException;
use APITube\Exceptions\RateLimitException;

try {
    $response = $client->news('everything', ['title' => 'php']);
} catch (AuthenticationException $e) {
    // Invalid or missing API key (HTTP 401)
    echo "Auth error: {$e->getMessage()}\n";
} catch (RateLimitException $e) {
    // Rate limit exceeded (HTTP 429)
    echo "Rate limited. Retry after: {$e->retryAfter} seconds\n";
} catch (ApiException $e) {
    // Other API errors
    echo "API error ({$e->getCode()}): {$e->getMessage()}\n";
    echo "Request ID: {$e->requestId}\n";
}
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

MIT

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance94

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Every ~14 days

Total

5

Last Release

33d ago

### Community

Maintainers

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

---

Top Contributors

[![liamka](https://avatars.githubusercontent.com/u/11809?v=4)](https://github.com/liamka "liamka (11 commits)")

---

Tags

api-clientapitubeheadlinesnewsnews-aggregatornews-apiphppsr-18rest-apipsr-18REST APIapi clientphp-sdknlp newsheadlinessentiment analysisnews-apiapitubenews-aggregator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/apitube-news-api/health.svg)

```
[![Health](https://phpackages.com/badges/apitube-news-api/health.svg)](https://phpackages.com/packages/apitube-news-api)
```

###  Alternatives

[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k28.0M301](/packages/openai-php-client)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

1003.9M47](/packages/getbrevo-brevo-php)[anthropic-ai/sdk

Anthropic PHP SDK

163583.3k15](/packages/anthropic-ai-sdk)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28150.5k](/packages/phpro-http-tools)[n1ebieski/ksef-php-client

PHP API client that allows you to interact with the API Krajowego Systemu e-Faktur

9067.8k](/packages/n1ebieski-ksef-php-client)

PHPackages © 2026

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