@ceramic-sdk/http-client v0.2.1 • Docs
Ceramic SDK / @ceramic-sdk/http-client / CeramicClient
Represents an HTTP client for interacting with the Ceramic One server.
This class provides methods for working with Ceramic events, including fetching, decoding, and posting events. It also supports retrieving server metadata and managing stream interests.
new CeramicClient(
params):CeramicClient
Creates a new instance of CeramicClient.
• params: ClientParams
Configuration options for initializing the client.
getapi():Client<paths, `${string}/${string}`>
Retrieves the OpenAPI client instance.
Client<paths, `${string}/${string}`>
The internal OpenAPI client used for making HTTP requests.
getEvent(
id):Promise<object>
Fetches a raw event response by its unique event CID.
• id: string
The unique identifier (CID) of the event to fetch.
Promise<object>
A Promise that resolves to the event schema.
optionaldata:string
Multibase encoding of event data.
id:
string
Multibase encoding of event root CID bytes.
Will throw an error if the request fails or the server returns an error.
getEventCAR(
id):Promise<CAR>
Fetches the CAR-encoded event for a given event CID.
• id: string
The unique identifier (CID) of the event.
Promise<CAR>
A Promise that resolves to a CAR object representing the event.
getEventData(
id):Promise<string>
Fetches the string-encoded event data for a given event CID.
• id: string
The unique identifier (CID) of the event to fetch.
Promise<string>
A Promise that resolves to the event's string data.
Will throw an error if the event data is missing.
getEventsFeed(
params):Promise<object>
Retrieves the events feed based on provided parameters.
• params: EventsFeedParams = {}
Options for paginated feeds, including resume tokens and limits.
Promise<object>
A Promise that resolves to the events feed schema.
events:
object[]
An array of events. For now, the event data payload is empty.
resumeToken:
string
The token/highwater mark to used as resumeAt on a future request
getEventType<
Payload>(decoder,id):Promise<Payload|MapIn<RequiredProps<object>,$TypeOf> &MapIn<OptionalProps<object>,$TypeOf>>
Decodes and retrieves a specific event type using the provided decoder.
• Payload
• decoder: Decoder<unknown, Payload>
The decoder used to interpret the event data.
• id: string
The unique identifier (CID) of the event.
Promise<Payload | MapIn<RequiredProps<object>, $TypeOf> & MapIn<OptionalProps<object>, $TypeOf>>
A Promise that resolves to the decoded event payload or a signed event.
getVersion():
Promise<object>
Retrieves the version information of the Ceramic One server.
Promise<object>
A Promise that resolves to the server version schema.
optionalversion:string
Version of the Ceramic node
postEvent(
data):Promise<void>
Posts a string-encoded event to the server.
• data: string
The string-encoded event data to post.
Promise<void>
A Promise that resolves when the request completes.
Will throw an error if the request fails.
postEventCAR(
car):Promise<CID<unknown,number,number,Version>>
Posts a CAR-encoded event to the server.
• car: CAR
The CAR object representing the event.
Promise<CID<unknown, number, number, Version>>
A Promise that resolves to the CID of the posted event.
postEventType(
codec,event):Promise<CID<unknown,number,number,Version>>
Encodes and posts an event using a specified codec.
• codec: Codec<unknown, unknown, unknown>
The codec used to encode the event.
• event: unknown
The event data to encode and post (must be compatible with the codec).
Promise<CID<unknown, number, number, Version>>
A Promise that resolves to the CID of the posted event.
registerInterestModel(
model):Promise<void>
Registers interest in a model stream using its model stream ID.
• model: string
The stream ID of the model to register interest in.
Promise<void>
A Promise that resolves when the request completes.
Will throw an error if the request fails.