skiptrace

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 11 Imported by: 1 module, 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 skiptrace provides synchronous forward property skip tracing on the BatchData V3 API: POST /api/v3/property/skip-trace.

Construct a Service from a *batchdata.Client and call Trace:

tracer := skiptrace.New(client)
res, err := tracer.Trace(ctx, skiptrace.Request{Items: []skiptrace.Item{{
	PropertyAddress: skiptrace.Address{Street: "100 Example Ave", Zip: "00000"},
}}})

Importing this package pulls in only github.com/mrz1836/go-batchdata and the standard library.

Index

Examples

Constants

View Source
const MaxItems = 100

MaxItems is the largest number of items one request may carry.

Variables

This section is empty.

Functions

This section is empty.

Types

type AKA

type AKA struct {
	First  string `json:"first,omitempty"`
	Middle string `json:"middle,omitempty"`
	Last   string `json:"last,omitempty"`
	Full   string `json:"full,omitempty"`

	// Rank orders the entries, starting at 1; 0 means not reported.
	Rank int `json:"rank,omitempty"`
}

AKA is another name a person is known by.

type Address

type Address struct {
	Street string `json:"street,omitempty"`
	City   string `json:"city,omitempty"`
	State  string `json:"state,omitempty"`
	Zip    string `json:"zip,omitempty"`
}

Address is a postal address in a request. When set, Street is required.

type AddressValidity

type AddressValidity string

AddressValidity is the result of address validation. Values other than the documented constants are kept as sent.

const (
	AddressValid          AddressValidity = "Valid"
	AddressInvalid        AddressValidity = "Invalid"
	AddressPartiallyValid AddressValidity = "Partially Valid"
)

Documented address validity values.

type Association

type Association string

Association reports what links a record to a request item. Records are never linked by position, name or address.

const (
	// AssociationRequestID means the record's echoed Input.RequestID equals
	// the RequestID of exactly one item, and no other item's RequestID equals
	// it after trimming surrounding whitespace and folding case.
	AssociationRequestID Association = "request_id"

	// AssociationSingleItem means the request had one item and the response
	// one decodable record, and either the item had no RequestID or the
	// record echoed none.
	AssociationSingleItem Association = "single_item"

	// AssociationAmbiguous means the echoed RequestID equals the RequestID
	// of an item, but more than one item has that RequestID, or another
	// item's differs from it only in case or surrounding whitespace.
	AssociationAmbiguous Association = "ambiguous"

	// AssociationNone means there is no evidence linking the record to an
	// item.
	AssociationNone Association = "none"
)

Associations.

type Counts

type Counts struct {
	RequestCount *int `json:"requestCount,omitempty"`

	// MatchCount is the number of items BatchData bills: matched property
	// records with at least one person.
	MatchCount *int `json:"matchCount,omitempty"`

	NoMatchCount *int `json:"noMatchCount,omitempty"`
	ErrorCount   *int `json:"errorCount,omitempty"`
}

Counts are the provider's counts for a call. Nil means the provider did not report the count, which is not the same as zero.

type DateFormat

type DateFormat string

DateFormat selects the format of dates in a response.

const (
	// DateFormatISODateTime is an ISO 8601 date-time, such as
	// "1985-07-21T00:00:00.000Z". It is the provider's default.
	DateFormatISODateTime DateFormat = "iso-date-time"

	// DateFormatISODate is an ISO 8601 date, such as "1985-07-21".
	DateFormatISODate DateFormat = "iso-date"
)

Documented date formats.

type Email

type Email struct {
	// Rank is the presentation order, starting at 1; 0 means not reported.
	Rank  int    `json:"rank,omitempty"`
	Email string `json:"email,omitempty"`

	// Tested reports that the address is registered and unlikely to bounce.
	Tested *bool `json:"tested,omitempty"`
}

Email is an email address associated with a person.

type Input

