Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 712 Bytes

page_through_segment.md

File metadata and controls

38 lines (28 loc) · 712 Bytes

Segment Paging

Iterate through all members of a particular segment. Returns the entire model for each user.

package main

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

func main() {
	var err error

	// set your api key & segment id to scan
	apikey := "<YOUR API KEY HERE>"
	segmentid := "<YOUR SEGMENT ID HERE>"

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

	// create the scanner
	scan := client.PageSegmentId(os.Args[1])

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

		fmt.Printf("%v\n\n", e.PrettyJson())
	}

	fmt.Printf("*** COMPLETED SCAN: Loaded %d batches and %d total entities", len(scan.Batches), scan.Total)
}