Skip to content

leonelquinteros/hubspot

Repository files navigation

GitHub release MIT license GoDoc Go Report Card

HubSpot API client SDK for Go

Install

go get github.com/leonelquinteros/hubspot

Quickstart

package main

import "github.com/leonelquinteros/hubspot"

func main() {
    // Create client object with config from environment variables (HUBSPOT_API_HOST, HUBSPOT_API_KEY, HUBSPOT_OAUTH_TOKEN)
    c := hubspot.NewClient(hubspot.NewClientConfig())

    // Create new contact
    data := hubspot.ContactsRequest{
		hubspot.Properties: []hubspot.Property{
			hubspot.Property{
				Property: "email",
				Value:    "[email protected]",
			},
			hubspot.Property{
				Property: "firstname",
				Value:    "Contact",
			},
			hubspot.Property{
				Property: "lastname",
				Value:    "Example",
			},
		},
    }
    r, err := c.Contacts().Create(data)
	if err != nil {
		log.Fatal(err)
	}

    // Get contact by email
    contact, err = c.Contacts().GetByEmail("[email protected]")
    if err != nil {
        log.Fatal(err)
    }

    // Print contact object
    fmt.Printf("%+v", contact)
}

Full documentation

https://godoc.org/github.com/leonelquinteros/hubspot