type Input struct {
	// RequestID is the echoed Item.RequestID. The response schema does not
	// list it; BatchData's request ID correlation article describes the
	// echo.
	RequestID string `json:"requestId,omitempty"`

	PropertyAddress *InputAddress `json:"propertyAddress,omitempty"`
	MailingAddress  *InputAddress `json:"mailingAddress,omitempty"`
	Name            *Name         `json:"name,omitempty"`
	APN             string        `json:"apn,omitempty"`
	CountyFIPSCode  string        `json:"countyFipsCode,omitempty"`
	County          string        `json:"county,omitempty"`
	State           string        `json:"state,omitempty"`
}

Input is the provider's echo of a request item.

type InputAddress

type InputAddress struct {
	Hash              string          `json:"hash,omitempty"`
	AddressValidity   AddressValidity `json:"addressValidity,omitempty"`
	Street            string          `json:"street,omitempty"`
	City              string          `json:"city,omitempty"`
	State             string          `json:"state,omitempty"`
	Zip               string          `json:"zip,omitempty"`
	ZipPlus4          string          `json:"zipPlus4,omitempty"`
	County            string          `json:"county,omitempty"`
	CountyFIPSCode    string          `json:"countyFipsCode,omitempty"`
	HouseNumber       string          `json:"houseNumber,omitempty"`
	UnitType          string          `json:"unitType,omitempty"`
	UnitNumber        string          `json:"unitNumber,omitempty"`
	StreetNoUnit      string          `json:"streetNoUnit,omitempty"`
	FormattedStreet   string          `json:"formattedStreet,omitempty"`
	DeliveryPointCode string          `json:"deliveryPointCode,omitempty"`
	DPVMatchCode      string          `json:"dpvMatchCode,omitempty"`

	// DPVFootnotes is a single string in the provider's schema.
	DPVFootnotes  string `json:"dpvFootnotes,omitempty"`
	GeoStatus     string `json:"geoStatus,omitempty"`
	GeoStatusCode string `json:"geoStatusCode,omitempty"`

	// CityAliases, OldHashes and Localities are documented with at most two
	// entries; extra entries are kept.
	CityAliases []string `json:"cityAliases,omitzero"`
	OldHashes   []string `json:"oldHashes,omitzero"`
	Localities  []string `json:"localities,omitzero"`

	Latitude   *float64 `json:"latitude,omitempty"`
	Longitude  *float64 `json:"longitude,omitempty"`
	Normalized *bool    `json:"normalized,omitempty"`
}

InputAddress is the provider's echo of a request address, with the standardization it applied.

type Item

type Item struct {
	// RequestID is a caller-chosen identifier for the item. It is the only
	// evidence the SDK uses to link a returned record to a multi-item
	// request, and only when BatchData echoes it and it is unique among the
	// items (see Record.Association).
	RequestID string `json:"requestId,omitempty"`

	PropertyAddress Address `json:"propertyAddress,omitzero"`
	APN             string  `json:"apn,omitempty"`
	County          string  `json:"county,omitempty"`
	CountyFIPSCode  string  `json:"countyFipsCode,omitempty"`
	State           string  `json:"state,omitempty"`
	Name            Name    `json:"name,omitzero"`
	MailingAddress  Address `json:"mailingAddress,omitzero"`
}

Item identifies one property, by address or by assessor's parcel number (APN). An item must satisfy at least one documented combination:

  • PropertyAddress with Street, City, State and Zip;
  • PropertyAddress with Street and Zip;
  • PropertyAddress with Street, City and State;
  • APN, County and State;
  • APN and CountyFIPSCode.

Other fields may be set alongside a satisfied combination. Name and MailingAddress are optional extras, not lookup keys. Values are sent as given: the SDK never trims, normalizes or rewrites them. Instead, Request.Validate rejects a string that is not valid UTF-8 or is only whitespace, and a CountyFIPSCode that is not exactly 5 ASCII digits.

type Meta

