ohspotted

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

OhSpotted Go SDK

The official Go 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, plus a generic Request(). It has no dependencies outside the standard library.

Requirements

  • Go 1.22 or newer

Installation

go get github.com/ohspotted/ohspotted-go

Get your API key

Sign up for OhSpotted or sign in, then copy your API key from the dashboard. NewClient("", nil) reads the OHSPOTTED_API_KEY environment variable.

Quick start

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/ohspotted/ohspotted-go"
)

func main() {
	client, err := ohspotted.NewClient("", nil) // reads OHSPOTTED_API_KEY
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	response, err := client.AddTarget(ctx, &ohspotted.AddTargetParams{URL: "https://www.linkedin.com/company/linkedin"})
	if err != nil {
		log.Fatal(err)
	}
	data, err := response.Map()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(data)
}

Parameter structs mirror the API reference. Required fields are plain values; optional fields are pointers — use ohspotted.String, ohspotted.Float, ohspotted.Int and ohspotted.Bool.

Decode into your own types with response.Decode(&value).

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.

Any endpoint

response, err := client.Request(ctx, "GET", "/account", nil)

Errors

response, err := client.AddTarget(ctx, &ohspotted.AddTargetParams{URL: "https://www.linkedin.com/company/linkedin"})
if apiError, ok := ohspotted.IsAPIError(err); ok {
	log.Printf("HTTP %d %s: %s", apiError.StatusCode, apiError.Code, apiError.Message) // e.g. 402 no_credits
}
Error When
*ConfigurationError Missing API key, invalid options or unsupported method.
*SerializationError A required parameter is missing or a value can't be sent.
*TransportError Network failure, timeout or cancelled context (errors.Is(err, context.DeadlineExceeded)).
*APIError Non-2xx status (StatusCode, Message, Code, Response). Code is the API's error.code, such as no_credits, target_limit or not_found (empty when absent).
*ResponseDecodingError A success response could not be decoded.

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, err := ohspotted.NewClient("", &ohspotted.ClientOptions{
	MaxRetries: 5,                      // negative disables retries
	RetryDelay: 500 * time.Millisecond,
})

// or for one request
response, err := client.AddTarget(ctx, &ohspotted.AddTargetParams{URL: "https://www.linkedin.com/company/linkedin"}, ohspotted.WithMaxRetries(0))

Batch requests

ohspotted.Batch runs a function per item with at most 10 calls in flight and returns one BatchResult per item, in input order. A failing item never stops the others.

inputs := []string{"https://www.linkedin.com/company/linkedin", "https://www.linkedin.com/company/microsoft", "https://www.linkedin.com/company/github"}
results := ohspotted.Batch(ctx, inputs, 5, func(ctx context.Context, value string) (*ohspotted.Response, error) {
	return client.AddTarget(ctx, &ohspotted.AddTargetParams{URL: value})
})
for _, result := range results {
	if result.Err != nil {
		log.Printf("%s: %v", inputs[result.Index], result.Err)
		continue
	}
	fmt.Println(string(result.Value.Body))
}
Constant Default Description
DefaultConcurrency 10 Tasks run at the same time by batch
DefaultTimeout 120 * time.Second Request timeout
MaxRetries 3 Retry attempts after a network error, a 408/5xx
RetryBackoffFactor 1.5 Exponential backoff multiplier
DefaultRetryDelay time.Second Delay before the first retry

Timeouts and custom HTTP clients

client, err := ohspotted.NewClient("", &ohspotted.ClientOptions{
	Timeout:    60 * time.Second, // default 120 s; negative disables
	HTTPClient: &http.Client{Transport: myTransport},
})

Every method also honours the deadline and cancellation of the context.Context you pass.

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.

Documentation

Overview

