fed

package module
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

Moov Banner Logo

Project Documentation · API Endpoints · API Guide · Community · Blog

GoDoc Build Status Coverage Status Go Report Card Repo Size Apache 2 License Slack Channel Docker Pulls GitHub Stars Twitter

moov-io/fed

Moov's mission is to give developers an easy way to create and integrate bank processing into their own software products. Our open source projects are each focused on solving a single responsibility in financial services and designed around performance, scalability, and ease of use.

Fed implements utility services for searching the United States Federal Reserve System such as ABA routing numbers, financial institution name lookup, and Fedwire and FedACH routing information. The HTTP server is available in a Docker image and the Go package github.com/moov-io/fed is available. Moov's primary usage for this project is with ACH origination in our paygate project.

The data and formats in this repository represent a compilation of FedWire and FedACH data from the Federal Reserve Bank Services site. Both the official Fed plaintext and JSON file formats are supported.

Table of contents

Project status

Moov Fed is actively used in multiple production environments. Please star the project if you are interested in its progress. We would appreciate any issues created or pull requests. Thanks!

Usage

The Fed project implements an HTTP server and Go library for searching for FedACH and Fedwire participants.

Note: The data files included in this repository (FedACHdir.md and fpddir.md) are outdated and from 2018. The Fed no longer releases this data publicly and licensing on more recent files prevents us from distributing them. However, the Fed still complies this data and you can retrieve up-to-date files for use in our project, either from LexisNexis or your financial institution.

Moov Fed can read the data files from anywhere on the filesystem. This allows you to mount the files and set FEDACH_DATA_PATH / FEDWIRE_DATA_PATH environmental variables. Both official formats from the Federal Reserve (plaintext and JSON) are supported.

Download files

The Federal Reserve Board (FRB) eServices offers API access to download the files. To download these files, work with your ODFI / banking partner to obtain a download code. Then run Fed with the following environment variables set.

FRB_ROUTING_NUMBER=123456780
FRB_DOWNLOAD_CODE=86cfa5a9-1ab9-4af5-bd89-0f84d546de13
Download files from proxy

Fed can download the files from a proxy or other HTTP resources. The optional URL template is configured as an environment variable. If the URL template is not configured, Fed will download the files directly from FRB eServices by default. This value is considered a template because when preparing the request Fed replaces %s in the path with the requested list name(fedach or fedwire).

FRB_DOWNLOAD_URL_TEMPLATE=https://my.example.com/files/%s?format=json
Docker

We publish a public Docker image moov/fed from Docker Hub or use this repository. No configuration is required to serve on :8086 and metrics at :9096/metrics in Prometheus format. We also have Docker images for OpenShift published as quay.io/moov/fed.

Pull & start the Docker image:

docker pull moov/fed:latest
docker run -p 8086:8086 -p 9096:9096 moov/fed:latest
ACH routing number example

Fed can be used to look up Financial Institutions for Automated Clearing House (ACH) transfers by their routing number (?routingNumber=...):

curl "localhost:8086/fed/ach/search?routingNumber=273976369"
{
  "achParticipants": [
    {
      "routingNumber": "273976369",
      "officeCode": "O",
      "servicingFRBNumber": "071000301",
      "recordTypeCode": "1",
      "revised": "041513",
      "newRoutingNumber": "000000000",
      "customerName": "VERIDIAN CREDIT UNION",
      "achLocation": {
        "address": "1827 ANSBOROUGH",
        "city": "WATERLOO",
        "state": "IA",
        "postalCode": "50702",
        "postalCodeExtension": "0000"
      },
      "phoneNumber": "3192878332",
      "statusCode": "1",
      "viewCode": "1"
    }
  ],
  "wireParticipants": null
}
Wire routing number example

Fed can be used to look up Financial Institutions for Fedwire messages by their routing number (?routingNumber=...):

