Metadata-Version: 2.5
Name: ohspotted
Version: 0.1.0
Summary: Official Python SDK for the OhSpotted LinkedIn change tracking API.
Project-URL: Homepage, https://www.ohspotted.com
Project-URL: Documentation, https://www.ohspotted.com/docs
Project-URL: Repository, https://github.com/ohspotted/ohspotted-python
Project-URL: Issues, https://github.com/ohspotted/ohspotted-python/issues
Author-email: OhSpotted <contact@ohspotted.com>
License-Expression: MIT
License-File: LICENSE
Keywords: api,change-tracking,linkedin,monitoring,ohspotted,sdk,signals
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx<1,>=0.27
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.13; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff<1,>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

# OhSpotted Python SDK

The official Python SDK for the [OhSpotted](https://www.ohspotted.com) 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 typed methods**, one per documented endpoint, with blocking and `asyncio` clients built on [HTTPX](https://www.python-httpx.org/), plus a generic `request()`.

## Requirements

- Python 3.11 or newer

## Installation

```sh
pip install ohspotted
```

## Get your API key

[Sign up for OhSpotted](https://www.ohspotted.com/signup) or sign in, then copy your API key from the [dashboard](https://www.ohspotted.com/app). The client reads the `OHSPOTTED_API_KEY` environment variable when no key is passed.

## Quick start

```python
import os

from ohspotted import OhSpottedClient

with OhSpottedClient(os.environ["OHSPOTTED_API_KEY"]) as client:
    response = client.add_target(url="https://www.linkedin.com/company/linkedin")
    print(response.data)
```

Keyword arguments mirror the [API reference](https://www.ohspotted.com/docs). Python keywords get a trailing underscore (`from_=`), and the wire name is used on the request.

## Async I/O

```python
import asyncio

from ohspotted import AsyncOhSpottedClient


async def main() -> None:
    async with AsyncOhSpottedClient() as client:
        response = await client.add_target(url="https://www.linkedin.com/company/linkedin")
        print(response.data)


asyncio.run(main())
```

## 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.

`None` values are omitted, `False` and `0` are sent, and sequences repeat the parameter name.

## Any endpoint

```python
response = client.request("GET", "/account")
```

## Errors

```python
from ohspotted import OhSpottedAPIError

try:
    client.add_target(url="https://www.linkedin.com/company/linkedin")
except OhSpottedAPIError as error:
    print(error.status, error.error_code, error, error.response_body)
```

| Error | When |
| --- | --- |
| `OhSpottedConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
| `OhSpottedSerializationError` | A required parameter is missing or a value can't be sent. |
| `OhSpottedTransportError` | Network failure or timeout. |
| `OhSpottedAPIError` | Non-2xx status (`status`, `error_message`, `error_code`, `response_body`, `raw_response`). `error_code` is the API's `error.code`, such as `no_credits` or `target_limit` (`None` when the body has none). |
| `OhSpottedResponseDecodingError` | A success response could not be decoded. |

All of them extend `OhSpottedError`.

## 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.

```python
client = OhSpottedClient(max_retries=5, retry_delay=0.5)

# or for one request
client.add_target(url="https://www.linkedin.com/company/linkedin", request_options=RequestOptions(max_retries=0))
```

## Batch requests

`batch()` runs a function per item on 10 threads (`concurrency`) and returns one `BatchResult` per item, in input order. A failing item never stops the others. `AsyncOhSpottedClient.batch()` does the same with `asyncio`.

```python
inputs = ["https://www.linkedin.com/company/linkedin", "https://www.linkedin.com/company/microsoft", "https://www.linkedin.com/company/github"]
results = client.batch(inputs, lambda url: client.add_target(url=url), concurrency=5)

for result in results:
    if result.ok:
        print(result.value.data)
    else:
        print(inputs[result.index], result.error)
```

| Constant | Default | Description |
| --- | --- | --- |
| `DEFAULT_CONCURRENCY` | `10` | Tasks run at the same time by batch |
| `DEFAULT_TIMEOUT` | `120.0` | Request timeout (seconds) |
| `MAX_RETRIES` | `3` | Retry attempts after a network error, a 408/5xx |
| `RETRY_BACKOFF_FACTOR` | `1.5` | Exponential backoff multiplier |
| `DEFAULT_RETRY_DELAY` | `1.0` | Delay before the first retry (seconds) |

## Timeouts and custom HTTPX clients

```python
import httpx

from ohspotted import OhSpottedClient, RequestOptions

client = OhSpottedClient(timeout=60)  # seconds, default 120, None disables
client.add_target(url="https://www.linkedin.com/company/linkedin", request_options=RequestOptions(timeout=30))

# Bring your own HTTPX client (proxies, limits, event hooks…). You keep ownership of it.
http_client = httpx.Client(proxy="http://localhost:8080")
client = OhSpottedClient(http_client=http_client)
```

## Endpoints

9 methods, generated from the [OpenAPI document](https://www.ohspotted.com/openapi.json).

| Method | HTTP | Description |
| --- | --- | --- |
| `add_target()` | 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… |
| `get_target()` | GET `/targets/{id}` | One target, with its latest signal. |
| `get_usage()` | 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… |
| `list_signals()` | 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. |
| `list_target_signals()` | 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… |
| `list_targets()` | 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… |
| `mark_signals_seen()` | 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}. |
| `remove_target()` | 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. |
| `update_target()` | 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`](https://www.npmjs.com/package/@ohspotted/sdk) | `npm install @ohspotted/sdk` |
| Python | [`ohspotted`](https://pypi.org/project/ohspotted/) | `pip install ohspotted` |
| Go | [`ohspotted-go`](https://pkg.go.dev/github.com/ohspotted/ohspotted-go) | `go get github.com/ohspotted/ohspotted-go` |
| .NET | [`OhSpotted`](https://www.nuget.org/packages/OhSpotted) | `dotnet add package OhSpotted` |
| Ruby | [`ohspotted`](https://rubygems.org/gems/ohspotted) | `gem install ohspotted` |
| PHP | [`ohspotted/sdk`](https://packagist.org/packages/ohspotted/sdk) | `composer require ohspotted/sdk` |
| Java | [`ohspotted-java`](https://github.com/ohspotted/ohspotted-java) | build from source, see its README |
| CLI | [`@ohspotted/cli`](https://www.npmjs.com/package/@ohspotted/cli) | `npm install -g @ohspotted/cli` |
| MCP server | [`@ohspotted/mcp`](https://www.npmjs.com/package/@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](LICENSE).
