ohspotted / sdk
Official PHP SDK for the OhSpotted LinkedIn change tracking API.
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.8
- guzzlehttp/psr7: ^2.6
- psr/http-client: ^1.0
- psr/http-message: ^1.1 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The official PHP SDK for the OhSpotted LinkedIn change tracking API.
Follow public LinkedIn profiles, company pages and jobs, and read what changed on them as signals, checked once a day.
The SDK exposes 9 methods, one per documented endpoint (with array-shape PHPDoc for static analysis), plus a generic request(). It sends requests through any PSR-18 client and uses Guzzle by default.
Requirements
- PHP 8.1 or newer
Installation
composer require ohspotted/sdk
Get your API key
Sign up for OhSpotted or sign in, then copy your API key from the dashboard. The client reads the OHSPOTTED_API_KEY environment variable when no key is passed.
Quick start
<?php require 'vendor/autoload.php'; use OhSpotted\Client; $client = new Client(getenv('OHSPOTTED_API_KEY') ?: null); $response = $client->addTarget(['url' => 'https://www.linkedin.com/company/linkedin']); print_r($response->data);
Parameter arrays use the names of the API reference. Unknown names throw a SerializationException; use request() for undocumented parameters.
HTTP methods
Each method uses the HTTP verb of its endpoint. GET and DELETE send parameters in the query string; POST and PATCH send them as a JSON body. Null values are never sent.
null values are omitted, false and 0 are sent, and lists repeat the parameter name.
Any endpoint
$response = $client->request('GET', '/account');
Errors
use OhSpotted\Exception\ApiException; try { $client->addTarget(['url' => 'https://www.linkedin.com/company/linkedin']); } catch (ApiException $exception) { echo $exception->status, ': ', $exception->getMessage(); }
| Exception | When |
|---|---|
ConfigurationException |
Missing API key, invalid options or unsupported method. |
SerializationException |
A required parameter is missing, unknown or can't be sent. |
TransportException |
Network failure or timeout. |
ApiException |
Non-2xx status (status, errorCode, errorMessage, responseBody, rawResponse). |
ResponseDecodingException |
A success response could not be decoded. |
errorCode is the API's error.code, such as no_credits, target_limit or not_found (null when the body has none).
All of them extend OhSpotted\Exception\OhSpottedException.
Retries
Requests are retried up to 3 times after a network error, a 408, 500, 502, 503 or 504. Other statuses, such as 400, 401, 402, 404 or 429, and client-side timeouts are not retried: the API's rate limits last until the hour (or the day) is over, and on the free plan every retry would count as a request. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a Retry-After header wins.
$client = new Client(null, ['max_retries' => 5, 'retry_delay' => 0.5]); $client->addTarget(['url' => 'https://www.linkedin.com/company/linkedin'], new RequestOptions(maxRetries: 0)); // one request without retries
Batch requests
batch() sends several calls with at most 10 requests in flight ($concurrency), through Guzzle's connection pool, and returns one BatchResult per call in input order. A failing call never stops the others. With a custom PSR-18 client the calls run one after another.
$inputs = ['https://www.linkedin.com/company/linkedin', 'https://www.linkedin.com/company/microsoft', 'https://www.linkedin.com/company/github']; $calls = array_map(static fn(string $value): array => ['addTarget', ['url' => $value]], $inputs); foreach ($client->batch($calls, concurrency: 5) as $result) { if ($result->ok()) { print_r($result->value->data); } else { echo $inputs[$result->index], ': ', $result->error->getMessage(), "\n"; } }
| Constant | Default | Description |
|---|---|---|
Client::DEFAULT_CONCURRENCY |
10 |
Tasks run at the same time by batch |
Client::DEFAULT_TIMEOUT |
120.0 |
Request timeout (seconds) |
Client::MAX_RETRIES |
3 |
Retry attempts after a network error, a 408/5xx |
Client::RETRY_BACKOFF_FACTOR |
1.5 |
Exponential backoff multiplier |
Client::DEFAULT_RETRY_DELAY |
1.0 |
Delay before the first retry (seconds) |
Options and custom HTTP clients
$client = new Client(null, [ 'timeout' => 60.0, // seconds, default 120 (default Guzzle client only) 'headers' => ['X-Trace' => 'abc'], 'http_client' => $psr18Client, // optional: any PSR-18 client ]);
Endpoints
9 methods, generated from the OpenAPI document.
| Method | HTTP | Description |
|---|---|---|
addTarget() |
POST /targets |
Adds a LinkedIn profile, company page or job to the list. The first read happens shortly after, usually within minutes, and only takes the… |
getTarget() |
GET /targets/{id} |
One target, with its latest signal. |
getUsage() |
GET /usage |
The plan, the credits left, how many pages are followed and how many the plan allows, and the credits the active pages use in 30 days. Ever… |
listSignals() |
GET /signals |
The signals found on every page of the list since each was added, newest first: the same as The Tea in the app. |
listTargetSignals() |
GET /targets/{id}/signals |
The signals found on one page since the account added it, newest first. A signal is a change between two daily reads: nothing is found betw… |
listTargets() |
GET /targets |
The account's list, newest first, with each page's state and its latest signal. A target is a LinkedIn profile, company page or job followe… |
markSignalsSeen() |
POST /signals/seen |
Marks every signal found so far as seen, on every page of the list. No body is needed. For one page, send seen: true to PATCH /targets/{id}. |
removeTarget() |
DELETE /targets/{id} |
Takes the page off the list. Its signals are no longer shown to the account; nothing else changes for the people who follow it too. |
updateTarget() |
PATCH /targets/{id} |
Send paused, muted and/or seen. A paused page isn't read and costs nothing; a muted page is still read and its signals are kept, but it isn… |
All OhSpotted SDKs
| SDK | Package | Install |
|---|---|---|
| Node.js | @ohspotted/sdk |
npm install @ohspotted/sdk |
| Python | ohspotted |
pip install ohspotted |
| Go | ohspotted-go |
go get github.com/ohspotted/ohspotted-go |
| .NET | OhSpotted |
dotnet add package OhSpotted |
| Ruby | ohspotted |
gem install ohspotted |
| PHP | ohspotted/sdk |
composer require ohspotted/sdk |
| Java | ohspotted-java |
build from source, see its README |
| CLI | @ohspotted/cli |
npm install -g @ohspotted/cli |
| MCP server | @ohspotted/mcp |
npx -y @ohspotted/mcp |
Trademarks
LinkedIn® is a registered trademark of LinkedIn Corporation. OhSpotted is not affiliated with, endorsed or sponsored by LinkedIn.
License
MIT — see LICENSE.