curl "localhost:8086/fed/wire/search?routingNumber=273976369"
{
  "achParticipants": null,
  "wireParticipants": [
    {
      "routingNumber": "273976369",
      "telegraphicName": "VERIDIAN",
      "customerName": "VERIDIAN CREDIT UNION",
      "wireLocation": {
        "city": "WATERLOO",
        "state": "IA"
      },
      "fundsTransferStatus": "Y",
      "fundsSettlementOnlyStatus": " ",
      "bookEntrySecuritiesTransferStatus": "N",
      "date": "20141107"
    }
  ]
}
Google Cloud Run

To get started in a hosted environment you can deploy this project to the Google Cloud Platform.

From your Google Cloud dashboard create a new project and call it:

moov-fed-demo

Enable the Container Registry API for your project and associate a billing account if needed. Then, open the Cloud Shell terminal and run the following Docker commands, substituting your unique project ID:

docker pull moov/fed
docker tag moov/fed gcr.io/<PROJECT-ID>/fed
docker push gcr.io/<PROJECT-ID>/fed

Deploy the container to Cloud Run:

gcloud run deploy --image gcr.io/<PROJECT-ID>/fed --port 8086

Select your target platform to 1, service name to fed, and region to the one closest to you (enable Google API service if a prompt appears). Upon a successful build you will be given a URL where the API has been deployed:

https://YOUR-FED-APP-URL.a.run.app

Now you can ping the server:

curl https://YOUR-FED-APP-URL.a.run.app/ping

You should get this response:

PONG
Configuration settings
Environmental Variable Description Default
FEDACH_DATA_PATH Filepath to FedACH data file ./data/FedACHdir.txt
FEDWIRE_DATA_PATH Filepath to Fedwire data file ./data/fpddir.txt
FRB_ROUTING_NUMBER Federal Reserve Board eServices (ABA) routing number used to download FedACH and FedWire files Empty
FRB_DOWNLOAD_CODE Federal Reserve Board eServices (ABA) download code used to download FedACH and FedWire files Empty
FRB_DOWNLOAD_URL_TEMPLATE URL Template for downloading files from alternate source https://frbservices.org/EPaymentsDirectory/directories/%s?format=json
LOG_FORMAT Format for logging lines to be written as. Options: json, plain - Default: plain
HTTP_BIND_ADDRESS Address for Fed to bind its HTTP server on. This overrides the command-line flag -http.addr. Default: :8086
HTTP_ADMIN_BIND_ADDRESS Address for Fed to bind its admin HTTP server on. This overrides the command-line flag -admin.addr. Default: :9096
HTTPS_CERT_FILE Filepath containing a certificate (or intermediate chain) to be served by the HTTP server. Requires all traffic be over secure HTTP. Empty
HTTPS_KEY_FILE Filepath of a private key matching the leaf certificate from HTTPS_CERT_FILE. Empty
Logos
Environmental Variable Description Default
CLEARBIT_API_KEY API key for connecting to Clearbit for logo requests. Empty
LOGO_CACHE_SIZE Maximum size for an in-memory cache of logos. Empty
Data persistence

By design, Fed does not persist (save) any data about the search queries created. The only storage occurs in memory of the process and upon restart Fed will have no files or data saved. Also, no in-memory encryption of the data is performed.

Go library

This project uses Go Modules and Go v1.18 or newer. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

$ git@github.com:moov-io/fed.git

# Pull down into the Go Module cache
$ go get -u github.com/moov-io/fed

$ go doc github.com/moov-io/fed ACHDictionary

Learn about Fed services participation

Getting help

channel info
Project Documentation Our project documentation available online.
Twitter @moov You can follow Moov.io's Twitter feed to get updates on our project(s). You can also tweet us questions or just share blogs or stories.
GitHub Issue If you are able to reproduce a problem please open a GitHub Issue under the specific project that caused the error.
moov-io slack Join our slack channel to have an interactive discussion about the development of the project.

Supported and tested platforms

  • 64-bit Linux (Ubuntu, Debian), macOS, and Windows

