The official FullContact Golang Client Library for the FullContact V3 APIs.
To install FullContact Go client, use go get
:
go get github.com/fullcontact/fullcontact-go/fc
Then, reference fullcontact-go in a Go program with import
:
import fc "github.com/fullcontact/fullcontact-go/fc"
To update FullContact Go client to the latest version use:
go get -u github.com/fullcontact/fullcontact-go/fc
FullContact client supports v3 Enrich APIs which are super simplified to easily enrich Person and Company data. All the API requests are over HTTPS using POST method with content sent as JSON. This library supports Multi Field Request, Person Enrichment & Data Packs, Company Enrichment & Data Packs and Webhooks. Just build a FullContact Client with your API Key, make a enrich request and get a response object back.
If you are not familiar with the Enrich API, complete details can be found @API documentation
FullContact Client provides an object layer to FullContact API communication, but understanding Enrich API, webhooks, request and response parameters, and common snags is still important.
Once you’re on board with the API behavior, FullContact Client library should simplify your integration.
- Enrich
person.enrich
company.enrich
company.search
- Resolve
identity.map
identity.resolve
identity.delete
FullContact client uses CredentialsProvider
interface for Authentication. Different ways
to provide authentication:
- Static API Key provider:
cp, err := fc.NewStaticCredentialsProvider("your-api-key")
- Through System Environment Variable:
//API Key is stored as Environment variable FC_API_KEY
cp, err := fc.NewDefaultCredentialsProvider("FC_API_KEY")
- If no
CredentialsProvider
is specified while making FullContact Client, it automatically looks for API key from Environment variable"FC_API_KEY"
(Don't have an API key? You can pick one up for free right here.)
Make your fcClient with:
Parameters | Description | Default value | isOptional |
---|---|---|---|
WithCredentialsProvider |
Used for Authentication | API Key through Environment variable"FC_API_KEY" |
No |
WithHeaders |
Any Custom Headers you want to add with every request, can include Reporting-Key as well. |
No additional header | Yes |
WithTimeout |
Connection timeout in millis for request | 3000ms | Yes |
WithRetryHandler |
type RetryHandler | DefaultRetryHandler |
Yes |
Please note that you don't have to provide Authorization
and Content-Type
in the
custom Headers map as these will be automatically added.
Custom headers provided will remain same and will be sent with every request made with this client.
If you wish to change the headers, make a new client with new custom headers.
type RetryHandler interface {
ShouldRetry(responseCode int) bool
RetryAttempts() int
RetryDelayMillis() int
}
In case of failure, FullContact Client will auto-retry for same request based on certain conditions set in RetryHandler
-
Although optional, a custom Retry handler can be created by implementing
RetryHandler
interface and then be used to make FC client. By default, client will useDefaultRetryHandler
to schedule a retry for same request, withretryAttempts = 1
,retryDelayMillis = 1000
, and in case of429
(rate limit error) or503
(capacity limit error). -
This Client will auto-retry for a maximum of 5 times, even if higher value is set in the custom Retry Handler.
fcClient, err := fc.NewFullContactClient(
fc.WithCredentialsProvider(cp),
fc.WithHeader(map[string]string{"Reporting-Key": "FC_GoClient_1.0.0"}),
fc.WithTimeout(3000))
person.enrich
company.enrich
company.search
Our V3 Person Enrich supports Multi Field Request: ability to match on one or many input fields
You can build a Person Request using NewPersonRequest
and setting different input parameters that you have. If you want to use Webhook, you can specify
it in webhookUrl
field.
API can lookup and enrich individuals by sending any identifiers you may already have,
such as:
Emails
: []stringPhones
: []stringLocation
: *LocationAddressLine1
: stringAddressLine2
: stringCity
: stringRegion
: stringRegionCode
: stringPostalCode
: string
Name
: *PersonNameFull
: stringGiven
: stringFamily
: string
Profiles
: []*ProfileService
: stringUsername
: stringUserid
: stringUrl
: string
DataFilters
: []stringMaids
: []stringConfidence
: stringInfer
: boolEebhookUrl
: stringRecordId
: stringPersonId
: string
profile, err := fc.NewProfile(
fc.WithUsername("bartlorang"),
fc.WithService("twitter"))
if err != nil {
log.Fatalln(err)
return
}
personRequest, err := fc.NewPersonRequest(
fc.WithEmail("bart@fullcontact.com"),
fc.WithEmail("bart.lorang@fullcontact.com"),
fc.WithName(&fc.PersonName{Full:"Bart Lorang",}),
fc.WithLocation(fc.NewLocation(
fc.WithAddressLine1("123 Main street"),
fc.WithAddressLine1("Unit2"),
fc.WithCity("Denver"),
fc.WithRegionForLocation("Colorado"))),
fc.WithProfile(profile),
fc.WithWebhookUrl(""),
fc.WithRecordId("customer123"),
fc.WithPersonId("eYxWc0B-dKRxerTw_uQpxCssM_GyPaLErj0Eu3y2FrU6py1J"))
You can send a request by calling PersonEnrich
on fcClient and passing personRequest
as a argument. It sends a Asynchronous request and a channel
of type APIResponse
is returned as response. You can then receive
response from this channel.
There is a flag isSuccessful
on APIResponse
to check
if the request was successful or not. If the request was unsuccessful, you can check the status code
and message to determine the cause.
//Sending Person Enrich request which returns a channel of type `APIResponse`
ch := fcClient.PersonEnrich(personRequest)
resp := <-ch
fmt.Printf("Person Enrich API Response: %v", resp)
if resp.IsSuccessful == true {
fmt.Printf("Person Response: %v", *resp.PersonResponse)
fmt.Println(resp.PersonResponse.FullName)
}
To Enrich Company data FullContact library provides two methods Lookup by Company Domain or Search by Company Name. More data is available through the Lookup by Company Domain, but if the domain is unknown, use our Search by Company Name API to find the list of domains that could be related to the Company you are looking for and then call the Lookup by Company Domain with that domain to get the full information about the company.
- Request:
companyEnrichRequest, err := fc.NewCompanyRequest(fc.WithDomain("fullcontact.com"))
if err != nil {
log.Fatalln(err)
return
}
- Response:
resp := <-fcClient.CompanyEnrich(companyEnrichRequest)
fmt.Printf("Company Enrich API Response: %v", resp)
if resp.IsSuccessful {
fmt.Printf("Company Name: %v", resp.CompanyResponse.Name)
}
- Request:
- Parameters:
companyName
webhookUrl
location
locality
region
country
sort
- Parameters:
companySearchRequest, err := fc.NewCompanyRequest(fc.WithCompanyName("FullContact"))
if err != nil {
log.Fatalln(err)
return
}
- Response: It returns an array of
CompanySearchResponse
.
resp := <-fcClient.CompanySearch(companySearchRequest)
fmt.Printf("Company Search API Response: %v", resp)
if resp.IsSuccessful {
fmt.Printf("Company Lookup Domain: %v", resp.CompanySearchResponse[0].LookupDomain)
}
identity.map
identity.resolve
identity.delete
Resolve uses ResolveRequest
type for its request which supports
Multi Field Request: ability to match on one or many input fields
You can build a Resolve Request by using NewResolveRequest
and setting different input parameters that you have.
Note: For identity.map
any of email
, phone
, profile
, name & location
must be present.
API can lookup and resolve individuals by sending any identifiers you may already have, such as:
Emails
: []stringPhones
: []stringLocation
: *LocationAddressLine1
: stringAddressLine2
: stringCity
: stringRegion
: stringRegionCode
: stringPostalCode
: string
Name
: *PersonNameFull
: stringGiven
: stringFamily
: string
Profiles
: []*ProfileService
: stringUsername
: stringUserid
: stringUrl
: string
Maids
: []stringRecordId
: stringPersonId
: string
resolveRequest, err := fc.NewResolveRequest(
fc.WithRecordIdForResolve("r1"),
fc.WithEmailForResolve("bart@fullcontact.com"))
All resolve methods returns a channel
of type APIResponse
from which you can get ResolveResponse
resp := <-fcClient.IdentityMap(resolveRequest)
fmt.Printf("Identity Map API Response: %v", resp)
if resp.IsSuccessful {
fmt.Printf("RecordIds Mapped: %v", resp.ResolveResponse.RecordIds)
}
resp = <-fcClient.IdentityResolve(resolveRequest)
fmt.Printf("Identity Resolve API Response: %v", resp)
if resp.IsSuccessful {
fmt.Printf("PersonIds Mapped: %v", resp.ResolveResponse.PersonIds)
}
resp = <-fcClient.IdentityDelete(resolveRequest)
fmt.Printf("Identity Delete API Response: %v", resp)
if resp.IsSuccessful {
fmt.Println("Record Deleted Successfully!")
}