diff --git a/docs/p2p/chat/get-message-list.mdx b/docs/p2p/chat/get-message-list.mdx new file mode 100644 index 0000000000..8f7d2a6060 --- /dev/null +++ b/docs/p2p/chat/get-message-list.mdx @@ -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 + + + + +```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==" +} +``` + + + + +```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 +)) +``` + + + + +### 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" +} +``` diff --git a/docs/p2p/chat/query-chat-session-list.mdx b/docs/p2p/chat/query-chat-session-list.mdx new file mode 100644 index 0000000000..b5bf62eaff --- /dev/null +++ b/docs/p2p/chat/query-chat-session-list.mdx @@ -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 + + + + +```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" +} +```` + + + + +```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" +)) +``` + + + + + +```n4js +``` + + + + +### 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" +} +``` \ No newline at end of file diff --git a/docs/p2p/chat/send-chat-msg.mdx b/docs/p2p/chat/send-chat-msg.mdx new file mode 100644 index 0000000000..3c5c9af32b --- /dev/null +++ b/docs/p2p/chat/send-chat-msg.mdx @@ -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. | +|sessionId|**true** |string |Session ID | + +### Response Parameters +None + +### Request Example + + + + +```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==" +} +``` + + + + +```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==" +)) +``` + + + + +### Response Example + +```json +{ + "ret_code": 0, + "ret_msg": "SUCCESS", + "result": null, + "ext_code": "", + "ext_info": {}, + "time_now": "1773866621.838588" +} +``` diff --git a/docs/p2p/order/upload-chat-file.mdx b/docs/p2p/chat/upload-chat-file.mdx similarity index 88% rename from docs/p2p/order/upload-chat-file.mdx rename to docs/p2p/chat/upload-chat-file.mdx index de26c7c5e7..fe9ef0bb4d 100644 --- a/docs/p2p/order/upload-chat-file.mdx +++ b/docs/p2p/chat/upload-chat-file.mdx @@ -1,7 +1,7 @@ --- title: Upload Chat File sidebar_label: Upload Chat File -sidebar_position: 7 +sidebar_position: 4 --- ### HTTP Request @@ -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 Send Chat Message with a correct `contentType`, like "pic", "pdf" or "video". Put URL into `message` +2. Use Send Message with a correct `contentType`, like "PIC", "PDF" or "VIDEO". Put URL into `message` ::: ### Request Parameters diff --git a/docs/p2p/order/chat-msg.mdx b/docs/p2p/order/chat-msg.mdx index 99709e7005..1b2beb676a 100644 --- a/docs/p2p/order/chat-msg.mdx +++ b/docs/p2p/order/chat-msg.mdx @@ -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` diff --git a/docs/p2p/order/send-chat-msg.mdx b/docs/p2p/order/send-chat-msg.mdx index a225b1da56..1d2e485099 100644 --- a/docs/p2p/order/send-chat-msg.mdx +++ b/docs/p2p/order/send-chat-msg.mdx @@ -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` diff --git a/sidebars.js b/sidebars.js index c75c2a9009..fa6b1708af 100644 --- a/sidebars.js +++ b/sidebars.js @@ -46,7 +46,7 @@ const sidebars = { }, { type: 'category', - label: 'Orders', + label: 'Order', items: [ { type: 'autogenerated', @@ -63,6 +63,16 @@ const sidebars = { dirName: 'p2p/user' } ] + }, + { + type: 'category', + label: 'Chat', + items: [ + { + type: 'autogenerated', + dirName: 'p2p/chat' + } + ] } ], v5SideBar: [