company

package
v2.8.21 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 8 Imported by: 0 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.

Documentation

Overview

Package company builds a public company profile from raw bodies the caller has already fetched (homepage HTML, Wikidata, SEC EDGAR, GitHub, ATS summary, Google Maps places). It performs no network I/O: Plan / Followups / PickWikidataEntity / EntityFollowupsFor tell the caller what to fetch next, and Merge folds the fetched bodies into a sanitized Profile with per-field source attribution.

Index

Constants

View Source
const (
	NetLinkedIn  = "linkedin"
	NetX         = "x"
	NetGitHub    = "github"
	NetFacebook  = "facebook"
	NetInstagram = "instagram"
	NetYouTube   = "youtube"
)

Social network keys (also used as `socials.<key>` in Profile.FieldSources).

View Source
const (
	SourceInput           = "input"
	SourceHomepageJSONLD  = "homepage_jsonld"
	SourceHomepageMeta    = "homepage_meta"
	SourceHomepageLinks   = "homepage_links"
	SourceWikidata        = "wikidata"
	SourceSECSubmissions  = "sec_submissions"
	SourceSECCompanyFacts = "sec_companyfacts"
	SourceGitHub          = "github"
	SourceATS             = "ats"
	SourceGoogleMaps      = "google_maps"
)

Source identifiers used in Profile.FieldSources / Profile.Sources.

Variables

View Source
var ErrInvalidDomain = errors.New("company: invalid or non-public domain")

ErrInvalidDomain is returned when the domain is not a safe public hostname.

View Source
var ErrNoInput = errors.New("company: name or domain is required")

ErrNoInput is returned by Plan when neither name nor domain is given.

Functions

func GitHubOrgURL

func GitHubOrgURL(login string) string

GitHubOrgURL builds the GitHub REST org URL for a login ("" when invalid).

func HostMatchesDomain

func HostMatchesDomain(host, domain string) bool

HostMatchesDomain reports whether host equals domain (ignoring `www.`) or shares its registrable domain (eTLD+1).

func NormalizeDomain

func NormalizeDomain(raw string) (string, error)

NormalizeDomain strips scheme, credentials-free authority, port, path, and a leading `www.`, lowercases, and validates that the result is a safe public, registrable hostname.

func NormalizeSocialURL

func NormalizeSocialURL(raw string) (network, normalized string, ok bool)

NormalizeSocialURL validates raw as a public https URL on a known social network and returns its canonical form: linkedin `https://www.linkedin.com/company/<slug>` (company/school/showcase pages only, never personal `/in/` profiles), `https://x.com/<handle>`, `https://github.com/<login>`, `https://www.facebook.com/<page>`, `https://www.instagram.com/<handle>`, `https://www.youtube.com/{@handle|channel/<id>|c/<name>|user/<name>}`. Non-https schemes (http:, javascript:, data:) and share/intent links are rejected.

func PadCIK

func PadCIK(cik string) (string, bool)

PadCIK returns the 10-digit zero-padded SEC CIK, or ok=false when cik is not 1-10 digits / zero.

func PlacesQuery

func PlacesQuery(in PlacesQueryInput) string

PlacesQuery builds the `search_places` text query: "<name> headquarters <hqHint>". When name is empty the domain label is used. Returns "" when there is nothing to search for.

func SECCompanyFactsURL

func SECCompanyFactsURL(cik string) string

SECCompanyFactsURL builds the data.sec.gov XBRL companyfacts URL ("" when cik invalid).

func SECSubmissionsURL

func SECSubmissionsURL(cik string) string

SECSubmissionsURL builds the data.sec.gov submissions URL ("" when cik invalid).

func WikidataEntitiesURL

func WikidataEntitiesURL(qids []string, labelsOnly bool) string

WikidataEntitiesURL builds one wbgetentities URL fetching labels/descriptions/claims for up to 50 QIDs.

func WikidataEntityURL

func WikidataEntityURL(qid string) string

WikidataEntityURL builds the Special:EntityData JSON URL for a QID ("" when invalid).

func WikidataSearchURL

func WikidataSearchURL(term string) string

WikidataSearchURL builds the wbsearchentities URL for term.

Types

type ATSSummary

