Table of Contents

Interface ICivitaiHttpClient

Namespace
CivitaiSharp.Core.Http
Assembly
CivitaiSharp.Core.dll

Abstraction for HTTP communication with Civitai APIs. Provides strongly-typed async methods for standard HTTP verbs with JSON serialization/deserialization and error response parsing. Results are wrapped in Result<T>.

public interface ICivitaiHttpClient

Methods

DeleteAsync<TResponse>(string, CancellationToken)

Performs an HTTP DELETE request and deserializes the response.

Task<Result<TResponse>> DeleteAsync<TResponse>(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string

The relative URI to request.

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<Result<TResponse>>

A task containing either the deserialized response or an error.

Type Parameters

TResponse

The type to deserialize the response body into.

GetAsync<TResponse>(string, CancellationToken)

Performs an HTTP GET request and deserializes the response.

Task<Result<TResponse>> GetAsync<TResponse>(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string

The relative URI to request.

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<Result<TResponse>>

A task containing either the deserialized response or an error.

Type Parameters

TResponse

The type to deserialize the response body into.

PostAsync<TResponse>(string, object?, CancellationToken)

Performs an HTTP POST request with a JSON body and deserializes the response.

Task<Result<TResponse>> PostAsync<TResponse>(string requestUri, object? content, CancellationToken cancellationToken = default)

Parameters

requestUri string

The relative URI to request.

content object

The content to serialize as JSON in the request body. Can be null.

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<Result<TResponse>>

A task containing either the deserialized response or an error.

Type Parameters

TResponse

The type to deserialize the response body into.

PutAsync<TResponse>(string, object?, CancellationToken)

Performs an HTTP PUT request with a JSON body and deserializes the response.

Task<Result<TResponse>> PutAsync<TResponse>(string requestUri, object? content, CancellationToken cancellationToken = default)

Parameters

requestUri string

The relative URI to request.

content object

The content to serialize as JSON in the request body. Can be null.

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<Result<TResponse>>

A task containing either the deserialized response or an error.

Type Parameters

TResponse

The type to deserialize the response body into.