Package ohspotted is the official Go SDK for the OhSpotted API (https://www.ohspotted.com).

Follow public LinkedIn profiles, company pages and jobs, and read what changed on them as signals, checked once a day.

Create one client and reuse it:

client, err := ohspotted.NewClient("", nil) // reads OHSPOTTED_API_KEY
response, err := client.AddTarget(ctx, ...)

Every documented endpoint has a typed method; Client.Request reaches any other path.

Index

Constants

View Source
const (
	// DefaultBaseURL is the production API origin.
	DefaultBaseURL = "https://www.ohspotted.com/api/v1"
	// DefaultTimeout bounds every request unless ClientOptions.Timeout says otherwise.
	DefaultTimeout = 120 * time.Second
	// APIKeyEnvironmentVariable is read when NewClient receives an empty API key.
	APIKeyEnvironmentVariable = "OHSPOTTED_API_KEY"
	// DefaultConcurrency is the number of tasks Batch runs at the same time.
	DefaultConcurrency = 10
	// MaxRetries is the default number of retries after a network error or a 408, 500, 502, 503 or 504.
	MaxRetries = 3
	// RetryBackoffFactor multiplies the delay before each new retry (a Retry-After header wins).
	RetryBackoffFactor = 1.5
	// DefaultRetryDelay is the delay before the first retry.
	DefaultRetryDelay = time.Second
	// MaxRetryDelay caps the delay between two attempts.
	MaxRetryDelay = 30 * time.Second
)
View Source
const Version = "0.1.0"

Version is the SDK version sent in the User-Agent header.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to v, for optional boolean parameters.

func Float

func Float(v float64) *float64

Float returns a pointer to v, for optional number parameters.

func Int

func Int(v int64) *int64

Int returns a pointer to v, for optional integer parameters.

func String

func String(v string) *string

String returns a pointer to v, for optional parameters.

Types

type APIError

type APIError struct {
	StatusCode int
	// Message is the "error" (or "message") field of the JSON body, when present.
	Message string
	// Code is the API's error code (the "code" of {"error": {"code", "message"}}), such as
	// "no_credits" or "target_limit"; empty when the body has none.
	Code     string
	Response *Response
}

APIError is returned for non-2xx responses.

func IsAPIError

func IsAPIError(err error) (*APIError, bool)

IsAPIError reports whether err is an *APIError and returns it.

func (*APIError) Error

func (e *APIError) Error() string

type AddTargetParams

type AddTargetParams struct {
	// The page's LinkedIn address, as copied from a browser (with or without https and www)
	URL string `json:"url" api:"url,required"`
}

AddTargetParams holds the parameters of AddTarget (POST /targets). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

type BatchResult

type BatchResult[T any] struct {
	Index int
	Value T
	Err   error
}

BatchResult is the outcome of one Batch item.

func Batch

func Batch[I, T any](ctx context.Context, items []I, concurrency int, task func(ctx context.Context, item I) (T, error)) []BatchResult[T]

Batch runs task for every item with at most concurrency calls in flight (DefaultConcurrency when concurrency <= 0) and returns one result per item, in input order. A failing item never stops the others; items not started when ctx is done get ctx.Err().

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a reusable, concurrency-safe OhSpotted API client.

func NewClient

func NewClient(apiKey string, options *ClientOptions) (*Client, error)

NewClient creates a client. An empty apiKey falls back to the OHSPOTTED_API_KEY environment variable.

func (*Client) AddTarget

func (c *Client) AddTarget(ctx context.Context, params *AddTargetParams, options ...RequestOption) (*Response, error)

AddTarget — Follow a page. Adds a LinkedIn profile, company page or job to the list. The first read happens shortly after, usually within minutes, and only takes the starting picture: signals are what changes after it, once a day. Needs the credits of one read (2 fo…

POST /targets

func (*Client) GetTarget

func (c *Client) GetTarget(ctx context.Context, params *GetTargetParams, options ...RequestOption) (*Response, error)

GetTarget — Get a page you follow. One target, with its latest signal.

GET /targets/{id}

func (*Client) GetUsage

func (c *Client) GetUsage(ctx context.Context, options ...RequestOption) (*Response, error)

GetUsage — Get your plan and credits. 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. Everything here uses the account's own list and credits, like the app: each page followed is read once a…

GET /usage

func (*Client) ListSignals

func (c *Client) ListSignals(ctx context.Context, params *ListSignalsParams, options ...RequestOption) (*Response, error)

ListSignals — Read what changed on all your pages. The signals found on every page of the list since each was added, newest first: the same as The Tea in the app.

GET /signals

func (*Client) ListTargetSignals

func (c *Client) ListTargetSignals(ctx context.Context, params *ListTargetSignalsParams, options ...RequestOption) (*Response, error)

ListTargetSignals — Read what changed on a page. 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 between them, and a change made and undone between two reads is never seen.

GET /targets/{id}/signals

func (*Client) ListTargets

func (c *Client) ListTargets(ctx context.Context, params *ListTargetsParams, options ...RequestOption) (*Response, error)

ListTargets — List the pages you follow. 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 followed by the account. Send url to find out whether one LinkedIn page is on the list.

GET /targets

func (*Client) MarkSignalsSeen

func (c *Client) MarkSignalsSeen(ctx context.Context, options ...RequestOption) (*Response, error)

MarkSignalsSeen — Mark everything as 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}.

POST /signals/seen

func (*Client) RemoveTarget

func (c *Client) RemoveTarget(ctx context.Context, params *RemoveTargetParams, options ...RequestOption) (*Response, error)

RemoveTarget — Stop following a page. 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.

DELETE /targets/{id}

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, params map[string]any, options ...RequestOption) (*Response, error)

