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
- func Bool(v bool) *bool
- func Float(v float64) *float64
- func Int(v int64) *int64
- func String(v string) *string
- type APIError
- type AddTargetParams
- type BatchResult
- type Client
- func (c *Client) AddTarget(ctx context.Context, params *AddTargetParams, options ...RequestOption) (*Response, error)
- func (c *Client) GetTarget(ctx context.Context, params *GetTargetParams, options ...RequestOption) (*Response, error)
- func (c *Client) GetUsage(ctx context.Context, options ...RequestOption) (*Response, error)
- func (c *Client) ListSignals(ctx context.Context, params *ListSignalsParams, options ...RequestOption) (*Response, error)
- func (c *Client) ListTargetSignals(ctx context.Context, params *ListTargetSignalsParams, options ...RequestOption) (*Response, error)
- func (c *Client) ListTargets(ctx context.Context, params *ListTargetsParams, options ...RequestOption) (*Response, error)
- func (c *Client) MarkSignalsSeen(ctx context.Context, options ...RequestOption) (*Response, error)
- func (c *Client) RemoveTarget(ctx context.Context, params *RemoveTargetParams, options ...RequestOption) (*Response, error)
- func (c *Client) Request(ctx context.Context, method, path string, params map[string]any, ...) (*Response, error)
- func (c *Client) UpdateTarget(ctx context.Context, params *UpdateTargetParams, options ...RequestOption) (*Response, error)
- type ClientOptions
- type ConfigurationError
- type GetTargetParams
- type ListSignalsParams
- type ListTargetSignalsParams
- type ListTargetsParams
- type RemoveTargetParams
- type RequestOption
- type Response
- type ResponseDecodingError
- type SerializationError
- type TransportError
- type UpdateTargetParams
Constants ¶
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 )
const Version = "0.1.0"
Version is the SDK version sent in the User-Agent header.
Variables ¶
This section is empty.
Functions ¶
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 ¶
IsAPIError reports whether err is an *APIError and returns it.
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 ¶
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 ¶
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 ¶
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 ¶
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.
type ResponseDecodingError ¶
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 ¶
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 ¶
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.