Table of Contents

Class Client

Namespace
Supabase.Postgrest
Assembly
Supabase.Postgrest.dll
public class Client : IPostgrestClient, IGettableHeaders
Inheritance
Client
Implements
Inherited Members

Constructors

Client(string, ClientOptions?)

Should be the first call to this class to initialize a connection with a Postgrest API Server

public Client(string baseUrl, ClientOptions? options = null)

Parameters

baseUrl string

Api Endpoint (ex: "http://localhost:8000"), no trailing slash required.

options ClientOptions

Optional client configuration.

Properties

BaseUrl

API Base Url for subsequent calls.

public string BaseUrl { get; }

Property Value

string

GetHeaders

Function that can be set to return dynamic headers.

Headers specified in the constructor options will ALWAYS take precedence over headers returned by this function.

public Func<Dictionary<string, string>>? GetHeaders { get; set; }

Property Value

Func<Dictionary<string, string>>

Options

The Options Client was initialized with.

public ClientOptions Options { get; }

Property Value

ClientOptions

Methods

AddDebugHandler(DebugEventHandler)

Adds a debug handler

public void AddDebugHandler(IPostgrestDebugger.DebugEventHandler handler)

Parameters

handler IPostgrestDebugger.DebugEventHandler

AddRequestPreparedHandler(OnRequestPreparedEventHandler)

Adds a handler that is called prior to a request being sent.

public void AddRequestPreparedHandler(OnRequestPreparedEventHandler handler)

Parameters

handler OnRequestPreparedEventHandler

ClearDebugHandlers()

Clears debug handlers

public void ClearDebugHandlers()

ClearRequestPreparedHandlers()

Clears all OnRequestPreparedEventHandler handlers.

public void ClearRequestPreparedHandlers()

RemoveDebugHandler(DebugEventHandler)

Removes a debug handler

public void RemoveDebugHandler(IPostgrestDebugger.DebugEventHandler handler)

Parameters

handler IPostgrestDebugger.DebugEventHandler

RemoveRequestPreparedHandler(OnRequestPreparedEventHandler)

Removes an OnRequestPreparedEventHandler handler.

public void RemoveRequestPreparedHandler(OnRequestPreparedEventHandler handler)

Parameters

handler OnRequestPreparedEventHandler

Rpc(string, object?)

Perform a stored procedure call.

public Task<BaseResponse> Rpc(string procedureName, object? parameters = null)

Parameters

procedureName string

The function name to call

parameters object

The parameters to pass to the function call

Returns

Task<BaseResponse>

Rpc<TModeledResponse>(string, object?)

Perform a stored procedure call.

public Task<TModeledResponse?> Rpc<TModeledResponse>(string procedureName, object? parameters = null)

Parameters

procedureName string

The function name to call

parameters object

The parameters to pass to the function call

Returns

Task<TModeledResponse>

A hydrated model

Type Parameters

TModeledResponse

A type used for hydrating the HTTP response content (hydration through JSON.NET)

SerializerSettings(ClientOptions?)

Custom Serializer resolvers and converters that will be used for encoding and decoding Postgrest JSON responses.

By default, Postgrest seems to use a date format that C# and Newtonsoft do not like, so this initial configuration handles that.

public static JsonSerializerSettings SerializerSettings(ClientOptions? options = null)

Parameters

options ClientOptions

Returns

JsonSerializerSettings

Table<T>()

Returns a Table Query Builder instance for a defined model - representative of USE $TABLE

public IPostgrestTable<T> Table<T>() where T : BaseModel, new()

Returns

IPostgrestTable<T>

Type Parameters

T

Custom Model derived from BaseModel

Table<T>(IPostgrestCacheProvider)

Returns a Table Query Builder instance with a Cache Provider for a defined model - representative of USE #$TABLE

public IPostgrestTableWithCache<T> Table<T>(IPostgrestCacheProvider cacheProvider) where T : BaseModel, new()

Parameters

cacheProvider IPostgrestCacheProvider

Returns

IPostgrestTableWithCache<T>

Type Parameters

T