type Meta struct {
	// APIVersion is the version the provider reports, such as "3.1.0".
	APIVersion string `json:"apiVersion,omitempty"`

	// CallRequestID is the provider's identifier for the whole call, for
	// support requests. It identifies the call, not an item.
	CallRequestID string `json:"requestId,omitempty"`

	// Results holds the provider's counts.
	Results Counts `json:"results,omitzero"`
}

Meta is the provider's metadata for a call.

type Name

type Name struct {
	First string `json:"first,omitempty"`
	Last  string `json:"last,omitempty"`
}

Name is a person's name in a request or in the provider's echo of one.

type Options

type Options struct {
	// IncludeTCPABlacklistedPhones includes phones with TCPA restrictions,
	// each flagged by Phone.TCPA, when true, and filters them out when false.
	IncludeTCPABlacklistedPhones *bool `json:"includeTCPABlacklistedPhones,omitempty"`

	// PrioritizeMobilePhones lists mobile numbers first in each person's
	// phones when true (the documented default), and leaves the order alone
	// when false.
	PrioritizeMobilePhones *bool `json:"prioritizeMobilePhones,omitempty"`

	// DateFormat selects the format of Person.DOB.
	DateFormat DateFormat `json:"dateFormat,omitempty"`
}

Options control processing and formatting for every item of a request. A nil pointer omits the option, so the provider's default applies; the SDK never injects a default of its own.

BatchData documents includeTCPABlacklistedPhones as defaulting to true, but also says that phones with tcpa=true are excluded when it is not specified. Set IncludeTCPABlacklistedPhones explicitly when the difference matters.

type Outcome

type Outcome string

Outcome summarizes a record. The empty string is never a valid outcome.

const (
	// OutcomeFailed means the provider set meta.error to true, whatever
	// meta.matched says. BatchData documents no detail for it.
	OutcomeFailed Outcome = "failed"

	// OutcomeMatched means the provider set meta.matched to true: it found
	// data for the property. It does not mean the persons are the one named
	// in Item.Name, which is not a lookup key; compare each person's
	// Name, its AKAs included, with the name you hold.
	OutcomeMatched Outcome = "matched"

	// OutcomeNoMatch means the provider set meta.matched to false: a valid
	// answer, not an error.
	OutcomeNoMatch Outcome = "no_match"

	// OutcomeUnreported means the provider sent no meta.matched flag.
	OutcomeUnreported Outcome = "unreported"

	// OutcomeUndecodable means the record was null, not an object, or held a
	// value of the wrong type. Nothing of it is kept: its Association is
	// AssociationNone and every other field is zero.
	OutcomeUndecodable Outcome = "undecodable"
)

Record outcomes. OutcomeUndecodable is decided first; the others follow the precedence error, then matched, then an absent flag.

type Owner

type Owner struct {
	Name PersonName `json:"name,omitzero"`
}

Owner is an owner of record on the property.

type Person

type Person struct {
	// PropertyOwner is true when the person's name matched an owner of
	// record, which is not proof of ownership, and false when owner names
	// were compared and none matched. Nil means ownership could not be
	// evaluated.
	PropertyOwner *bool `json:"propertyOwner,omitempty"`

	Name      PersonName      `json:"name,omitzero"`
	Addresses []PersonAddress `json:"addresses,omitzero"`
	Phones    []Phone         `json:"phones,omitzero"`
	Emails    []Email         `json:"emails,omitzero"`

	// Litigator reports whether the person is on the known TCPA litigators
	// list. It is informational and filters nothing.
	Litigator *bool `json:"litigator,omitempty"`

	// Deceased is true when records show the person as deceased. Nil means
	// no value is on file.
	Deceased *bool `json:"deceased,omitempty"`

	// DOB is the date of birth as sent: an ISO 8601 date-time by default, or
	// a date with DateFormatISODate. The SDK never parses it. Nil means no
	// value is on file.
	DOB *string `json:"dob,omitempty"`
}

