synthient

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

go-synthient

synthient sdk for golang. currently in development and NOT ready for use.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoToken    = errors.New("no token provided for client")
	ErrFileExists = errors.New("file already exists")
)
View Source
var (
	ErrBadRequest           = errors.New("invalid input parameters")
	ErrUnauthorized         = errors.New("no api key was provided or the key is invalid")
	ErrPaymentRequired      = errors.New("credits have run out")
	ErrInternalServerError  = errors.New("unexpected error occurred")
	ErrUnexpectedStatusCode = errors.New("returned status code did not match expected status code")
)

Functions

This section is empty.

Types

type AnonymizersQuery

type AnonymizersQuery struct {
	Provider     *string
	Type         *string
	LastObserved *string
	CountryCode  *string
	Format       string
	Full         bool
	Order        string
}

AnonymizersQuery defines optional filters and output options for the anonymizers feed download.

Pointer fields are optional; when nil, the corresponding filter is omitted from the request. Format selects the feed encoding (API-defined), Full requests the expanded dataset when true, and Order controls result ordering (API-defined).

type Client

type Client struct {
	HttpClient *http.Client
	Token      string
	BaseAPI    url.URL
	BaseFeeds  url.URL
}

Client is the primary API client for interacting with the Synthient v3 API.

HttpClient is used to execute requests (defaults to a zero-config http.Client in NewClient). Token is sent as the Authorization header value for authenticated endpoints. BaseAPI is the base URL for JSON API endpoints. BaseFeeds is the base URL for feed download endpoints.

func NewClient

func NewClient(token string) Client

NewClient constructs a Client configured for the Synthient v3 API.

The returned client uses the provided token for authentication and sets the default BaseAPI and BaseFeeds endpoints. Callers may override HttpClient and/or base URLs after construction if needed.

func (*Client) DownloadAnonymizersFeed

func (client *Client) DownloadAnonymizersFeed(
	query AnonymizersQuery,
	filepath string,
	options *RequestOptions,
) (int64, error)

DownloadAnonymizersFeed downloads the anonymizers feed and streams it directly to the given filepath.

The request is built from query and issued as a GET to:

{BaseFeeds}/feeds/anonymizers

The destination file must not already exist; if it does, this returns ErrFileExists. On success, it returns the number of bytes written to disk.

func (*Client) GetIP

func (client *Client) GetIP(ip string, options *RequestOptions) (IP, error)

GetIP looks up enrichment details for a single IPv4/IPv6 address.

It performs an HTTP GET request to the API endpoint:

{BaseAPI}/lookup/ip/{ip}

The provided ip is inserted into the request path (and should be a valid IP string). Request behavior such as context can be configured via options. A successful response (HTTP 200 OK) is decoded as JSON into an IP value and returned.

type IP

type IP struct {
	IP      string `json:"ip"`
	Network struct {
		Asn        int    `json:"asn"`
		Isp        string `json:"isp"`
		Type       string `json:"type"`
		Org        string `json:"org"`
		AbuseEmail string `json:"abuse_email"`
		AbusePhone string `json:"abuse_phone"`
		Domain     string `json:"domain"`
	} `json:"network"`
	Location struct {
		Country   string  `json:"country"`
		State     string  `json:"state"`
		City      string  `json:"city"`
		Timezone  string  `json:"timezone"`
		Longitude float64 `json:"longitude"`
		Latitude  float64 `json:"latitude"`
		GeoHash   string  `json:"geo_hash"`
	} `json:"location"`
	IPData struct {
		Devices []struct {
			OS      string `json:"os"`
			Version string `json:"version"`
		} `json:"devices"`
		DeviceCount int      `json:"device_count"`
		Behavior    []string `json:"behavior"`
		Categories  []string `json:"categories"`
		Enriched    []struct {
			Provider string `json:"provider"`
			Type     string `json:"type"`
			LastSeen string `json:"last_seen"`
		} `json:"enriched"`
		IPRisk int `json:"ip_risk"`
	} `json:"ip_data"`
}

IP represents the API response for an IP lookup.

type RequestOptions

type RequestOptions struct {
	Context context.Context
}

RequestOptions configures per-request behavior for client API calls.

Context is applied to the outgoing HTTP request (for cancellation, deadlines, and request-scoped values). If nil, the client uses context.Background().

Directories

Path Synopsis
_examples
ip command

Jump to

Keyboard shortcuts

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