{"id":18974992,"url":"https://github.com/bufferapp/segment-config-api","last_synced_at":"2025-04-19T16:44:31.245Z","repository":{"id":57465291,"uuid":"225973766","full_name":"bufferapp/segment-config-api","owner":"bufferapp","description":"A Python Wrapper for Segment's Config API","archived":false,"fork":false,"pushed_at":"2021-11-02T16:47:56.000Z","size":9,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T23:07:43.517Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/bufferapp.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":"2019-12-04T23:10:45.000Z","updated_at":"2023-10-26T20:10:53.000Z","dependencies_parsed_at":"2022-08-31T02:00:12.036Z","dependency_job_id":null,"html_url":"https://github.com/bufferapp/segment-config-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fsegment-config-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fsegment-config-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fsegment-config-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufferapp%2Fsegment-config-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bufferapp","download_url":"https://codeload.github.com/bufferapp/segment-config-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249740898,"owners_count":21318715,"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":[],"created_at":"2024-11-08T15:16:54.455Z","updated_at":"2025-04-19T16:44:31.228Z","avatar_url":"https://github.com/bufferapp.png","language":"Python","readme":"# A Python wrapper for [Segment's Config API](https://segment.com/docs/config-api/)\n\nA minimal wrapper for Segment's config API.\n\nThe library is designed as a [Fluent interface](https://en.wikipedia.org/wiki/Fluent_interface) around the REST API. It consists of models that are designed execute API calls within the scope of parent models.\n\n## Installation\n\n```\npip install segment-config-api\n```\n\n## Usage\n\n```python\nimport os\nfrom segment_config_api.api import SegmentConfigApi\n\naccess_token = os.getenv('SEGMENT_CONFIG_API_ACCESS_TOKEN') # Or hard-coded or whichever way you want to access it\napi = SegmentConfigApi(access_token)\n```\n\n### Workspaces\n\n```python\n# List all workspaces\napi.workspaces.list()\n\n# Get a workspace\napi.workspace('myworkspace').get()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#7a63ac88-43af-43db-a987-7ed7d677a8c8)\n\n\n### Integrations Catalog\n\n```python\n# List all sources\ncatalog = api.integrations_catalog\n\ncatalog.sources.list()\n\n# Get a specific source\ncatalog.source('customerio').get()\n\n# List all destinations\ncatalog = api.integrations_catalog\n\ncatalog.destinations.list()\n\n# Get a specific destination\ncatalog.destination('customerio').get()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#7a63ac88-43af-43db-a987-7ed7d677a8c8)\n\n### Sources\n\n```python\n# Sources are scoped on a workspace level.\nworkspace = api.workspace('myworkspace')\nsources = workspace.sources\n\n# List all sources\nsources.list()\n\n# Create a new source\npayload = {...}\nsources.create(payload)\n\n# Get a specific source by name\nworkspace.source('js').get()\n\n# Get schema config\nsc = workspace.source('js').get_schema_config\n\n#Update schema config\npayload = {...}\nworkspace.source('js').update_schema_config(payload)\n\n# Delete a source\nworkspace.source('js').delete()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#5a852761-54d5-46da-8437-6e14e63449f3)\n\n### Destinations\n\n```python\n# Destinations are scoped on the source level\nworkspace = api.workspace('myworkspace')\ndestinations = api.source('js').destinations\n\n# List all destinations at this source\ndestinations.list()\n\n# Create a new destination for this source\npayload = {}\ndestinations.create(payload)\n\n# Get a specific destination by name\nga = workspace.source('js').destination('google-analytics')\nga.get()\n\n# Update a destination\npayload = {...}\nga.update(payload)\n\n# Delete a destination\nga.delete()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#39ce0439-0969-48c3-ba49-b22a46c41060)\n\n### Tracking Plans\n\n```python\n# Tracking plans are scoped on the workspace level\nworkspace = api.workspace('myworkspace')\ntracking_plans = workspace.tracking_plans\n\n# List all the tracking plans\ntracking_plans.list()\n\n# Create a tracking plan\npayload = {...}\ntracking_plans.create(payload)\n\n# Get a specific tracking plan by plan_id\nplan = workspace.tracking_plan('rs_123')\nplan.get()\n\n# Update a tracking plan\npayload = {...}\nplan.update(payload)\n\n# Create tracking plan source connection\nplan.create_source_connection('workspaces/myworkspace/sources/js')\n\n# Batch create source connections\nsource_names = [...]\nplan.batch_create_source_connection(source_names)\n\n# List source connections\nplan.list_source_connections()\n\n# Delete source connection\nplan.delete_source_connection('workspaces/myworkspace/sources/js')\n\n# Delete a tracking plan\nplan.delete()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#c4647e3c-fe1b-4e2f-88b9-6634841eb4e5)\n\n\n### Event Delivery Metrics\n\n```python\n# Event delivery metrics are scoped on a destination level\nga = api.workspace('myworkspace').source('js').destination('google-analytics')\n\nmetrics = ga.event_delivery_metrics\n\n# List all the timeseries metrics\npayload = {...}\nmetrics.list_timeseries(payload=payload) #payload is optional\n\n\n# Get a timeseries metric\nmetrics.get_timeseries('time_to_success_p95')\n\n# Batch get a timeseries metric, no need to add the full path prefix to metrics names, we'll do it for you\nmetrics.batch_get_timeseries(['successes', 'retried_502'])\n\n# Get summary metrics\nmetrics.get_summary()\n\n# Batch get summary metrics (on a workspace level)\nws = api.workspace('myworkspace')\npairs = ['workspaces/myworkspace/sources/js/destinations/google-analytics']\n# Or let the api wrapper build your path\npairs = [ws.source('js').destination('google-analytics').model_path]\n\nws.batch_get_summary_metrics(pairs)\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#51d89077-efd7-429b-85d4-155ac2cd07aa)\n\n### Destination Filters\n\n```python\n# Destination Filters are scoped on a destination level\nga = api.workspace('myworkspace').source('js').destination('google-analytics')\ndestination_filters = ga.destination_filters\n\n# List all filters for a destination\ndestination_filters.list()\n\n# Create a destination filter\npayload = {...}\ndestination_filters.create(payload)\n\n# Get a specific filter\nfilter = ga.destination_filter('df_123')\nfilter.get()\n\n# Update a filter\npayload = {...}\nfilter.update(payload)\n\n# Delete a filter\nfilter.delete()\n\n# Preview a filter - This is scoped on the api level\npayload = {\n    \"filter\": {\n        \"if\": \"all\",\n            \"actions\": [\n                {\n                    \"type\": \"blacklist_fields\",\n                    \"fields\": {\n                        \"properties\": {\n                            \"fields\": [\"name\", \"age\"]\n                        }\n                    }\n                }\n            ],\n            \"enabled\": True\n        },\n        \"input\": \"{ \\\"userId\\\": \\\"6592\\\", \\\"properties\\\": { \\\"name\\\": \\\"Bob Smith\\\", \\\"age\\\": \\\"40\\\", \\\"order\\\": \\\"129\\\" } }\"\n}\napi.destination_filters.preview(payload)\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#6c12fbe8-9f84-4a6c-848e-76a2325cb3c5)\n\n\n### Deletion and Surpression\n\n```python\n# Regulations are scoped on a workspace level\nws = api.workspace('myworkspace')\nregulations = ws.regulations\n\n# List all regulations for a workspace\nregulations.list()\n\n#List regulations based on status\nregulations.list(regulation_types='Suppress_With_Delete')\n\n# Create a regulation\npayload = {...}\nregulations.create(payload)\n\n# Get a specific regulation on it's regulation_id\nregulation = ws.regulation('1KQVncbOPeRGjRcpuOHdnhDwPn7')\nregulation.get()\n\n# Delete a regulation (It has to be in an `initialized` state)\nregulation.delete()\n\n# Create a regulation on a source\npayload = {...}\nws.source('js').regulations.create(payload)\n\n# Delete an Object from a cloud source\npayload = {...}\nws.source('js').regulations.delete(payload)\n\n# List suppressed users on a workspace level\nws.suppressed_users.list()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#57a69434-76cc-43cc-a547-98c319182247)\n\n### IAM\n\n```python\n# Roles are scoped on a workspace level\nws = api.workspace('myworkspace')\nroles = ws.roles\n\n# List all roles for a workspace\nroles.list()\n\n# List role policies\nroles.policies.list()\n\n# Get a specific regulation on it's regulation_id\nregulation = ws.regulation('1KQVncbOPeRGjRcpuOHdnhDwPn7')\nregulation.get()\n\n# Delete a regulation (It has to be in an `initialized` state)\nregulation.delete()\n\n# Create a role policy (scoped on the api level)\npayload = {...}\napi.role_policies(role_name).create(payload)\n\n# Delete role policy\napi.role_policy(policy_name).delete()\n\n# Invites are scoped on the workspace level\ninvites = ws.invites\n\n# List all invites\ninvites.list()\n\n# Create an invite\npayload = {...}\ninvites.create(payload)\n\n# Delete an invite\nws.invite('123').delete()\n```\n\nMore API details [here](https://reference.segmentapis.com/?version=latest#57a69434-76cc-43cc-a547-98c319182247)\n\n## What's missing\n\n- Unit/Integration tests. The library hasn't been fully tested end-to-end. If you find any bugs, please file an issue!\n- Pagination helpers. Right now you still have to manually retrieve and pass through the `page_token` to do pagination. Ideally there would be a set of nice iteratort functions to automatically do that for you.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fsegment-config-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbufferapp%2Fsegment-config-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufferapp%2Fsegment-config-api/lists"}