The Segment Public API helps you manage your Segment Workspaces and its resources. You can use the API to perform CRUD (create, read, update, delete) operations at no extra charge. This includes working with resources such as Sources, Destinations, Warehouses, Tracking Plans, and the Segment Destinations and Sources Catalogs.
All CRUD endpoints in the API follow REST conventions and use standard HTTP methods. Different URL endpoints represent different resources in a Workspace.
See the next sections for more information on how to use the Segment Public API.
This C# SDK is automatically generated by the OpenAPI Generator project:
- API version: 57.2.0
- Generator version: 7.0.1
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen For more information, please visit https://docs.segmentapis.com
- RestSharp - 112.0.0 or later
- Json.NET - 13.0.2 or later
- JsonSubTypes - 1.8.0 or later
- System.ComponentModel.Annotations - 5.0.0 or later
using System.Collections.Generic;
using System.Diagnostics;
using Segment.PublicApi.Api;
using Segment.PublicApi.Client;
using Segment.PublicApi.Model;
public class Example
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.segmentapis.com";
// Configure Bearer token for authorization: token
config.AccessToken = "YOUR_BEARER_TOKEN";
WorkspacesApi workspacesApi = new WorkspacesApi(config);
try
{
GetWorkspace200Response workspace200Response = workspacesApi.GetWorkspace();
Console.WriteLine(workspace200Response.Data.Workspace.Slug);
}
catch (ApiException e)
{
Debug.Print("Exception when calling APICallsApi.GetDailyPerSourceAPICallsUsage: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
SourcesApi sourcesApi = new SourcesApi(config);
PaginationInput paginationInput = new PaginationInput(count: 100, cursor: "");
try
{
do
{
ListSources200Response sources200Response = sourcesApi.ListSources(paginationInput);
foreach (SourceV1 source in sources200Response.Data.Sources)
{
// iterate over the sources
}
paginationInput.Cursor = sources200Response.Data.Pagination.Next;
} while (paginationInput.Cursor != null);
}
catch (ApiException e)
{
Debug.Print("Exception when calling APICallsApi.GetDailyPerSourceAPICallsUsage: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}