Pre-Black Friday: 20% off, for as long as you stayEARLYBFon Solo and AgencyEnds Nov 28Start free

How-to guide

How to Look Up Companies by Domain (in Go)

Fifty lines of standard-library Go: read domains, call the API, retry on 429, write one JSON line per company.

Get your free API key →Free to start. No credit card. 1,000 records to spend whenever you like.

You send a domain to POST /v1/companies/enrich and get one company record back. This page gives you a Go program that does that for a list of domains.

TL;DR

  • It takes about 10 minutes and uses only the Go standard library.
  • It spends one LeadOcean record per company returned. A 404 (domain not in our data) is free, so the Free plan's 1,000 records cover 1,000 hits.
  • It retries on 429 using the Retry-After header and writes one JSON line per company.

Prerequisites

  • Go 1.21 or newer.
  • A LeadOcean API key, exported as $LEADOCEAN_API_KEY. The Free plan gives one key, no card.
  • A file domains.txt with one domain per line, for example acme.com.

Step 1: Send one request

The endpoint takes a flat JSON body with domain or linkedin_url. Auth is the x-api-key header. Test it with curl before writing Go.

bash
curl -s https://api.leadocean.io/v1/companies/enrich \
  -H "x-api-key: $LEADOCEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain":"acme.com"}'

A hit returns 200 with a data object. A miss returns 404.

Step 2: Write the Go program

Save this as main.go. It reads domains.txt, calls the API once per domain and prints JSON Lines to stdout.

go
package main
import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"net/http"
	"os"
	"strconv"
	"strings"
	"time"
)
const url = "https://api.leadocean.io/v1/companies/enrich"
func lookup(c *http.Client, key, domain string) ([]byte, error) {
	body := fmt.Sprintf(`{"domain":%q}`, domain)
	for try := 0; try < 5; try++ {
		req, _ := http.NewRequest("POST", url, bytes.NewBufferString(body))
		req.Header.Set("x-api-key", key)
		req.Header.Set("Content-Type", "application/json")
		res, err := c.Do(req)
		if err != nil {
			return nil, err
		}
		b, _ := io.ReadAll(res.Body)
		res.Body.Close()
		switch res.StatusCode {
		case 200:
			return bytes.ReplaceAll(b, []byte("\n"), nil), nil
		case 404:
			return nil, nil
		case 429:
			s, _ := strconv.Atoi(res.Header.Get("Retry-After"))
			time.Sleep(time.Duration(max(s, 1)) * time.Second)
		default:
			return nil, fmt.Errorf("%s: HTTP %d %s", domain, res.StatusCode, b)
		}
	}
	return nil, fmt.Errorf("%s: still rate limited", domain)
}
func main() {
	key := os.Getenv("LEADOCEAN_API_KEY")
	f, _ := os.Open("domains.txt")
	sc := bufio.NewScanner(f)
	c := &http.Client{Timeout: 30 * time.Second}
	for sc.Scan() {
		d := strings.TrimSpace(sc.Text())
		if d == "" {
			continue
		}
		line, err := lookup(c, key, d)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}
		if line != nil {
			fmt.Println(string(line))
		}
	}
}

The 429 branch waits for the number of seconds in Retry-After, then tries again, up to five times. A 429 costs no records.

Step 3: Run it and save the results

bash
printf 'acme.com\nexample.org\n' > domains.txt
go run main.go > companies.jsonl
wc -l companies.jsonl

Each line is one company. Misses are skipped, so the line count can be lower than the domain count. The loop is sequential on purpose. One call at a time rarely passes the Free plan's 5 requests a second, and the 429 branch covers the rest.

Step 4: Page through a search when you do not have the domains yet

Enrich returns one company per call, so there is nothing to page. If you need to build the domain list first, call POST /v1/companies/search. The body is flat JSON, filters are arrays, limit runs 1 to 100, and you pass the cursor from the previous page to get the next one.

json
{ "country": ["US"], "limit": 100, "cursor": "<meta.nextCursor from the last page>" }

One search pages to 10,000 rows. The last page has meta.depthCapped true and no nextCursor. Narrow the filters instead of walking further. To size the list first, call GET /v1/companies/count, which is free. Search spends one record per company returned, so check the count before you page.

What you get

This is the response shape from the API reference, with placeholder values. A hit is wrapped as success, data and meta, and data holds these groups.

json
{
  "success": true,
  "data": {
    "company_data": {
      "company_name": "Acme",
      "company_domain": "acme.com",
      "company_type": "Privately Held",
      "company_industries": [{ "name2": "Software Development", "priority": 1 }],
      "company_employees": { "number_of_employees": 120, "number_of_employees_code": "51-200" },
      "company_primary_address": { "city": "San Francisco", "country_code": "US" },
      "company_number_of_detected_technologies": 2
    },
    "company_detected_technologies": [
      { "technology_product": { "name": "Example CDN" }, "technology_category": { "name2": "Content Delivery Network" } }
    ],
    "company_metrics": { "completion_score": 90, "marketability_score": 80 },
    "meta": { "sources": ["own"], "schema": "leadocean.company.v1" }
  },
  "meta": { "source": "leadocean" }
}

Response shape from the company lookup docs (October 2026), placeholder values. Fields we hold nothing for come back as null. company_data also carries funding, revenue, NAICS and SIC codes, and company_number_of_profiles when we hold them.

Troubleshooting

ErrorCauseFix
401Missing or wrong x-api-keyCheck that $LEADOCEAN_API_KEY is exported in the same shell as go run
429Requests above the plan's rate (5 a second on Free, 200 on Agency)Keep the Retry-After sleep, or upgrade the plan
402The 1,000 Free records are spentAdd a paid plan at leadocean.io/pricing. Solo is $97 a month
404We hold nothing for that domainExpected and free. The program skips it
Empty companies.jsonldomains.txt has the wrong path or only missesRun from the folder that holds domains.txt. Try a bare domain, not a URL
Search stops at 10,000 rowsThe depth cap on one searchSplit the query with narrower filters

FAQ

Do I need an SDK?

No. The API is plain HTTPS and JSON, so net/http is enough.

Can I look up by LinkedIn URL instead?

Yes. Send linkedin_url in place of domain in the same body.

How do I go faster than one request at a time?

Run a few goroutines behind a shared limiter set to your plan's rate: 5 a second on Free, 50 on Solo, 200 on Agency. Keep the Retry-After handling.

Does a miss cost a record?

No. A 404 is free. A record is spent only for a company you receive.

Where do I see the other languages?

Same recipe in C#, TypeScript and Rust. More guides are in the blog. Plan details are on pricing.

Run your first Go lookup on the free plan

Free to start. No credit card. 1,000 records to spend whenever you like.

Get your free API key →