Request sends any request, including endpoints released after this SDK version. GET parameters travel in the query string; POST parameters travel in a JSON body.

func (*Client) UpdateTarget

func (c *Client) UpdateTarget(ctx context.Context, params *UpdateTargetParams, options ...RequestOption) (*Response, error)

UpdateTarget — Pause, resume, mute or mark a page as seen. 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't in the daily email. seen: true marks every signal found on the page so far as seen. A page paused…

PATCH /targets/{id}

type ClientOptions

type ClientOptions struct {
	// BaseURL overrides DefaultBaseURL.
	BaseURL string
	// Timeout bounds each request. Zero uses DefaultTimeout; a negative value disables it.
	Timeout time.Duration
	// HTTPClient is copied and used for requests. Redirects are never followed.
	HTTPClient *http.Client
	// Headers are sent with every request.
	Headers map[string]string
	// MaxRetries overrides the number of retries. Zero uses MaxRetries; a negative value disables retries.
	MaxRetries int
	// RetryDelay is the delay before the first retry. Zero uses DefaultRetryDelay.
	RetryDelay time.Duration
}

ClientOptions configures a Client. The zero value is valid.

type ConfigurationError

type ConfigurationError struct {
	Message string
	Err     error
}

ConfigurationError reports a missing or unusable client configuration.

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

func (*ConfigurationError) Unwrap

func (e *ConfigurationError) Unwrap() error

type GetTargetParams

type GetTargetParams struct {
	// id returned when the page was added
	ID string `json:"id" api:"id,required"`
}

GetTargetParams holds the parameters of GetTarget (GET /targets/{id}). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

type ListSignalsParams

type ListSignalsParams struct {
	// Signals returned, newest first Default: 50.
	Limit *int64 `json:"limit" api:"limit"`
	// 1 (or true) for the signals not seen yet only; 0 (the default) for all of them Default: 0.
	Unread *int64 `json:"unread" api:"unread"`
}

ListSignalsParams holds the parameters of ListSignals (GET /signals). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

type ListTargetSignalsParams