Note: 32-bit platforms have known issues and are not supported.

Contributing

Yes please! Please review our Contributing guide and Code of Conduct to get started!

This project uses Go Modules and Go v1.18 or newer. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

Releasing

To make a release of fed simply open a pull request with CHANGELOG.md and version.go updated with the next version number and details. You'll also need to push the tag (i.e. git push origin v1.0.0) to origin in order for CI to make the release.

Testing

We maintain a comprehensive suite of unit tests and recommend table-driven testing when a particular function warrants several very similar test cases. To run all test files in the current directory, use go test. Current overall coverage can be found on Codecov.

As part of Moov's initiative to offer open source fintech infrastructure, we have a large collection of active projects you may find useful:

  • Moov Watchman offers search functions over numerous trade sanction lists from the United States and European Union.

  • Moov Image Cash Letter implements Image Cash Letter (ICL) files used for Check21, X.9 or check truncation files for exchange and remote deposit in the U.S.

  • Moov Wire implements an interface to write files for the Fedwire Funds Service, a real-time gross settlement funds transfer system operated by the United States Federal Reserve Banks.

  • Moov ACH provides ACH file generation and parsing, supporting all Standard Entry Codes for the primary method of money movement throughout the United States.

  • Moov Metro 2 provides a way to easily read, create, and validate Metro 2 format, which is used for consumer credit history reporting by the United States credit bureaus.

(c) Federal Reserve Banks

By accessing the data in this repository you agree to the Federal Reserve Banks' Terms of Use and the E-Payments Routing Directory Terms of Use Agreement.

Disclaimer

THIS REPOSITORY IS NOT AFFILIATED WITH THE FEDERAL RESERVE BANKS AND IS NOT AN OFFICIAL SOURCE FOR FEDWIRE AND FEDACH DATA.

License

Apache License 2.0 - See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	// ACHLineLength is the FedACH text file line length
	ACHLineLength = 155
	// WIRELineLength is the FedACH text file line length
	WIRELineLength = 101
	// MinimumRoutingNumberDigits is the minimum number of digits needed searching by routing numbers
	MinimumRoutingNumberDigits = 2
	// MaximumRoutingNumberDigits is the maximum number of digits allowed for searching by routing number
	// Based on https://www.frbservices.org/EPaymentsDirectory/search.html
	MaximumRoutingNumberDigits = 9
)
View Source
const Version = "v0.11.1"

Version is the current version

Variables

View Source
var (
	// ACHJaroWinklerSimilarity is the search similarity percentage for strcmp.JaroWinkler for CustomerName
	// (Financial Institution Name)
	ACHJaroWinklerSimilarity = 0.85
	// ACHLevenshteinSimilarity is the search similarity percentage for strcmp.Levenshtein for CustomerName
	// (Financial Institution Name)
	ACHLevenshteinSimilarity = 0.85
)
View Source
var (
	// WIREJaroWinklerSimilarity is the search similarity percentage for strcmp.JaroWinkler for CustomerName
	// (Financial Institution Name)
	WIREJaroWinklerSimilarity = 0.85
	// WIRELevenshteinSimilarity is the search similarity percentage for strcmp.Levenshtein for CustomerName
	// (Financial Institution Name)
	WIRELevenshteinSimilarity = 0.85
)
View Source
var (
	ErrFileTooLong = errors.New("file exceeds maximum possible number of lines")
	// Similar to FEDACH site
	ErrRoutingNumberNumeric = errors.New("the routing number entered is not numeric")
)

ErrFileTooLong is the error given when a file exceeds the maximum possible length

Functions

func Normalize added in v0.8.0

func Normalize(name string) string

func RemoveDuplicatedSpaces added in v0.8.0

func RemoveDuplicatedSpaces(name string) string

func StripSymbols added in v0.8.0

func StripSymbols(name string) string

func StripWaste added in v0.8.0

func StripWaste(name string) string

Types

type ACHDictionary

