{"id":13570235,"url":"https://github.com/datalust/seq-api","last_synced_at":"2025-05-16T01:05:07.064Z","repository":{"id":24463769,"uuid":"27867062","full_name":"datalust/seq-api","owner":"datalust","description":"HTTP API client for Seq","archived":false,"fork":false,"pushed_at":"2025-05-09T02:24:26.000Z","size":539,"stargazers_count":82,"open_issues_count":4,"forks_count":22,"subscribers_count":10,"default_branch":"dev","last_synced_at":"2025-05-09T02:41:06.149Z","etag":null,"topics":["seq"],"latest_commit_sha":null,"homepage":"https://datalust.co/seq","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datalust.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-11T10:58:00.000Z","updated_at":"2025-05-09T02:22:37.000Z","dependencies_parsed_at":"2024-01-14T03:47:43.819Z","dependency_job_id":"8a05aa58-1d5f-4883-a424-ff8a05a8523e","html_url":"https://github.com/datalust/seq-api","commit_stats":{"total_commits":166,"total_committers":11,"mean_commits":"15.090909090909092","dds":0.1987951807228916,"last_synced_commit":"68ef56133a6d2f5ee1fa4871164b278088e01319"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fseq-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fseq-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fseq-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datalust%2Fseq-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datalust","download_url":"https://codeload.github.com/datalust/seq-api/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"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":["seq"],"created_at":"2024-08-01T14:00:49.968Z","updated_at":"2025-05-16T01:05:07.037Z","avatar_url":"https://github.com/datalust.png","language":"C#","readme":"# Seq HTTP API Client [![Build status](https://ci.appveyor.com/api/projects/status/bhtx25hyqmmdqhvt?svg=true)](https://ci.appveyor.com/project/datalust/seq-api) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Seq.Api.svg)](https://nuget.org/packages/seq.api)\n\nThis library includes:\n\n * C# representations of the entities exposed by the Seq HTTP API\n * Helper classes for interacting with the API\n\nIt's useful for querying events and working with configuration data - *everything you can do using the Seq web UI*, you can do programmatically via the API.\n\nIf you want to *write events* to Seq, use one of the logging framework clients, such as _Serilog.Sinks.Seq_ or _NLog.Targets.Seq_ instead.\n\n### Getting started\n\nInstall from NuGet:\n\n```powershell\ndotnet add package Seq.Api\n```\n\nCreate a `SeqConnection` with your server URL:\n\n```csharp\nvar connection = new SeqConnection(\"http://localhost:5341\");\n```\n\nNavigate the \"resource groups\" exposed as properties of the `connnection`:\n\n```csharp\nvar installedApps = await connection.Apps.ListAsync();\n```\n\n**To authenticate**, the `SeqConnection` constructor accepts an `apiKey` parameter (make sure the API key permits _user-level access_) or, if you want to log in with personal credentials you can `await connection.Users.LoginAsync(username, password)`.\n\nFor a more complete example, see the [seq-tail app included in the source](https://github.com/datalust/seq-api/blob/main/example/SeqTail/Program.cs).\n\n#### Creating entities\n\nThe Seq API provides a `/template` resource for each resource group that provides a new instance of the resource with defaults populated. The API client uses this pattern when creating new entities:\n\n```csharp\nvar signal = await connection.Signals.TemplateAsync();\nsignal.Title = \"Signal 123\";\nawait connection.Signals.AddAsync(signal);\n```\n\nSee the [signal-copy app](https://github.com/datalust/seq-api/blob/main/example/SignalCopy/Program.cs) for an example of this pattern in action.\n\n### Reading events\n\nSeq internally limits the resources a query is allowed to consume. The query methods on `SeqConnection.Events` include a _status_ with each result set - a `Partial` status indicates that further results must be retrieved.\n\nThe snippet below demonstrates lazily enumerating through results to retrieve the complete set.\n\n```csharp\nvar resultSet = connection.Events.EnumerateAsync(\n    filter: \"Environment = 'Test'\",\n    render: true,\n    count: 1000);\n\nawait foreach (var evt in resultSet)\n  Console.WriteLine(evt.RenderedMessage);\n```\n\nAll methods that retrieve events require a `count`. The API client defaults this value to `30` if not specified.\n\n### Streaming events\n\nSeq provides live streaming of events matching a filter and/or set of signals.\n\n```csharp\nvar filter = \"@Level = 'Error'\";\n\nawait foreach (var evt in connection.Events.StreamAsync\u003cJObject\u003e(filter: filter, clef: true))\n{\n    var logEvent = LogEventReader.ReadFromString(evt);\n    Log.Write(logEvent);\n}\n```\n\n`Events.StreamAsync()` method returns `IAsyncEnumerable\u003cT\u003e` over a _WebSocket_. The enumerator will keep producing events until either it's disposed, or the server is shut down.\n\nSeq streams the events in [compact JSON format](https://github.com/serilog/serilog-formatting-compact), which the Seq API client library can deserialize into JSON.NET `JObjects` for consumption.\n\n[_Serilog.Formatting.Compact.Reader_](https://github.com/serilog/serilog-formatting-compact-reader) provides the `LogEventReader` class used above to turn these documents back into Serilog `LogEvent`s. Having the events represented in Serilog’s object model means they can be passed back into a logging pipeline, as performed above using `Log.Write()`.\n\n### Working with the basic client\n\nThe `SeqApiClient` class implements the low level interactions with the API's entities and links. It's one step up from `System.Net.HttpClient` - you may be able to use it in cases not supported by the high-level wrapper. \n\nCreate a `SeqApiClient` with your server URL:\n\n```csharp\nvar client = new SeqApiClient(\"http://localhost:5341\");\n```\n\nGet the root resource and use it to retrieve one or more of the resource groups:\n\n```csharp\nvar root = await client.GetRootAsync();\nvar events = await client.GetAsync\u003cResourceGroup\u003e(root, \"EventsResources\");\n```\n\n(Available resource groups, like `Events`, `Users` and so-on, can be seen in the root document's `Links` collection.)\n\nUse the client to navigate links from entity to entity:\n\n```csharp\nvar matched = await client.ListAsync\u003cEventEntity\u003e(\n  events,\n  \"Items\",\n  new Dictionary\u003cstring, object\u003e{{\"count\", 10}, {\"render\", true}});\n\nforeach (var match in matched)\n  Console.WriteLine(match.RenderedMessage);\n```\n\n### Package versioning\n\nThis package does not follow the SemVer rule of major version increments for breaking changes. Instead, the package version tracks the Seq version it supports.\n","funding_links":[],"categories":["C# #"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalust%2Fseq-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatalust%2Fseq-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatalust%2Fseq-api/lists"}