type ListTargetSignalsParams struct {
	// id returned when the page was added
	ID string `json:"id" api:"id,required"`
	// Signals returned, newest first Default: 50.
	Limit *int64 `json:"limit" api:"limit"`
	// 1 (or true) for the signals not seen yet only; 0 (the default) for all of them Default: 0.
	Unread *int64 `json:"unread" api:"unread"`
}

ListTargetSignalsParams holds the parameters of ListTargetSignals (GET /targets/{id}/signals). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

type ListTargetsParams

type ListTargetsParams struct {
	// Only the target that follows this LinkedIn address (with or without https, www or tracking parameters): one item, or none when the page isn't on the list
	URL *string `json:"url" api:"url"`
	// Only this kind of page Allowed values: profile, company, job.
	Kind *string `json:"kind" api:"kind"`
	// Page number Default: 1.
	Page *int64 `json:"page" api:"page"`
	// Targets per page Default: 50.
	Limit *int64 `json:"limit" api:"limit"`
}

ListTargetsParams holds the parameters of ListTargets (GET /targets). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

type RemoveTargetParams

type RemoveTargetParams struct {
	// id returned when the page was added
	ID string `json:"id" api:"id,required"`
}

RemoveTargetParams holds the parameters of RemoveTarget (DELETE /targets/{id}). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

type RequestOption

type RequestOption func(*requestOptions)

RequestOption customizes one request.

func WithHeader

func WithHeader(name, value string) RequestOption

WithHeader adds a header to one request.

func WithMaxRetries

func WithMaxRetries(n int) RequestOption

WithMaxRetries overrides the number of retries for one request (0 disables them).

func WithMethod

func WithMethod(method string) RequestOption

WithMethod selects the HTTP method. Operations default to their own method.

type Response

type Response struct {
	StatusCode  int
	Header      http.Header
	ContentType string
	// Body holds the raw bytes: JSON text, or a file such as an image or PDF.
	Body []byte
	// IsJSON reports whether the body is JSON (Content-Type application/json or +json).
	IsJSON bool
}

Response is a buffered, successful API response.

func (*Response) Decode

func (r *Response) Decode(v any) error

Decode unmarshals a JSON body into v.

func (*Response) Map

func (r *Response) Map() (map[string]any, error)

Map decodes a JSON object body.

type ResponseDecodingError

type ResponseDecodingError struct {
	Message  string
	Response *Response
	Err      error
}

ResponseDecodingError reports a success response that could not be decoded.

func (*ResponseDecodingError) Error

func (e *ResponseDecodingError) Error() string

func (*ResponseDecodingError) Unwrap

func (e *ResponseDecodingError) Unwrap() error

type SerializationError

type SerializationError struct {
	Param   string
	Message string
	Err     error
}

SerializationError reports a parameter that is missing or cannot be sent.

func (*SerializationError) Error

func (e *SerializationError) Error() string

func (*SerializationError) Unwrap

func (e *SerializationError) Unwrap() error

type TransportError

type TransportError struct {
	Message string
	Err     error
}

TransportError reports a failure before a complete HTTP response was received, including client-side timeouts and context cancellation (see Unwrap).

func (*TransportError) Error

func (e *TransportError) Error() string

func (*TransportError) Unwrap

func (e *TransportError) Unwrap() error

type UpdateTargetParams

type UpdateTargetParams struct {
	// id returned when the page was added
	ID string `json:"id" api:"id,required"`
	// true to pause, false to resume
	Paused *bool `json:"paused" api:"paused"`
	// true to leave it out of the email
	Muted *bool `json:"muted" api:"muted"`
	// true to mark its signals as seen; false is refused
	Seen *bool `json:"seen" api:"seen"`
}

UpdateTargetParams holds the parameters of UpdateTarget (PATCH /targets/{id}). Required fields are plain values; optional fields are pointers (use ohspotted.String, ohspotted.Float, ohspotted.Bool) or nil slices and maps.

Directories

Path Synopsis
examples
json command
request command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL