Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions docs/p2p/chat/get-message-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Get Message List
sidebar_label: Get Message List
sidebar_position: 3
---

:::tip
Rate limit:
* Global: 100 QPS
* Per User: 10 requests/second

Data within the last 3 months only;
:::

### HTTP Request
POST `/v5/p2p/chat/message/listpage`

### Request Parameters
| Parameter | Required | Type | Comments|
|:----- |:-------|:-----|------ |
|lastId|false |int |ID of the last message on the previous page (descending order); pass 0 to start from the latest|
|limit|**true** |int |Page size, maximum 30|
|sessionId|**true** |string |Session ID |

### Response Parameters
| Parameter | Type | Comments |
| :----------------- | :----- | :-------------------------------------------------------------- |
| messages | array | List of chat messages |
| > id | string | Message ID |
| > sendUserNickName | string | Sender nickname |
| > contentType | string | Message content type. `str` for text, `pic` for image, `pdf` for pdf, `video` for videos |
| > message | string | Message payload as a JSON-encoded string. See a breakdown below |
| >> content | string | For `str`, text content. For `pic`, `pdf`, or `video`, it is an URL |
| >> msgType | integer | Message type code |
| >> fileName | string | File name. Empty for text messages |
| > createDate | string | Message creation timestamp in milliseconds |

### Request Example

<Tabs groupId="programming-languages">
<TabItem value="http" label="HTTP">

```http
POST /v5/p2p/chat/message/listpage HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1675866354698
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"limit": 2,
"sessionId": "rl8BAkdDTQDgSTg+FGrPjr6Vc06F1TWGGU7rg1oLqPDKtM0VNXvL1I7Oo1aPYKKWVbnEEZRclyY+/w=="
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
from bybit_p2p import P2P
api = P2P(
testnet=True,
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
print(api.get_message_list(
sessionId="rl8BAkdDTQDgSTg+FGrPjr6Vc06F1TWGGU7rg1oLqPDKtM0VNXvL1I7Oo1aPYKKWVbnEEZRclyY+/w==",
limit=2
))
```

</TabItem>
</Tabs>

### Response Example

```json
{
"ret_code": 0,
"ret_msg": "SUCCESS",
"result": {
"messages": [
{
"id": "3004232936",
"sendUserNickName": "kolya",
"contentType": "str",
"message": "{\"content\":\"hello world by kolya\",\"msgType\":301,\"fileName\":\"\"}",
"createDate": "1773867363932"
},
{
"id": "3004232935",
"sendUserNickName": "kolya",
"contentType": "pic",
"message": "{\"content\":\"/fiat/p2p/oss/showObj/otc/9001/100571889c0KzUhd1Zw0ytzlu69b2KZn_po8SpHm9x7qtW4h36yY.png?e=1773878266&token=9ElO6c92Gg5gEJPsnUE7vZoSPnO9ivlwEOLJNVuKIB0=&salt=bb32b0e50a5f4fff9a96c1a0843f6208\",\"msgType\":302,\"fileName\":\"grub.png\"}",
"createDate": "1773866621818"
}
]
},
"ext_code": "",
"ext_info": {},
"time_now": "1773867466.080287"
}
```
103 changes: 103 additions & 0 deletions docs/p2p/chat/query-chat-session-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: Query Chat Session List
sidebar_label: Query Chat Session List
sidebar_position: 1
---

Query chat session list.

:::tip
Rate limit:
* Global: 500 QPS
* Per User: 100 requests/second
:::

### HTTP Request
POST `/v5/p2p/chat/session/list`

### Request Parameters
| Parameter | Required | Type | Comments|
|:----- |:-------|:-----|------ |
|size |**true** |integer |Page size|
|lastId |false |integer |ID of the last record on the previous page, used as pagination cursor|
|sessionId |false |string |Encrypted session ID|
|userMaskId |false |string |Masked user ID, obtained from order details (`target_user_mask_id`)|

### Response Parameters
| Parameter | Type | Comments|
|:----- |:-----|----- |
|chatSession |array |Object|
|> sessionName |string |Session display name|
|> sessionId |string |Session ID|
|> type |string |Session type. `GROUP`: Group chat (future version), `SINGLE`: Direct chat|
|> id |integer |Session record ID|

### Request Example

<Tabs groupId="programming-languages">
<TabItem value="http" label="HTTP">