type ATSSummary struct {
	BoardURLs   []string `json:"boardUrls,omitempty"`
	Platform    string   `json:"platform,omitempty"`
	OpenRoles   int      `json:"openRoles,omitempty"`
	Departments []string `json:"departments,omitempty"`
	Locations   []string `json:"locations,omitempty"`
	SampleRoles []string `json:"sampleRoles,omitempty"`
}

ATSSummary is the hiring summary the caller builds from the jobs tool.

type Employees

type Employees struct {
	Count int64  `json:"count"`
	AsOf  string `json:"asOf,omitempty"`
}

Employees is a headcount with its point-in-time date when known.

type EntityFollowups

type EntityFollowups struct {
	QID                string   `json:"qid,omitempty"`
	CIK                string   `json:"cik,omitempty"`
	SECSubmissionsURL  string   `json:"secSubmissionsUrl,omitempty"`
	SECCompanyFactsURL string   `json:"secCompanyFactsUrl,omitempty"`
	LabelIDs           []string `json:"labelIds"`
	LabelsURL          string   `json:"labelsUrl,omitempty"`
	HomepageURL        string   `json:"homepageUrl,omitempty"`
	GitHubOrgURL       string   `json:"githubOrgUrl,omitempty"`
}

EntityFollowups lists the fetches derived from a chosen Wikidata entity.

func EntityFollowupsFor

func EntityFollowupsFor(in EntityFollowupsInput) EntityFollowups

EntityFollowupsFor derives SEC URLs (from P5531 CIK), the label lookup URL for referenced items (HQ, country, industry, exchanges), and — when no domain is known — the P856 homepage and P2037 GitHub org.

type EntityFollowupsInput

type EntityFollowupsInput struct {
	EntityJSON string `json:"entityJson"`
	QID        string `json:"qid,omitempty"`
	Domain     string `json:"domain,omitempty"`
}

EntityFollowupsInput is the `company_entity_followups` request.

type FetchRequest

type FetchRequest struct {
	ID       string `json:"id"`
	URL      string `json:"url"`
	Method   string `json:"method"`
	Kind     string `json:"kind"`
	Optional bool   `json:"optional,omitempty"`
}

FetchRequest is one GET the hub should perform. Kind is "html" or "json".

type FollowupsInput

type FollowupsInput struct {
	WikidataSearchJSON string `json:"wikidataSearchJson"`
	Domain             string `json:"domain,omitempty"`
	Name               string `json:"name,omitempty"`
}

FollowupsInput is the `company_followups` request.

type FollowupsOutput

type FollowupsOutput struct {
	Candidates         []WikidataCandidate `json:"candidates"`
	WikidataEntityURLs []string            `json:"wikidataEntityUrls"`
	WikidataBatchURL   string              `json:"wikidataBatchUrl,omitempty"`
}

FollowupsOutput is the `company_followups` response.

func Followups

func Followups(in FollowupsInput) FollowupsOutput

Followups turns a Wikidata search body into entity fetch URLs (per-QID EntityData and one batched wbgetentities).

type GitHubSummary

type GitHubSummary struct {
	Login       string `json:"login"`
	URL         string `json:"url,omitempty"`
	PublicRepos int    `json:"publicRepos"`
	Followers   int    `json:"followers"`
}

GitHubSummary is the corroborated GitHub organization.

type Hiring

type Hiring struct {
	OpenRoles   int      `json:"openRoles"`
	Platform    string   `json:"platform,omitempty"`
	BoardURLs   []string `json:"boardUrls,omitempty"`
	Departments []string `json:"departments,omitempty"`
	Locations   []string `json:"locations,omitempty"`
	SampleRoles []string `json:"sampleRoles,omitempty"`
}

Hiring summarizes open roles.

type HomepageInput