type ACHDictionary struct {
	// Participants is a list of Participant structs
	ACHParticipants []*ACHParticipant
	// IndexACHRoutingNumber creates an index of ACHParticipants keyed by ACHParticipant.RoutingNumber
	IndexACHRoutingNumber map[string]*ACHParticipant
	// IndexACHCustomerName creates an index of ACHParticipants keyed by ACHParticipant.CustomerName
	IndexACHCustomerName map[string][]*ACHParticipant
	// contains filtered or unexported fields
}

ACHDictionary of Participant records

func NewACHDictionary

func NewACHDictionary() *ACHDictionary

NewACHDictionary creates a ACHDictionary

func (*ACHDictionary) ACHParticipantCityFilter

func (f *ACHDictionary) ACHParticipantCityFilter(achParticipants []*ACHParticipant, s string) []*ACHParticipant

ACHParticipantCityFilter filters ACHParticipant by City

func (*ACHDictionary) ACHParticipantPostalCodeFilter

func (f *ACHDictionary) ACHParticipantPostalCodeFilter(achParticipants []*ACHParticipant, s string) []*ACHParticipant

ACHParticipantPostalCodeFilter filters ACHParticipant by Postal Code.

func (*ACHDictionary) ACHParticipantRoutingNumberFilter

func (f *ACHDictionary) ACHParticipantRoutingNumberFilter(achParticipants []*ACHParticipant, s string) ([]*ACHParticipant, error)

ACHParticipantRoutingNumberFilter filters ACHParticipant by Routing Number

func (*ACHDictionary) ACHParticipantStateFilter

func (f *ACHDictionary) ACHParticipantStateFilter(achParticipants []*ACHParticipant, s string) []*ACHParticipant

ACHParticipantStateFilter filters ACHParticipant by State.

func (*ACHDictionary) CityFilter

func (f *ACHDictionary) CityFilter(s string) []*ACHParticipant

CityFilter filters ACHDictionary.ACHParticipant by city

func (*ACHDictionary) FinancialInstitutionSearch

func (f *ACHDictionary) FinancialInstitutionSearch(s string, limit int) []*ACHParticipant

FinancialInstitutionSearch returns a FEDACH participant based on a ACHParticipant.CustomerName

func (*ACHDictionary) FinancialInstitutionSearchSingle

func (f *ACHDictionary) FinancialInstitutionSearchSingle(s string) []*ACHParticipant

FinancialInstitutionSearchSingle returns FEDACH participants based on a ACHParticipant.CustomerName

func (*ACHDictionary) PostalCodeFilter

func (f *ACHDictionary) PostalCodeFilter(s string) []*ACHParticipant

PostalCodeFilter filters ACHParticipant by postal code

func (*ACHDictionary) Read

func (f *ACHDictionary) Read(r io.Reader) error

Read parses a single line or multiple lines of FedACHdir text

func (*ACHDictionary) RoutingNumberSearch

func (f *ACHDictionary) RoutingNumberSearch(s string, limit int) ([]*ACHParticipant, error)

RoutingNumberSearch returns FEDACH participants if ACHParticipant.RoutingNumber begins with prefix string s. The first 2 digits of the routing number are required. Based on https://www.frbservices.org/EPaymentsDirectory/search.html

func (*ACHDictionary) RoutingNumberSearchSingle

func (f *ACHDictionary) RoutingNumberSearchSingle(s string) *ACHParticipant

RoutingNumberSearchSingle returns a FEDACH participant based on a ACHParticipant.RoutingNumber. Routing Number validation is only that it exists in IndexParticipant. Expecting a valid 9 digit routing number.

func (*ACHDictionary) StateFilter

func (f *ACHDictionary) StateFilter(s string) []*ACHParticipant

StateFilter filters ACHDictionary.ACHParticipant by state

type ACHLocation