```http
POST /v5/p2p/chat/session/list HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN: XXXXXX
X-BAPI-API-KEY: XXXXXX
X-BAPI-TIMESTAMP: 1772100000000
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"lastId": 0,
"size": 20,
"userMaskId": "sc696b52c224f42e3b4e572fe3d732464"
}
````

</TabItem>
<TabItem value="python" label="Python">

```python
from bybit_p2p import P2P
api = P2P(
testnet=True,
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
print(api.query_chat_session_list(
lastId=0,
size=20,
userMaskId="sc696b52c224f42e3b4e572fe3d732464"
))
```

</TabItem>

<TabItem value="Node" label="Node.js">

```n4js
```

</TabItem>
</Tabs>

### Response Example

```json
{
"ret_code": 0,
"ret_msg": "SUCCESS",
"result": {
"chatSession": [
{
"sessionName": "kolya_3",
"sessionId": "rl8BAkdDTQC57qWq17gyYWlJ7dOD/seTGnXTTYcKcutJMR40VoMaVRPgrH0mr1+MFFt6QcKZC5RS4g==",
"type": "SINGLE",
"id": "1994307488961036288"
}
]
},
"ext_code": "",
"ext_info": {},
"time_now": "1773864599.696081"
}
```
78 changes: 78 additions & 0 deletions docs/p2p/chat/send-chat-msg.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Send Message
sidebar_label: Send Message
sidebar_position: 2
---

:::tip
Rate limit:
* Global: 50 QPS
* Per User: 5 requests/second
:::

### HTTP Request
POST `/v5/p2p/chat/message/send`

### Request Parameters
| Parameter | Required | Type | Comments|
|:----- |:-------|:-----|------ |
|message|**true** |string |Chat message. Is either: the text of the message you send, or the URL of the file you want to send|
|contentType|**true** |string |Chat message type. <ul><li>For text messages use: `STR`</li><li>For images use: `PIC`</li><li>For PDF files use: `PDF`</li><li>For video files use: `VIDEO`</li></ul>|
|sessionId|**true** |string |Session ID |

### Response Parameters
None

### Request Example

<Tabs groupId="programming-languages">
<TabItem value="http" label="HTTP">

```http
POST /v5/p2p/chat/message/send HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1675866354698
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"message": "hi, test",
"contentType": "STR",
"sessionId": "rl8BAkdDTQDgSTg+FGrPjr6Vc06F1TWGGU7rg1oLqPDKtM0VNXvL1I7Oo1aPYKKWVbnEEZRclyY+/w=="
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
from bybit_p2p import P2P
api = P2P(
testnet=True,
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
print(api.send_message(
message="hi, test",
contentType="STR",
sessionId="rl8BAkdDTQDgSTg+FGrPjr6Vc06F1TWGGU7rg1oLqPDKtM0VNXvL1I7Oo1aPYKKWVbnEEZRclyY+/w=="
))
```

</TabItem>
</Tabs>

### Response Example

```json
{
"ret_code": 0,
"ret_msg": "SUCCESS",
"result": null,
"ext_code": "",
"ext_info": {},
"time_now": "1773866621.838588"
}
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Upload Chat File
sidebar_label: Upload Chat File
sidebar_position: 7
sidebar_position: 4
---

### HTTP Request
Expand All @@ -10,7 +10,7 @@ POST `/v5/p2p/oss/upload_file`
:::info
The correct way to operate file uploads is:
1. Upload the file to get your `url`
2. Use <a href="https://bybit-exchange.github.io/docs/p2p/order/send-chat-msg"><b>Send Chat Message</b></a> with a correct `contentType`, like "pic", "pdf" or "video". Put URL into `message`
2. Use <a href="https://bybit-exchange.github.io/docs/p2p/chat/send-chat-msg"><b>Send Message</b></a> with a correct `contentType`, like "PIC", "PDF" or "VIDEO". Put URL into `message`
:::

### Request Parameters
Expand Down
8 changes: 6 additions & 2 deletions docs/p2p/order/chat-msg.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
title: Get Chat Message
sidebar_label: Get Chat Message
title: [DEPRECATED] Get Chat Message
sidebar_label: [DEPRECATED] Get Chat Message
sidebar_position: 8
---

:::caution
DEPRECATED!! Use "Get Message List" method instead.
:::

### HTTP Request
POST `/v5/p2p/order/message/listpage`

Expand Down
8 changes: 6 additions & 2 deletions docs/p2p/order/send-chat-msg.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
title: Send Chat Message
sidebar_label: Send Chat Message
title: [DEPRECATED] Send Chat Message
sidebar_label: [DEPRECATED] Send Chat Message
sidebar_position: 6
---

:::caution
DEPRECATED!! Use "Send Message" method instead.
:::

### HTTP Request
POST `/v5/p2p/order/message/send`

Expand Down
12 changes: 11 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const sidebars = {
},
{
type: 'category',
label: 'Orders',
label: 'Order',
items: [
{
type: 'autogenerated',
Expand All @@ -63,6 +63,16 @@ const sidebars = {
dirName: 'p2p/user'
}
]
},
{
type: 'category',
label: 'Chat',
items: [
{
type: 'autogenerated',
dirName: 'p2p/chat'
}
]
}
],
v5SideBar: [
Expand Down