Search by

xproapi / xproapi-php

xproapi

PHP client for the Xproapi X (Twitter) data API: profiles, followers, followings, tweets, search.

v1.0.0.0 2026-10-12 20:32 UTC

This package is not auto-updated.

Last update: 2026-10-13 19:07:16 UTC


README

Latest Version on Packagist Total Downloads License PHP Version Require

The official PHP SDK for Xproapi.com. A lightweight, type-safe client designed to query public X (Twitter) profiles, track follower events, and detect network diffs without heavy enterprise API costs or streaming connection overhead.

Key Capabilities

  • Follower Event Tracking: Fetch latest follower pages and compute diffs reliably.
  • Profile & Graph Ingestion: Access public follower and following lists as structured objects.
  • Resilient Network Handling: Built-in rate limit (HTTP 429) backoff, automatic retries, and strict timeouts.
  • Framework Agnostic: Works seamlessly in vanilla PHP, Laravel, Symfony, or background CLI workers.

Install

Requires PHP 8.1+ with ext-curl and ext-json; no other dependencies.

With Composer, from this folder (a path repository):

{
    "repositories": [{ "type": "path", "url": "../xproapi-code-examples/xproapi-php" }],
    "require": { "xproapi/xproapi-php": "*" }
}

Without Composer, copy the folder and require 'xproapi-php/autoload.php';.

Usage

use Xproapi\Client;

$x = new Client(getenv('XPROAPI_KEY'));

$user = $x->userInfo('jack')['data'];
echo "{$user['name']} has {$user['followers']} followers\n";

// One page (up to 200)
$page = $x->followers('jack', pageSize: 200);
foreach ($page['followers'] as $follower) { /* ... */ }
$next = $x->followers('jack', cursor: $page['next_cursor']);

// Every page, capped at 5 requests
foreach ($x->paginate('followers', ['userName' => 'jack'], maxPages: 5) as $follower) {
    echo $follower['userName'], "\n";
}

// Tweets
$x->lastTweets(['userName' => 'jack', 'includeReplies' => false]);
$x->advancedSearch('from:jack min_faves:100', queryType: 'Top');
$x->tweetsByIds(['20', '1800000000000000000']);
$x->replies('https://x.com/jack/status/20');   // ids or links

Methods return the API's JSON as arrays. The response keys are listed in the root README.

Options

new Client(
    apiKey: 'xp_...',
    baseUrl: 'https://xproapi.com/api', // default
    timeout: 30,                        // seconds per request
    maxRetries: 2,                      // for 429 / 502 / 503 / network errors; 0 = off
);

Errors

use Xproapi\{InsufficientCreditsException, NotFoundException, RateLimitException, XproapiException};

try {
    $x->userInfo('someone');
} catch (NotFoundException) {
    // no such user
} catch (InsufficientCreditsException $e) {
    // top up; nothing was charged
} catch (RateLimitException $e) {
    sleep($e->retryAfter);
} catch (XproapiException $e) {
    error_log("Xproapi {$e->status}: {$e->getMessage()}");
}

Rate limit

$x->rateLimit(); // ['limit' => 60, 'remaining' => 57] from the last response

Anything else

$x->get('/twitter/user/info', ['userName' => 'jack']) calls any GET endpoint with the same auth, retries and errors.

Tests

php tests/run.php