Person is a person found for the property, with contact data.

The flags are provider observations, not consent or compliance decisions.

type PersonAddress

type PersonAddress struct {
	PostalAddress

	// Rank is the presentation order, starting at 1, not a measured
	// confidence; 0 means not reported.
	Rank int `json:"rank,omitempty"`

	// PropertyMailingAddress reports whether this is the mailing address of
	// the property.
	PropertyMailingAddress *bool `json:"propertyMailingAddress,omitempty"`
}

PersonAddress is an address associated with a person.

type PersonName

type PersonName struct {
	First  string `json:"first,omitempty"`
	Middle string `json:"middle,omitempty"`
	Last   string `json:"last,omitempty"`
	Full   string `json:"full,omitempty"`
	AKAs   []AKA  `json:"akas,omitzero"`
}

PersonName is a person's name and the other names they are known by.

type Phone

type Phone struct {
	// Rank is the presentation order, starting at 1, not a probability of
	// reaching the person; 0 means not reported.
	Rank int `json:"rank,omitempty"`

	// Number is the 10-digit number as sent.
	Number  string    `json:"number,omitempty"`
	Type    PhoneType `json:"type,omitempty"`
	Carrier string    `json:"carrier,omitempty"`

	// Tested reports a successful connection in the last six months.
	Tested *bool `json:"tested,omitempty"`

	// Reachable reports a successful reach in the last three months.
	Reachable *bool `json:"reachable,omitempty"`

	// DNC reports registration on the national Do Not Call Registry.
	DNC *bool `json:"dnc,omitempty"`

	// TCPA reports TCPA restrictions. BatchData sends it only when
	// IncludeTCPABlacklistedPhones is true; nil means not reported, which is
	// not the same as false.
	TCPA *bool `json:"tcpa,omitempty"`
}

Phone is a phone number associated with a person.

type PhoneType

type PhoneType string

PhoneType is the type of a phone line. Values other than the documented constants are kept as sent.

const (
	PhoneTypeMobile   PhoneType = "Mobile"
	PhoneTypeLandLine PhoneType = "Land Line"
	PhoneTypeVoIP     PhoneType = "VoIP"
)

Documented phone types.

type PostalAddress

type PostalAddress struct {
	Hash            string          `json:"hash,omitempty"`
	AddressValidity AddressValidity `json:"addressValidity,omitempty"`
	FullAddress     string          `json:"fullAddress,omitempty"`
	Street          string          `json:"street,omitempty"`
	City            string          `json:"city,omitempty"`
	County          string          `json:"county,omitempty"`
	State           string          `json:"state,omitempty"`
	Zip             string          `json:"zip,omitempty"`
	ZipPlus4        string          `json:"zipPlus4,omitempty"`
}

PostalAddress is a standardized address in a response.

PersonAddress embeds it, so it must never gain a custom JSON marshaler or unmarshaler: one would be promoted and replace PersonAddress's own fields.

type Property

type Property struct {
	ID             string         `json:"id,omitempty"`
	Address        *PostalAddress `json:"address,omitempty"`
	MailingAddress *PostalAddress `json:"mailingAddress,omitempty"`
	Owners         []Owner        `json:"owners,omitzero"`
}

Property is the property the provider matched.

type Record

type Record struct {
	// ItemIndex is the index in Request.Items of the item this record is
	// linked to, or nil unless Association is AssociationRequestID or
	// AssociationSingleItem.
	ItemIndex *int `json:"itemIndex,omitempty"`

	// Association reports what links this record to an item.
	Association Association `json:"association"`

	// Outcome summarizes the record's meta flags.
	Outcome Outcome `json:"outcome"`

	// Input is the provider's echo of the request item.
	Input Input `json:"input,omitzero"`

	// Property is the matched property, or nil when none was returned.
	Property *Property `json:"property,omitempty"`

	// Persons are the persons found for the property. A no-match record
	// keeps an empty, non-nil slice when the provider sent one.
	Persons []Person `json:"persons,omitzero"`

	// Meta holds the provider's per-record flags.
	Meta RecordMeta `json:"meta,omitzero"`
}

