Skip to content

About

Official Python SDK for the OhSpotted LinkedIn change tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

OhSpotted Python SDK

The official Python 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 typed methods, one per documented endpoint, with blocking and asyncio clients built on HTTPX, plus a generic request().

Requirements

  • Python 3.11 or newer

Installation

pip install ohspotted

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

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. Python keywords get a trailing underscore (from_=), and the wire name is used on the request.

Async I/O

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

response = client.request("GET", "/usage")

Errors

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.

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.

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

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.

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

About

Official Python SDK for the OhSpotted LinkedIn change tracking API.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages