Lytics SDK for Go (Golang)
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
mock
LICENSE.md
README.md
account.go
account_test.go
auth.go
auth_test.go
campaign.go
campaign_test.go
catalog.go
catalog_test.go
content.go
content_test.go
entity.go
entity_test.go
json.go
json_test.go
lytics.go
lytics_test.go
provider.go
provider_test.go
query.go
segment.go
segment_test.go
segmentml.go
segmentml_test.go
user.go
user_test.go
work.go
work_test.go

README.md

#Lytics SDK for Go The Lytics SDK for go offers easy integration with our public REST API endpoints. This library is actively being managed and every effort will be made to ensure that all handling reflects the best methods available. Overview of supported methods outlined below.

Full REST API Documentation

https://learn.lytics.com/api-docs

Command Line Tool Doc

The Lytics CLI utilizes this library.

Getting Started

  1. Import the library. go get github.com/lytics/go-lytics
  2. Create a new client from api key.
  3. Run one of the many methods to access account info.
package main

import (
	"fmt"
	"encoding/json"
	
	lytics "github.com/lytics/go-lytics"
)

func main() {
	// set your api key
	key := "<YOUR API KEY>"

	// create the client
	client := lytics.NewLytics(key, nil)

	// create a scanner for All Users in a Segment 
	scan := client.PageSegment(`
		FILTER AND (
		    lastvisit_ts > "now-2d"
		    EXISTS email
		)
		FROM user
	`)

	// handle processing the users
	for {
		e := scan.Next()
		if e == nil {
			break
		}

		by, err := json.Marshal(e.Fields)
		if err != nil {
			fmt.Println("ERROR: ", err)
			continue
		}
		fmt.Println(string(by))
	}
}

Examples

Supported Methods

  • Account
    • Single GET
    • All GET
  • Admin User
    • Single GET
    • All GET
  • Segment
    • Single GET
    • All GET
  • Entity (end users) API GET
  • Catalog
    • Schema GET
  • Query
    • All GET
    • Test Evaluation POST

Contributing

Want to add something? Go for it, just fork the repo and send us a PR. Please make sure all tests run go test -v and that all new functionality comes with well documented and thorough testing.

License

MIT Copyright (c) 2018, 2017, 2016, 2015 Lytics