Record is the provider's answer for one property.

type RecordMeta

type RecordMeta struct {
	Matched *bool `json:"matched,omitempty"`
	Error   *bool `json:"error,omitempty"`
}

RecordMeta holds a record's flags. Nil means the provider did not send the flag.

type Request

type Request struct {
	Items   []Item  `json:"requests"`
	Options Options `json:"options,omitzero"`
}

Request is one synchronous skip-trace call: 1 to MaxItems items and the options that apply to all of them. Each item is one property lookup.

func (Request) Validate

func (r Request) Validate() error

Validate reports the first problem with r as a *batchdata.ValidationError matching batchdata.ErrInvalidRequest, or nil. It performs no I/O and never modifies r.

It checks, in order and stopping at the first problem:

  • that r has 1 to MaxItems items; an out-of-range count is reported alone, without inspecting the items;
  • each item in index order: every string field, in declaration order, is valid UTF-8 and either empty or not only whitespace (as defined by unicode.IsSpace); a non-zero PropertyAddress or MailingAddress has a Street; a non-empty CountyFIPSCode is exactly 5 ASCII digits; and the item satisfies at least one combination documented on Item;
  • that Options.DateFormat is empty or a documented DateFormat.

Duplicate RequestIDs are allowed. The error's Field is a Go field path such as "Items[3].PropertyAddress.Street"; neither it nor the Reason contains a value from r.

type Result

type Result struct {
	// Records holds one entry per element of the provider's data array.
	Records []Record `json:"records"`

	// Options are the options the provider reports it applied.
	Options Options `json:"options,omitzero"`

	// Meta is the provider's metadata for the whole call.
	Meta Meta `json:"meta,omitzero"`

	// Warnings are the envelope's status.warnings, then its top-level
	// warnings, in order.
	Warnings []batchdata.Warning `json:"warnings,omitzero"`
}

Result is the decoded response of a successful call. Records keep the provider's order and are never reordered, deduplicated or truncated.

A Result holds personal data. Access control, logging, retention and lawful use are the caller's responsibility.

func (*Result) RecordsFor

func (r *Result) RecordsFor(itemIndex int) []Record

RecordsFor returns the records linked to Items[itemIndex], in provider order: those whose ItemIndex equals itemIndex. Records with a nil ItemIndex are never returned. It returns nil when there are none, including for a negative or out of range index or a nil Result.

The returned slice is new, so changing it leaves r.Records alone, but each element is a shallow copy that shares its pointers and slices with r.

Example

Several properties: records are linked to items only by an echoed request ID that is unique among the items, never by position.

package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"net/http/httptest"

	"github.com/mrz1836/go-batchdata"
	"github.com/mrz1836/go-batchdata/skiptrace"
)

// exampleServer serves body from a local TLS server, standing in for
// BatchData so that the examples run offline.
func exampleServer(body string) *httptest.Server {
	return httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
		_, _ = io.WriteString(w, body)
	}))
}

func main() {
	srv := exampleServer(`{"status":{"code":200},"result":{"data":[` +
		`{"input":{"requestId":"row-2"},"persons":[],"meta":{"matched":false,"error":false}},` +
		`{"input":{"requestId":"row-1"},"persons":[{"name":{"full":"Sample Person"}}],"meta":{"matched":true,"error":false}}]}}`)
	defer srv.Close()

	client, err := batchdata.NewClient("EXAMPLE-KEY-0000",
		batchdata.WithHTTPClient(srv.Client()), batchdata.WithTestEndpoint(srv.URL))
	if err != nil {
		fmt.Println(err)
		return
	}
	req := skiptrace.Request{Items: []skiptrace.Item{
		{RequestID: "row-1", PropertyAddress: skiptrace.Address{Street: "100 Example Ave", City: "Testville", State: "ZZ"}},
		{RequestID: "row-2", APN: "000-000-0000", CountyFIPSCode: "00000"},
	}}
	res, err := skiptrace.New(client).Trace(context.Background(), req)
	if err != nil {
		fmt.Println(err)
		return
	}
	for i, item := range req.Items {
		for _, rec := range res.RecordsFor(i) {
			fmt.Println(item.RequestID, rec.Outcome, len(rec.Persons))
		}
	}
}
Output:
row-1 matched 1
row-2 no_match 0

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service makes synchronous property skip-trace calls. It is immutable and safe for concurrent use.