type ACHLocation struct {
	// Address
	Address string `json:"address"`
	// City
	City string `json:"city"`
	// State
	State string `json:"state"`
	// PostalCode
	PostalCode string `json:"postalCode"`
	// PostalCodeExtension
	PostalCodeExtension string `json:"postalCodeExtension"`
}

ACHLocation is the institution's delivery address

type ACHParticipant

type ACHParticipant struct {
	// RoutingNumber The institution's routing number
	RoutingNumber string `json:"routingNumber"`
	// OfficeCode Main/Head Office or Branch. O=main B=branch
	OfficeCode string `json:"officeCode"`
	// ServicingFRBNumber Servicing Fed's main office routing number
	ServicingFRBNumber string `json:"servicingFRBNumber"`
	// RecordTypeCode The code indicating the ABA number to be used to route or send ACH items to the RDFI
	// 0 = Institution is a Federal Reserve Bank
	// 1 = Send items to customer routing number
	// 2 = Send items to customer using new routing number field
	RecordTypeCode string `json:"recordTypeCode"`
	// Revised Date of last revision: YYYYMMDD, or blank
	Revised string `json:"revised"`
	// NewRoutingNumber Institution's new routing number resulting from a merger or renumber
	NewRoutingNumber string `json:"newRoutingNumber"`
	// CustomerName (36): FEDERAL RESERVE BANK
	CustomerName string `json:"customerName"`
	// Location is the delivery address
	ACHLocation `json:"achLocation"`
	// PhoneNumber The institution's phone number
	PhoneNumber string `json:"phoneNumber"`
	// StatusCode Code is based on the customers receiver code
	// 1 = Receives Gov/Comm
	StatusCode string `json:"statusCode"`
	// ViewCode is current view
	// 1 = Current view
	ViewCode string `json:"viewCode"`

	// CleanName is our cleaned up value of CustomerName
	CleanName string `json:"cleanName"`
	Logo *logos.Logo `json:"logo"`
}

ACHParticipant holds a FedACH dir routing record as defined by Fed ACH Format https://www.frbservices.org/EPaymentsDirectory/achFormat.html

func (*ACHParticipant) CustomerNameLabel

func (p *ACHParticipant) CustomerNameLabel() string

CustomerNameLabel returns a formatted string Title for displaying ACHParticipant.CustomerName

type RecordWrongLengthErr

type RecordWrongLengthErr struct {
	Message        string
	LengthRequired int
	Length         int
}

RecordWrongLengthErr is the error given when a record is the wrong length

func NewRecordWrongLengthErr

func NewRecordWrongLengthErr(lengthRequired int, length int) RecordWrongLengthErr

NewRecordWrongLengthErr creates a new error of the RecordWrongLengthErr type

func (RecordWrongLengthErr) Error

func (e RecordWrongLengthErr) Error() string

type WIREDictionary

type WIREDictionary struct {
	// Participants is a list of Participant structs
	WIREParticipants []*WIREParticipant
	// IndexWIRERoutingNumber creates an index of WIREParticipants keyed by WIREParticipant.RoutingNumber
	IndexWIRERoutingNumber map[string]*WIREParticipant
	// IndexWIRECustomerName creates an index of WIREParticipants keyed by WIREParticipant.CustomerName
	IndexWIRECustomerName map[string][]*WIREParticipant
	// contains filtered or unexported fields
}

WIREDictionary of Participant records

func NewWIREDictionary

func NewWIREDictionary() *WIREDictionary

NewWIREDictionary creates a WIREDictionary

func (*WIREDictionary) CityFilter

func (f *WIREDictionary) CityFilter(s string) []*WIREParticipant

CityFilter filters WIREDictionary.WIREParticipant by city

func (*WIREDictionary) FinancialInstitutionSearch

func (f *WIREDictionary) FinancialInstitutionSearch(s string, limit int) []*WIREParticipant

FinancialInstitutionSearch returns a FEDWIRE participant based on a WIREParticipant.CustomerName

func (*WIREDictionary) FinancialInstitutionSearchSingle

