This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-predictions / CommentsApi

CommentsApi ​

Market comments. Reading is public; commenting, liking and listing your own requires a session (UNAUTHENTICATED without one).

Methods ​

create() ​

create(input, options?): Promise<Comment>

Posts a comment (or a reply, with parentId). Requires a session. A new comment may stay pending until moderation. It does not use Idempotency-Key: repeating the call posts again. An empty content is not validated here: the gateway answers INVALID_ARGUMENT.

Parameters ​

input ​
content ​

string

marketId ​

string

parentId? ​

string

options? ​

CallOptions

Returns ​

Promise<Comment>

Example ​

ts
const comment = await predictions.comments.create({ marketId: 'mkt-1', content: 'Concordo' })

Throws ​

UNAUTHENTICATED without a session, INVALID_ARGUMENT (empty content), MARKET_NOT_FOUND and the errors of CommentsApi.list.


like() ​

like(input, options?): Promise<Comment>

Likes a comment and returns the updated comment. Requires a session.

Parameters ​

input ​
commentId ​

string

options? ​

CallOptions

Returns ​

Promise<Comment>

Example ​

ts
const liked = await predictions.comments.like({ commentId: 'cmt-1' })

Throws ​

UNAUTHENTICATED without a session, COMMENT_NOT_FOUND (the gateway may answer with HTTP 500), CONFIGURATION_ERROR without a request if commentId is invalid, and the network/validation errors of CommentsApi.list.


list() ​

list(input, options?): Promise<CommentList>

Lists a market's comments (public, no token). Pagination by limit/offset: the gateway uses 50 by default and total is the market's total comments.

Parameters ​

input ​
limit? ​

number

marketId ​

string

offset? ​

number

options? ​

CallOptions

Returns ​

Promise<CommentList>

Example ​

ts
const { items, total } = await predictions.comments.list({ marketId: 'mkt-1', limit: 20, offset: 0 })

Throws ​

CONFIGURATION_ERROR without a request if marketId is empty, has /, is . or ..; MARKET_NOT_FOUND (the gateway may answer with HTTP 500), NETWORK_ERROR, TIMEOUT, ABORTED, VALIDATION_ERROR or CONFIGURATION_ERROR (including after dispose()). Identify with isEnginexError(error, code).


listMine() ​

listMine(input?, options?): Promise<CommentList>

Lists the logged-in user's comments, with limit/offset (50 by default). Requires a session.

Parameters ​

input? ​
limit? ​

number

offset? ​

number

options? ​

CallOptions

Returns ​

Promise<CommentList>

Example ​

ts
const { items, total } = await predictions.comments.listMine({ limit: 20 })

Throws ​

UNAUTHENTICATED without a session and the network/validation errors of CommentsApi.list.


unlike() ​

unlike(input, options?): Promise<Comment>

Removes a comment's like and returns the updated comment. Requires a session.

Parameters ​

input ​
commentId ​

string

options? ​

CallOptions

Returns ​

Promise<Comment>

Example ​

ts
const comment = await predictions.comments.unlike({ commentId: 'cmt-1' })

Throws ​

As in CommentsApi.like.