func New

func New(client *batchdata.Client) *Service

New returns a Service that calls through client. A nil or zero client yields a Service whose every call fails with batchdata.ErrInvalidConfig and makes no request.

func (*Service) Trace

func (s *Service) Trace(ctx context.Context, req Request) (*Result, error)

Trace makes one synchronous skip-trace call for req and returns the decoded records.

Before any request it checks, in order: the Service and its client (batchdata.ErrInvalidConfig), ctx (batchdata.ErrInvalidRequest when nil), req.Validate, and the size of the encoded request (batchdata.ErrInvalidRequest above batchdata.MaxRequestBytes). A context that is already done fails with its error as a *batchdata.Error. None of these make a call.

Otherwise Trace makes exactly one HTTP attempt: it never retries, follows a redirect, or splits the request. Every other error is a *batchdata.Error, and the call may already have been processed and billed: do not resend blindly. Records with OutcomeNoMatch, OutcomeFailed, OutcomeUnreported or OutcomeUndecodable are part of a successful Result, never an error.

Example

One property: a request with a single item. With one item and one record, the record is linked to the item by elimination.

package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"net/http/httptest"

	"github.com/mrz1836/go-batchdata"
	"github.com/mrz1836/go-batchdata/skiptrace"
)

// exampleServer serves body from a local TLS server, standing in for
// BatchData so that the examples run offline.
func exampleServer(body string) *httptest.Server {
	return httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
		_, _ = io.WriteString(w, body)
	}))
}

func main() {
	srv := exampleServer(`{"status":{"code":200},"result":{"data":[{"persons":[` +
		`{"name":{"full":"Sample Person"},"phones":[{"rank":1,"number":"2025550100","type":"Mobile","dnc":false}]}],` +
		`"meta":{"matched":true,"error":false}}],"meta":{"results":{"matchCount":1}}}}`)
	defer srv.Close()

	client, err := batchdata.NewClient("EXAMPLE-KEY-0000",
		batchdata.WithHTTPClient(srv.Client()), batchdata.WithTestEndpoint(srv.URL))
	if err != nil {
		fmt.Println(err)
		return
	}
	res, err := skiptrace.New(client).Trace(context.Background(), skiptrace.Request{Items: []skiptrace.Item{{
		PropertyAddress: skiptrace.Address{Street: "100 Example Ave", Zip: "00000"},
	}}})
	if err != nil {
		fmt.Println(err)
		return
	}
	for _, rec := range res.RecordsFor(0) {
		fmt.Println(rec.Outcome, rec.Association)
		for _, p := range rec.Persons {
			for _, ph := range p.Phones {
				// Flags are pointers: nil means BatchData did not report it.
				dnc := "not reported"
				if ph.DNC != nil {
					dnc = fmt.Sprint(*ph.DNC)
				}
				fmt.Println(p.Name.Full, ph.Rank, ph.Type, "DNC:", dnc, "TCPA reported:", ph.TCPA != nil)
			}
		}
	}
	if n := res.Meta.Results.MatchCount; n != nil {
		fmt.Println("billed:", *n)
	}
}
Output:
matched single_item
Sample Person 1 Mobile DNC: false TCPA reported: false
billed: 1

Jump to

Keyboard shortcuts

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