---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-predictions/interfaces/CommentsApi.md
---
[Reference](../../../index.md) / [@getenginex/sdk-predictions](../index.md) / 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`](Comment.md)>

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`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Comment`](Comment.md)>

#### 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](#list).

***

### like()

> **like**(`input`, `options?`): `Promise`<[`Comment`](Comment.md)>

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

#### Parameters

##### input

###### commentId

`string`

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Comment`](Comment.md)>

#### 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()

> **list**(`input`, `options?`): `Promise`<[`CommentList`](CommentList.md)>

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`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`CommentList`](CommentList.md)>

#### 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`](CommentList.md)>

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

#### Parameters

##### input?

###### limit?

`number`

###### offset?

`number`

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`CommentList`](CommentList.md)>

#### Example

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

#### Throws

`UNAUTHENTICATED` without a session and the network/validation errors of
[CommentsApi.list](#list).

***

### unlike()

> **unlike**(`input`, `options?`): `Promise`<[`Comment`](Comment.md)>

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

#### Parameters

##### input

###### commentId

`string`

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Comment`](Comment.md)>

#### Example

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

#### Throws

As in [CommentsApi.like](#like).
