Name: minimarketo
Owner: CoreOS
Description: A small Marketo library written in Go.
Created: 2018-03-07 19:33:12.0
Updated: 2018-03-07 19:33:14.0
Pushed: 2017-08-21 09:25:51.0
Size: 9
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Inspired by the FrenchBen/goketo, we created MiniMarketo which is a very tiny client for Marketo REST API.
It is very different from goketo as it doesn't do much.
What MiniMarketo does is only one thing:
Other than that, MiniMarketo acts very much like a http client. So all you have to do is:
MiniMarketo, instead of covering all the Marketo REST API calls, acts as a thin wrapper for Marketo REST API. Currently it only supports JSON API. Most “bulk” endpoints are not supported as it requires sending and downloading files.
et github.com/SpeakData/minimarketo
Basic operations are:
First, create a client. In this example, I'm passing configuration through environment variables.
ig := minimarketo.ClientConfig{
ID: os.Getenv("MARKETO_ID"),
Secret: os.Getenv("MARKETO_SECRET"),
Endpoint: os.Getenv("MARKETO_URL"), // https://XXX-XXX-XXX.mktorest.com
Debug: true,
nt, err := minimarketo.NewClient(config)
rr != nil {
log.Fatal(err)
Then, call Marketo supported http calls: GET, POST, or DELETE.
Find a lead
:= "/rest/v1/leads.json?"
url.Values{
"filterType": {"email"},
"filterValues": {"tester@example.com"},
"fields": {"email"},
onse, err := client.Get(path + v.Encode())
rr != nil {
log.Fatal(err)
response.Success {
log.Fatal(response.Errors)
leads []minimarketo.LeadResult
rr = json.Unmarshal(response.Result, &leads); err != nil {
log.Fatal(err)
_, lead := range leads {
fmt.Printf("%+v", lead)
Create a lead
:= "/rest/v1/leads.json"
Input struct {
Email string `json:"email"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
CreateData struct {
Action string `json:"action"`
LookupField string `json:"lookupField"`
Input []Input `json:"input"`
:= CreateData{
"createOnly",
"email",
[]Input{
Input{"tester@example.com", "John", "Doe"},
},
InBytes, err := json.Marshal(data)
onse, err := client.Post(path, dataInBytes)
rr != nil {
log.Fatal(err)
response.Success {
log.Fatal(response.Errors)
createResults []minimarketo.RecordResult
rr = json.Unmarshal(response.Result, &createResults); err != nil {
log.Fatal(err)
_, result := range createResults {
fmt.Printf("%+v", result)
MiniMarketo defines the common Marketo response format. This covers most of the API responses.
Response struct {
RequestID string `json:"requestId"`
Success bool `json:"success"`
NextPageToken string `json:"nextPageToken,omitempty"`
MoreResult bool `json:"moreResult,omitempty"`
Errors []struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"errors,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Warnings []struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"warning,omitempty"`
Your job is to parse “Result”.
As for convenience, MiniMarketo defines two commonly used “result” format.
ind lead returns "result" in this format
LeadResult struct {
ID int `json:"id"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Email string `json:"email"`
Created string `json:"createdAt"`
Updated string `json:"updatedAt"`
reate/update lead uses this format
RecordResult struct {
ID int `json:"id"`
Status string `json:"status"`
Reasons []struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"reasons,omitempty"`
MIT