{"id":17359918,"url":"https://github.com/ajbosco/segment-config-go","last_synced_at":"2025-08-02T08:31:31.860Z","repository":{"id":48121557,"uuid":"161078706","full_name":"ajbosco/segment-config-go","owner":"ajbosco","description":"A Go client library for the Segment Config API","archived":false,"fork":false,"pushed_at":"2022-07-27T14:45:10.000Z","size":224,"stargazers_count":2,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-16T21:58:15.386Z","etag":null,"topics":["go","golang","segment","segmentio"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajbosco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-09T20:31:07.000Z","updated_at":"2022-07-26T13:44:20.000Z","dependencies_parsed_at":"2022-08-12T19:01:03.952Z","dependency_job_id":null,"html_url":"https://github.com/ajbosco/segment-config-go","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajbosco%2Fsegment-config-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajbosco%2Fsegment-config-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajbosco%2Fsegment-config-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajbosco%2Fsegment-config-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajbosco","download_url":"https://codeload.github.com/ajbosco/segment-config-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228454012,"owners_count":17922584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","segment","segmentio"],"created_at":"2024-10-15T19:13:31.918Z","updated_at":"2024-12-06T11:12:20.022Z","avatar_url":"https://github.com/ajbosco.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# segment-config-go\n\n[![Github Actions](https://github.com/ajbosco/segment-config-go/workflows/build/badge.svg?branch=master\u0026event=push)](https://github.com/ajbosco/segment-config-go/actions?workflow=build)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ajbosco/segment-config-go?style=flat-square)](https://goreportcard.com/report/github.com/ajbosco/segment-config-go)\n[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/ajbosco/segment-config-go/segment)\n\nsegment-config-go is a Go client library for accessing the [Segment Config](https://segment.com/docs/config-api/) API.\n\nThis library allows you to do the following programmatically:\n\n* List all your Segment sources and destinations\n* Create [sources](https://segment.com/docs/sources/)\n* Create or modify [destinations](https://segment.com/docs/destinations/)\n* Enable and disable destinations\n* Create, list or modify [tracking plans](https://segment.com/docs/protocols/tracking-plan/create/)\n\n## Authentication\n\nsegment-config-go requires a Segment Personal Access Token for authentication. You can generate one with the appropriate access by following the steps in the Segment [documentation](https://segment.com/docs/config-api/authentication/)\n\n## Usage\n\n```go\nimport \"github.com/ajbosco/segment-config-go/segment\"\n```\n\nConstruct a new Segment client with your access token and Segment workspace. For example:\n\n```go\naccessToken :=  os.Getenv(\"ACCESS_TOKEN\")\nsegmentWorkspace :=  os.Getenv(\"SEGMENT_WORKSPACE\")\n\nclient := segment.NewClient(accessToken, segmentWorkspace)\n```\n\nNow you can interact with the API to do things like list all [sources](https://segment.com/docs/sources/) in your workspace:\n\n```go\nsources, err := c.ListSources()\n```\n\nList [destinations](https://segment.com/docs/destinations/) for a given source:\n\n```go\ndestinations, err := c.ListDestinations(\"your-source\")\n```\n\nCreate a new [source](https://segment.com/docs/sources/):\n\n```go\nsource, err := c.CreateSource(\"your-source\", \"catalog/sources/javascript\")\n```\n\nCreate a new [destination](https://segment.com/docs/destinations/):\n\n```go\nsource, err := c.CreateDestination(\"your-source\", \"google-analytics\", \"cloud\", false, nil)\n```\n\nCreate a new [tracking plan](https://segment.com/docs/protocols/tracking-plan/create/):\n\n```go\ntp := TrackingPlan{\n    DisplayName: \"Your Tracking Plan\",\n    Rules: RuleSet{\n        Global: Rules{\n            Schema: \"http://json-schema.org/draft-04/schema#\",\n            Type:   \"object\",\n            Properties: RuleProperties{\n                Context: Properties{\n                    Type: \"object\",\n                    Properties: map[string]Property{},\n                },\n                Properties: Properties{},\n                Traits:     Properties{},\n            },\n        },\n        Events: []Event{\n            {\n                Name:        \"Test Event\",\n                Description: \"A simple test event\",\n                Rules: Rules{\n                    Schema: \"http://json-schema.org/draft-07/schema#\",\n                    Type:   \"object\",\n                    Properties: RuleProperties{\n                        Traits: Properties{},\n                        Properties: Properties{\n                            Required: []string{\"user_id\"},\n                            Type:     \"object\",\n                            Properties: map[string]Property{\n                                \"user_id\": {\n                                    Description: \"unique id of the user\",\n                                    Type:        []string{\"string\"},\n                                },\n                            },\n                        },\n                    },\n                },\n            },\n        },\n    },\n}\ntrackingPlan, err := c.CreateTrackingPlan(tp)\n```\n\nGet an existing [tracking plan](https://segment.com/docs/protocols/tracking-plan/create/):\n\n```go\ntrackingPlan, err := c.GetTrackingPlan(\"rs_123abc\")\n```\n\nList all [tracking plans](https://segment.com/docs/protocols/tracking-plan/create/):\n\n```go\ntrackingPlans, err := c.ListTrackingPlans()\n```\n\nUpdate an existing [tracking plan](https://segment.com/docs/protocols/tracking-plan/create/):\n```go\ntp := TrackingPlan{\n    DisplayName: \"Your Tracking Plan\",\n    Rules: RuleSet{\n        Global: Rules{\n            Schema: \"http://json-schema.org/draft-04/schema#\",\n            Type:   \"object\",\n            Properties: RuleProperties{\n                Context: Properties{\n                    Type: \"object\",\n                    Properties: map[string]Property{},\n                },\n                Properties: Properties{},\n                Traits:     Properties{},\n            },\n        },\n        Events: []Event{\n            {\n                Name:        \"Test Event\",\n                Description: \"A simple test event\",\n                Rules: Rules{\n                    Schema: \"http://json-schema.org/draft-07/schema#\",\n                    Type:   \"object\",\n                    Properties: RuleProperties{\n                        Traits: Properties{},\n                        Properties: Properties{\n                            Required: []string{\"user_id\"},\n                            Type:     \"object\",\n                            Properties: map[string]Property{\n                                \"user_id\": {\n                                    Description: \"unique id of the user\",\n                                    Type:        []string{\"string\"},\n                                },\n                            },\n                        },\n                    },\n                },\n            },\n        },\n    },\n}\ntrackingPlan, err := c.UpdateTrackingPlan(\"rs_123abc\", tp)\n```\n\nDelete an existing [tracking plan](https://segment.com/docs/protocols/tracking-plan/create/):\n\n```go\nerr := client.DeleteTrackingPlan(\"rs_123abc\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajbosco%2Fsegment-config-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajbosco%2Fsegment-config-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajbosco%2Fsegment-config-go/lists"}