Splunk.Api 10.6.73

dotnet add package Splunk.Api --version 10.6.73
                    
NuGet\Install-Package Splunk.Api -Version 10.6.73
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Splunk.Api" Version="10.6.73" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Splunk.Api" Version="10.6.73" />
                    
Directory.Packages.props
<PackageReference Include="Splunk.Api" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Splunk.Api --version 10.6.73
                    
#r "nuget: Splunk.Api, 10.6.73"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Splunk.Api@10.6.73
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Splunk.Api&version=10.6.73
                    
Install as a Cake Addin
#tool nuget:?package=Splunk.Api&version=10.6.73
                    
Install as a Cake Tool

Splunk.Api

NuGet License: MIT .NET 10 CI Codacy Badge Codacy Coverage

A typed, modern .NET client for the Splunk Enterprise REST API (version 10.6), built on Refit and System.Text.Json, plus a client for the HTTP Event Collector.

Splunk.Api is an independent open-source project by Panoramic Data Limited. It is not made, endorsed or supported by Splunk Inc. Splunk is a trademark of Splunk Inc.

Installation

dotnet add package Splunk.Api

Splunk.Api targets .NET 10. The package version follows the REST API reference it implements: 10.6.x targets Splunk Enterprise 10.6. Most endpoints also work on earlier releases that have them.

Quick start

using Splunk.Api;
using Splunk.Api.Models.Introspection;

using var client = new SplunkClient(new SplunkClientOptions
{
	BaseUrl = "https://splunk.example.com:8089",
	Token = "<a Splunk authentication token>"
});

var info = await client.ServerInfo.GetAsync(cancellationToken);
Console.WriteLine($"Splunk {info.Entries[0].Content!.Version}");

var indexes = await client.Indexes.ListAsync(new IndexListOptions { Count = 0 }, cancellationToken);
foreach (var index in indexes.Entries)
{
	Console.WriteLine($"{index.Name}: {index.Content!.TotalEventCount} events");
}

Searching

client.Search runs searches end to end: it creates the job, waits for it, pages through every result and deletes the job afterwards (also when it fails, times out or is cancelled).

var run = await client.Search.RunAsync("search index=_internal | stats count by sourcetype", cancellationToken);
foreach (var row in run.Results)
{
	Console.WriteLine($"{row["sourcetype"]}: {row["count"]}");
}

// Small, quick searches in one round trip.
var oneshot = await client.Search.OneshotAsync("| makeresults count=5 | eval n=random()", cancellationToken);

// Stream a large result set as Splunk produces it.
await foreach (var result in client.Search.ExportAsync("search index=main earliest=-1h", cancellationToken))
{
	Console.WriteLine(result.Raw);
}

Multivalue fields are kept: row.GetValues("field") returns every value, row.GetString("field") the first. The raw endpoints (client.SearchJobs, client.SearchJobResults, client.SearchExport, client.SavedSearches...) are there when you need full control. A search that fails in Splunk raises SplunkSearchException with Splunk's messages.

Endpoint groups

Each group of endpoints is a property of SplunkClient (client.Users, client.Indexes, client.EventTypes, client.KvStoreData...). Methods take a required CancellationToken; optional parameters travel in an options or request object, so pass null when you need none.

Authentication

Option How it authenticates
Token A Splunk authentication token, sent as Authorization: Bearer. Recommended.
Username + Password Logs in through services/auth/login and sends the session key; logs in again once if the session expires.
Username + Password + UseBasicAuthentication = true HTTP basic credentials on every request.

Splunk's management port often uses a self-signed certificate. Rather than turning validation off, pin it:

var options = new SplunkClientOptions
{
	BaseUrl = "https://localhost:8089",
	Username = "admin",
	Password = password,
	TrustedServerCertificateThumbprint = "<SHA-256 thumbprint>" // other certificates are still validated normally
};

ServerCertificateValidationCallback gives full control, and the SplunkClient(options, innerHandler) constructor accepts your own HttpMessageHandler (a proxy, or instrumentation).

Namespaces

Splunk scopes knowledge objects to a user and an app (servicesNS/{owner}/{app}/...). Set a default with SplunkClientOptions.Namespace, or get a view of a client in another namespace; views share the client's connections and session:

var search = client.InNamespace("nobody", "search");          // objects shared in the search app
var everything = client.InNamespace(SplunkNamespace.All);       // -/-: every user and app

var eventTypes = await everything.EventTypes.ListAsync(null, cancellationToken);

Creating and changing objects

using Splunk.Api.Models.Access;

await client.Users.CreateAsync(new UserCreateRequest
{
	Name = "jsmith",
	Password = initialPassword,
	Roles = ["user"],
	Email = "jsmith@example.com"
}, cancellationToken);

Request objects carry Splunk's documented parameters as typed properties. Splunk's open-ended parameter families (for example action.<name>.*) go in AdditionalParameters, which every request object has.

KV store

using Splunk.Api.Models.KvStore;

var app = client.InNamespace("nobody", "search");
var key = await app.KvStoreData.InsertAsync("assets", new JsonBody<Asset>(new Asset("web01", 4)), cancellationToken);
var busy = await app.KvStoreData.QueryAsync<Asset>(
	"assets",
	new KvStoreQuery { Query = """{"cpus":{"$gt":2}}""", Sort = "cpus:-1", Limit = 10 },
	cancellationToken);

public sealed record Asset(string Name, int Cpus);

HTTP Event Collector

The HTTP Event Collector is a separate service (port 8088) with its own tokens, so it has its own client:

using Splunk.Api.Models.Inputs;

using var hec = new SplunkHecClient(new SplunkHecClientOptions
{
	BaseUrl = "https://splunk.example.com:8088",
	Token = hecToken
});

await hec.SendAsync(
	[new HecEvent { Event = new { message = "deployment finished", version = "2.4.1" }, Sourcetype = "deploy", Index = "main" }],
	cancellationToken);

Batches go in one request; indexer acknowledgement is supported through Channel and QueryAcksAsync.

Read-only mode

ReadOnly = true makes the client refuse, before anything is sent, every request that could change Splunk: any DELETE, and any POST other than logging in and running, controlling or parsing searches. It raises SplunkReadOnlyException. It cannot police the SPL inside a search (| delete, | outputlookup), so use a Splunk role without those capabilities for a truly read-only identity.

Errors, retries and timeouts

  • A non-success response raises SplunkApiException with the status code and Splunk's messages.
  • 429 and 503 are retried for any verb, other 5xx for idempotent verbs, honouring Retry-After, with exponential back-off (MaxRetries, RetryBaseDelay, MaxRetryDelay). A connection that could not be established is retried too, since nothing was sent.
  • Timeout applies per attempt and raises TimeoutException; cancelling your token raises OperationCanceledException.
  • Credentials, session keys and query strings (which can carry search text) are never logged; pass an ILogger as Logger to see method, path and retry decisions.

Coverage

docs/endpoints/ lists every operation in the Splunk Enterprise 10.6 REST API reference (656), with the client method that implements it and the test that pins its request. InventoryTests keeps that list and the code in step. Deprecated operations, including the v1 search endpoints Splunk disables by default since 9.0.1, are not implemented.

Area Status
Access control, users, roles, tokens, SAML/LDAP/MFA/ProxySSO, stored passwords Complete
Apps and licensing Complete
Knowledge objects: event types, tags, field extractions, aliases, lookups, data models, views, macros Complete
Indexes, inputs (monitor, TCP/UDP, scripted, modular, Windows, HEC tokens), outputs, receivers Complete
Configuration files and properties, server settings, messages, introspection, health Complete
KV store collections and data, workload management Complete
Indexer and search head clustering, deployment server, federated search, topology Complete
Search jobs and results (v2), export streaming, saved searches, scheduled views, alerts, SPL2, metrics catalog Complete

Splunk's reference is wrong in places; where a live Splunk 10.6 behaves differently, the method follows Splunk and its documentation says so.

Quality

  • Every operation has a unit test pinning its exact HTTP method, path, query and body, and a test mapping a real (anonymised) Splunk 10.6 response. The library has 100% line and branch coverage.
  • Integration tests run every safe operation against a disposable Splunk Enterprise 10.6 in Docker; see docs/TESTING.md.
  • Zero compiler warnings, nullable reference types, XML documentation on every public member, Codacy grade A.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.6.73 95 10/16/2026
10.6.66 98 10/8/2026
10.6.32 93 10/8/2026