func (f *WIREDictionary) FinancialInstitutionSearchSingle(s string) []*WIREParticipant

FinancialInstitutionSearchSingle returns a FEDWIRE participant based on a WIREParticipant.CustomerName

func (*WIREDictionary) Read

func (f *WIREDictionary) Read(r io.Reader) error

Read parses a single line or multiple lines of FedWIREdir text

func (*WIREDictionary) RoutingNumberSearch

func (f *WIREDictionary) RoutingNumberSearch(s string, limit int) ([]*WIREParticipant, error)

RoutingNumberSearch returns FEDWIRE participants if WIREParticipant.RoutingNumber begins with prefix string s. The first 2 digits of the routing number are required. Based on https://www.frbservices.org/EPaymentsDirectory/search.html

func (*WIREDictionary) RoutingNumberSearchSingle

func (f *WIREDictionary) RoutingNumberSearchSingle(s string) *WIREParticipant

RoutingNumberSearchSingle returns a FEDWIRE participant based on a WIREParticipant.RoutingNumber. Routing Number validation is only that it exists in IndexParticipant. Expecting 9 digits, checksum needs to be included.

func (*WIREDictionary) StateFilter

func (f *WIREDictionary) StateFilter(s string) []*WIREParticipant

StateFilter filters WIREDictionary.WIREParticipant by state

func (*WIREDictionary) WIREParticipantCityFilter

func (f *WIREDictionary) WIREParticipantCityFilter(wireParticipants []*WIREParticipant, s string) []*WIREParticipant

WIREParticipantCityFilter filters WIREParticipant by City

func (*WIREDictionary) WIREParticipantRoutingNumberFilter

func (f *WIREDictionary) WIREParticipantRoutingNumberFilter(wireParticipants []*WIREParticipant, s string) ([]*WIREParticipant, error)

WIREParticipantRoutingNumberFilter filters WIREParticipant by Routing Number

func (*WIREDictionary) WIREParticipantStateFilter

func (f *WIREDictionary) WIREParticipantStateFilter(wireParticipants []*WIREParticipant, s string) []*WIREParticipant

WIREParticipantStateFilter filters WIREParticipant by State.

type WIRELocation

type WIRELocation struct {
	// City
	City string `json:"city"`
	// State
	State string `json:"state"`
}

WIRELocation is the city and state

type WIREParticipant

type WIREParticipant struct {
	// RoutingNumber The institution's routing number
	RoutingNumber string `json:"routingNumber"`
	// TelegraphicName is the short name of financial institution  Wells Fargo
	TelegraphicName string `json:"telegraphicName"`
	// CustomerName (36): FEDERAL RESERVE BANK
	CustomerName string `json:"customerName"`
	// Location is the city and state
	WIRELocation `json:"wireLocation"`
	// FundsTransferStatus designates funds transfer status
	// Y - Eligible
	// N - Ineligible
	FundsTransferStatus string `json:"fundsTransferStatus"`
	// FundsSettlementOnlyStatus designates funds settlement only status
	// S - Settlement-Only
	FundsSettlementOnlyStatus string `json:"fundsSettlementOnlyStatus"`
	// BookEntrySecuritiesTransferStatus designates book entry securities transfer status
	BookEntrySecuritiesTransferStatus string `json:"bookEntrySecuritiesTransferStatus"`
	// Date of last revision: YYYYMMDD, or blank
	Date string `json:"date"`

	// CleanName is our cleaned up value of CustomerName
	CleanName string `json:"cleanName"`
	Logo *logos.Logo `json:"logo"`
}

WIREParticipant holds a FedWIRE dir routing record as defined by Fed WIRE Format https://frbservices.org/EPaymentsDirectory/fedwireFormat.html

Directories

Path Synopsis
cmd
fedtest
fedtest is a cli tool for testing Moov's FED API endpoints.
fedtest is a cli tool for testing Moov's FED API endpoints.
pkg

Jump to

Keyboard shortcuts

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