The official Go client for SEC API. Resolve public companies, retrieve SEC filings and filing sections, and search SEC disclosures.
go get github.com/secapi-ai/secapi-goCreate an API key in the SEC API dashboard. See pricing before putting recurring workloads into production, then set the key for your application:
export SECAPI_API_KEY="secapi_live_..."Resolve a company by ticker. ResolveAgent requests view=agent and returns a typed *secapi.AgentEntity.
package main
import (
"encoding/json"
"errors"
"log"
"os"
secapi "github.com/secapi-ai/secapi-go"
)
func main() {
apiKey := os.Getenv("SECAPI_API_KEY")
if apiKey == "" {
log.Fatal("SECAPI_API_KEY is not set")
}
client := secapi.NewClient(apiKey)
entity, err := client.Entities.ResolveAgent(map[string]string{"ticker": "AAPL"})
if err != nil {
var apiErr *secapi.APIError
if errors.As(err, &apiErr) {
log.Fatalf("SEC API request %s failed: %s (%d)", apiErr.RequestID, apiErr.Code, apiErr.StatusCode)
}
log.Fatal(err)
}
if err := json.NewEncoder(os.Stdout).Encode(entity); err != nil {
log.Fatal(err)
}
}The response contains the resolved company, the matching basis, and a request ID for support:
{
"object": "entity",
"id": "cent_...",
"ticker": "AAPL",
"cik": "0000320193",
"name": "Apple Inc.",
"primaryIdentifiers": [{ "type": "ticker", "value": "AAPL" }],
"matchConfidence": 1,
"matchBasis": "ticker",
"requestId": "req_..."
}Filing and statement responses also preserve source fields where available, including filingUrl and sources[].sourceUrl. See the filing and section workflow for a request that fetches the latest 10-K and Item 1A.
NewClient sends the supplied key in the x-api-key header. Passing an empty string makes it read SECAPI_API_KEY; the client uses https://api.secapi.ai unless SECAPI_BASE_URL is set.
For an endpoint that explicitly uses bearer authentication, construct a separate client with secapi.NewBearerTokenClient. It accepts a token directly or reads SECAPI_BEARER_TOKEN when passed an empty string.
Every non-2xx API response is returned as *secapi.APIError. It preserves the HTTP status, API code, message, request ID, and decoded response body; the first-request program shows how to capture the request ID when reporting an issue.
The default HTTP timeout is 30 seconds. The client retries transient transport failures and 408, 502, 503, and 504 for GET and HEAD requests; it also retries 429 responses. Configure client.RetryConfig to change the retry policy.
- Basic example: resolve an entity and print its typed response.
- Filing and section workflow: resolve a company, fetch its latest 10-K, and retrieve Item 1A.
- Entity resolution reference
- SEC API documentation
- API conventions
This module requires Go 1.23 or later. The current client sends SEC API version 2026-03-19 by default. Report SDK bugs and request support through SEC API Support; include the API request ID for API-response problems.