A Go (golang) client for interacting with the SRFax API

client, golang, srfax, srfax-api, srfax-operation
go get



srfax is a Go client library for interacting with the SRFax API service. The client supports all official operations and provides convenience functions for ease-of-use.

The official SRFax API documentation can be found here

Important, this library will handle Result errors in a Go like manner. Instead of mixing error messages with real results like so:

    "Status": "",
    "Result": "",

This client will always return an operation-specific response (suffixed with Resp) composed of the following:

    "Status": "Success or Failed", 
    "Result": "result will be specific to the operation performed", 
    "ResultError": "error will be empty unless there was an error"

It is the caller's responsibility to check the Error value prior to using Result. If Error is not an empty string assume something has gone wrong and Result should not be used.

If SRFax had publically availble errors then could compose error types, but for now it'll be a string.


go get -u


Import the library.

To begin using the client initialize a ClientCfg and pass it to NewClient.

cfg := srfax.ClientCfg{
    ID:  00001,
    PWD: "password",
    // URL: optional, defaults to

client, err := srfax.NewClient(cfg)
if err != nil {
    // check errors

With a *Client one runs all SRFax operations.


resp, err := client.GetFaxUsage() // resp is a pointer to a FaxUsageResp.
if err != nil {
    // check errors

// for testing purposes use convenience func PP to pretty print the response to terminal


    "Status": "Success",
    "Result": [{
        "Period": "ALL",
        "ClientName": "mike",
        "BillingNumber": "",
        "UserID": 00001,
        "SubUserID": 0,
        "NumberOfFaxes": 140,
        "NumberOfPages": 40
    "ResultError": ""