type HomepageInput struct {
	URL         string `json:"url,omitempty"`
	FinalURL    string `json:"finalUrl,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	SiteName    string `json:"siteName,omitempty"`
	HTML        string `json:"html,omitempty"`
}

HomepageInput is a fetched HTML page (homepage or /about).

type Industry

type Industry struct {
	SICCode        string   `json:"sicCode,omitempty"`
	SICDescription string   `json:"sicDescription,omitempty"`
	Labels         []string `json:"labels,omitempty"`
}

Industry holds SEC SIC classification and Wikidata P452 industry labels.

type Listing

type Listing struct {
	Ticker   string `json:"ticker"`
	Exchange string `json:"exchange,omitempty"`
}

Listing is a ticker on an exchange.

type Location

type Location struct {
	City      string   `json:"city,omitempty"`
	Region    string   `json:"region,omitempty"`
	Country   string   `json:"country,omitempty"`
	Address   string   `json:"address,omitempty"`
	Latitude  *float64 `json:"latitude,omitempty"`
	Longitude *float64 `json:"longitude,omitempty"`
}

Location is a headquarters location.

type MergeInput

type MergeInput struct {
	Name                string         `json:"name,omitempty"`
	Domain              string         `json:"domain,omitempty"`
	Homepage            *HomepageInput `json:"homepage,omitempty"`
	About               *HomepageInput `json:"about,omitempty"`
	WikidataID          string         `json:"wikidataId,omitempty"`
	WikidataEntityJSON  string         `json:"wikidataEntityJson,omitempty"`
	WikidataLabelsJSON  string         `json:"wikidataLabelsJson,omitempty"`
	SECSubmissionsJSON  string         `json:"secSubmissionsJson,omitempty"`
	SECCompanyFactsJSON string         `json:"secCompanyFactsJson,omitempty"`
	GitHubOrgJSON       string         `json:"githubOrgJson,omitempty"`
	ATS                 *ATSSummary    `json:"ats,omitempty"`
	PlacesJSON          string         `json:"placesJson,omitempty"`
}

MergeInput is the `company_merge` request. Every source is optional.

type PickInput

type PickInput struct {
	WikidataSearchJSON string   `json:"wikidataSearchJson"`
	EntityJSONs        []string `json:"entityJsons,omitempty"`
	Domain             string   `json:"domain,omitempty"`
	Name               string   `json:"name,omitempty"`
}

PickInput is the `company_pick_wikidata` request. EntityJSONs holds Special:EntityData or wbgetentities bodies (each may contain several entities).

type PickResult

type PickResult struct {
	QID       string           `json:"qid,omitempty"`
	OK        bool             `json:"ok"`
	Reason    string           `json:"reason"`
	Website   string           `json:"website,omitempty"`
	Followups *EntityFollowups `json:"followups,omitempty"`
}

PickResult is the `company_pick_wikidata` response.

func PickWikidataEntity

func PickWikidataEntity(in PickInput) PickResult

PickWikidataEntity chooses the Wikidata item for the company. With a domain, only an entity whose P856 official website host matches the domain (exact, `www.`-stripped, or same registrable domain) is chosen; it never picks an uncorroborated entity. Without a domain, the first candidate whose label equals the name and whose description looks like an organization wins, else the first organization-like candidate.

type Place

type Place struct {
	Name        string   `json:"name,omitempty"`
	Address     string   `json:"address,omitempty"`
	MapsURL     string   `json:"mapsUrl,omitempty"`
	Phone       string   `json:"phone,omitempty"`
	Website     string   `json:"website,omitempty"`
	Rating      float64  `json:"rating,omitempty"`
	RatingCount int      `json:"ratingCount,omitempty"`
	Latitude    *float64 `json:"latitude,omitempty"`
	Longitude   *float64 `json:"longitude,omitempty"`
	MatchedBy   string   `json:"matchedBy,omitempty"`
}

Place is the best-matching map place for the company (from a Google Maps `search_places` result).

func PickPlace

func PickPlace(body, domain string, names []string) *Place

PickPlace selects the place whose website matches domain; otherwise one whose normalized name equals a normalized company name — but a place whose website points at a different domain is never chosen.

type PlacesQueryInput

type PlacesQueryInput struct {
	Name   string `json:"name,omitempty"`
	Domain string `json:"domain,omitempty"`
	HQHint string `json:"hqHint,omitempty"`
}

PlacesQueryInput is the `company_places_query` request.

type PlanInput

type PlanInput struct {
	Name   string `json:"name,omitempty"`
	Domain string `json:"domain,omitempty"`
}

PlanInput is the `company_plan` request.

type PlanOutput

type PlanOutput struct {
	Name       string         `json:"name,omitempty"`
	Domain     string         `json:"domain,omitempty"`
	SearchTerm string         `json:"searchTerm,omitempty"`
	GitHubSlug string         `json:"githubSlug,omitempty"`
	Requests   []FetchRequest `json:"requests"`
}

PlanOutput is the `company_plan` response.

func Plan

func Plan(in PlanInput) (PlanOutput, error)

Plan normalizes the input and returns the first wave of fetches (homepage, /about, Wikidata search, GitHub org). It performs no network I/O.

type Profile

type Profile struct {
	Name         string            `json:"name,omitempty"`
	LegalName    string            `json:"legalName,omitempty"`
	Domain       string            `json:"domain,omitempty"`
	Website      string            `json:"website,omitempty"`
	Description  string            `json:"description,omitempty"`
	Founded      int               `json:"founded,omitempty"`
	Headquarters *Location         `json:"headquarters,omitempty"`
	Industry     *Industry         `json:"industry,omitempty"`
	Employees    *Employees        `json:"employees,omitempty"`
	Ticker       string            `json:"ticker,omitempty"`
	Exchange     string            `json:"exchange,omitempty"`
	Listings     []Listing         `json:"listings,omitempty"`
	CIK          string            `json:"cik,omitempty"`
	Revenue      *Revenue          `json:"revenue,omitempty"`
	Socials      *Socials          `json:"socials,omitempty"`
	GitHub       *GitHubSummary    `json:"github,omitempty"`
	Hiring       *Hiring           `json:"hiring,omitempty"`
	Place        *Place            `json:"place,omitempty"`
	WikidataID   string            `json:"wikidataId,omitempty"`
	FieldSources map[string]string `json:"fieldSources"`
	Sources      []string          `json:"sources"`
	Warnings     []string          `json:"warnings,omitempty"`
	Markdown     string            `json:"markdown"`
}

Profile is the merged company profile. FieldSources maps a field key (e.g. "name", "headquarters", "industry.sic", "socials.linkedin") to the single source id that supplied it; Sources lists every source that contributed at least one field.

func Merge

func Merge(in MergeInput) Profile

Merge folds the fetched sources into a Profile. Precedence:

  • legal & financial facts (legalName, cik, ticker/exchange, SIC industry, revenue): SEC first;
  • founded, employees, headquarters: SEC address for HQ, then Wikidata, then homepage JSON-LD, then Google Maps place address;
  • description, logo, socials: homepage JSON-LD first, homepage meta / links next, Wikidata last;
  • display name: Wikidata label, JSON-LD name, og:site_name, input name, SEC name, page title.

Wikidata is used only when it is corroborated by the domain (P856) or no domain was given; SEC only when its CIK equals the accepted Wikidata P5531; GitHub only when its blog domain, a homepage/JSON-LD link, or Wikidata P2037 corroborates the login.

type Revenue

type Revenue struct {
	Value      int64  `json:"value"`
	Currency   string `json:"currency"`
	FiscalYear int    `json:"fiscalYear"`
	PeriodEnd  string `json:"periodEnd"`
	Form       string `json:"form,omitempty"`
	Filed      string `json:"filed,omitempty"`
	Concept    string `json:"concept,omitempty"`
}

Revenue is the latest full-year revenue from SEC XBRL companyfacts.

type Socials

type Socials struct {
	LinkedIn  string `json:"linkedin,omitempty"`
	X         string `json:"x,omitempty"`
	GitHub    string `json:"github,omitempty"`
	Facebook  string `json:"facebook,omitempty"`
	Instagram string `json:"instagram,omitempty"`
	YouTube   string `json:"youtube,omitempty"`
}

Socials holds normalized company social profile URLs (https only, canonical hosts).

type WikidataCandidate

type WikidataCandidate struct {
	ID          string `json:"id"`
	Label       string `json:"label,omitempty"`
	Description string `json:"description,omitempty"`
}

WikidataCandidate is one wbsearchentities hit.

func ParseWikidataSearch

func ParseWikidataSearch(body string) []WikidataCandidate

ParseWikidataSearch parses a wbsearchentities response into at most 5 valid candidates.

Jump to

Keyboard shortcuts

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