Skip to content

Commit 8931573

Browse files
saminacodeskien-ngo
authored andcommitted
added data
1 parent 6685d5e commit 8931573

File tree

15 files changed

+509
-266
lines changed

15 files changed

+509
-266
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// data.js
2+
3+
export const chatEndpointData = {
4+
title: "Initiate Chat",
5+
method: "POST",
6+
description: "Starts a new chat session with the specified parameters.",
7+
endpointUrl: "/chat",
8+
parameters: [],
9+
headers: [
10+
{
11+
name: "x-secret-key",
12+
required: true,
13+
description: "Your thirdweb secret key for authentication.",
14+
type: "string",
15+
},
16+
{
17+
name: "Content-Type",
18+
required: true,
19+
description: "Indicates the media type of the request body.",
20+
type: "string",
21+
},
22+
],
23+
bodyParameters: [
24+
{
25+
name: "user_id",
26+
required: true,
27+
description: "The unique identifier for the user starting the chat.",
28+
type: "string",
29+
},
30+
{
31+
name: "message",
32+
required: true,
33+
description: "The initial message to start the chat.",
34+
type: "string",
35+
},
36+
{
37+
name: "metadata",
38+
required: false,
39+
description: "Optional metadata associated with the chat session.",
40+
type: "object",
41+
},
42+
],
43+
codeExamples: [
44+
{
45+
language: "curl",
46+
code: `curl -X POST https://nebula-api.thirdweb.com/chat \\
47+
-H "x-secret-key: YOUR_THIRDWEB_SECRET_KEY" \\
48+
-H "Content-Type: application/json" \\
49+
-d '{"user_id": "user123", "message": "Hello!", "metadata": {"topic": "support"}}'`,
50+
},
51+
{
52+
language: "JavaScript",
53+
code: `const axios = require('axios');
54+
55+
const secretKey = 'YOUR_THIRDWEB_SECRET_KEY';
56+
57+
axios.post('https://nebula-api.thirdweb.com/chat', {
58+
user_id: 'user123',
59+
message: 'Hello!',
60+
metadata: { topic: 'support' },
61+
}, {
62+
headers: {
63+
'x-secret-key': secretKey,
64+
'Content-Type': 'application/json',
65+
},
66+
})
67+
.then(response => {
68+
console.log("Chat initiated successfully.", response.data);
69+
})
70+
.catch(error => {
71+
console.error(error);
72+
});`,
73+
},
74+
],
75+
apiResponses: [
76+
{
77+
status: "201",
78+
description: "Chat initiated successfully.",
79+
code: `{
80+
"chat_id": "chat123",
81+
"status": "active",
82+
"created_at": "2024-01-01T00:00:00Z"
83+
}`,
84+
},
85+
{
86+
status: "400",
87+
description: "Invalid input data.",
88+
code: `{
89+
"error": "Missing user_id or message."
90+
}`,
91+
},
92+
{
93+
status: "403",
94+
description: "Unauthorized request.",
95+
code: `{
96+
"error": "Invalid secret key."
97+
}`,
98+
},
99+
],
100+
};

apps/portal/src/app/nebula/api-reference/chat/page.mdx

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,7 @@
1-
### Send Message
1+
import { ApiEndpoint} from '@doc';
2+
import { chatEndpointData } from './data';
23

3-
```http
4-
POST /chat
5-
```
6-
7-
**Request Body:**
8-
```json
9-
{
10-
"message": "Find the last 5 blocks",
11-
"session_id": "abc",
12-
"stream": true,
13-
"context_filter": {
14-
"chain_ids": [137],
15-
"contract_addresses": ["0x..."],
16-
"wallet_addresses": ["0x..."]
17-
},
18-
"execute_config": {
19-
"mode": "client",
20-
"signer_wallet_address": "0x..."
21-
}
22-
}
23-
```
24-
25-
**Request Parameters:**
26-
27-
- `message` (required)
28-
- Type: string
29-
- Description: The user's input message or command to be processed by Nebula
30-
31-
- `session_id` (optional)
32-
- Type: string
33-
- Description: Identifier for maintaining conversation context
34-
- Default: A new session will be created if omitted
35-
36-
- `stream` (optional)
37-
- Type: boolean
38-
- Description: Controls whether the response is streamed or returned as a single response
39-
- Default: false
40-
41-
- `context_filter` (optional)
42-
- Type: object
43-
- Description: Controls which blockchain data sources are used for context
44-
- Properties:
45-
- `chain_ids`: Array of numbers representing blockchain network IDs
46-
- `contract_addresses`: Array of strings containing contract addresses to focus on
47-
48-
- `execute_config` (optional)
49-
- Type: object
50-
- Description: Configuration for transaction execution
51-
- Properties:
52-
- `mode`: String indicating execution mode (currently only "client" is supported)
53-
- `signer_wallet_address`: String containing the wallet address that will sign transactions
54-
55-
#### Chat Messages
56-
57-
Chat messages are natural language responses from Nebula. They appear in the `message` field of the response and provide formatted information, explanations, or answers to your queries. Messages can include formatted text, blockchain data, and technical details.
58-
59-
**Example Response with Chat Message:**
60-
```json
61-
{
62-
"message": "The last block on the Arbitrum mainnet is block number **284204124**. Here are the details:\n\n- **Block Hash:** 0xf42e3d624ae1e3fd6b89d4680f39943eb1cd3b8f0606918ef818d3021b7724f1\n- **Parent Hash:** 0x4c45cd0964281833b070b633980d8f530debdd21dfbdbf6eddf96cc93cbaac8e\n- **Timestamp:** 1734063299\n- **Gas Used:** 5,064,851\n- **Gas Limit:** 1,125,899,906,842,624\n- **Base Fee per Gas:** 10,000,000\n- **Transaction Count:** 7\n- **Withdrawals Count:** 0\n\nIf you need any more information about this block or related transactions, feel free to ask!",
63-
"actions": [],
64-
"session_id": "5d579903-5a63-434f-8667-788adfae9304",
65-
"request_id": "d46cfb80-de6a-48a6-9a97-746e1708d066"
66-
}
67-
```
68-
69-
Response properties:
70-
- `message`: A formatted string containing the response, which may include:
71-
- Markdown formatting for better readability
72-
- Technical data (hashes, addresses, numbers)
73-
- Structured information about blockchain state
74-
- `actions`: Array of actions (empty when no transactions are needed)
75-
- `session_id`: Unique identifier for the current session
76-
- `request_id`: Unique identifier for the specific request
4+
<ApiEndpoint {...chatEndpointData} />
775

786
#### Chat Actions
797

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// data.js
2+
3+
export const clearSessionEndpointData = {
4+
title: "Clear Session",
5+
method: "POST",
6+
description:
7+
"Clears all messages for a specific session using the session ID.",
8+
endpointUrl: "/session/{session_id}/clear",
9+
parameters: [
10+
{
11+
name: "session_id",
12+
required: true,
13+
description: "The unique identifier of the session to clear.",
14+
type: "string",
15+
},
16+
],
17+
headers: [
18+
{
19+
name: "x-secret-key",
20+
required: true,
21+
description: "Your thirdweb secret key for authentication.",
22+
type: "string",
23+
},
24+
],
25+
bodyParameters: [],
26+
codeExamples: [
27+
{
28+
language: "curl",
29+
code: `curl -X POST https://nebula-api.thirdweb.com/session/{session_id}/clear \\
30+
-H "x-secret-key: YOUR_THIRDWEB_SECRET_KEY"`,
31+
},
32+
],
33+
apiResponses: [
34+
{
35+
status: "200",
36+
description: "Session messages cleared successfully.",
37+
code: `{
38+
"message": "All session messages have been cleared."
39+
}`,
40+
},
41+
{
42+
status: "404",
43+
description: "Session not found.",
44+
code: `{
45+
"error": "Session with ID 'abc123' not found." }`,
46+
},
47+
],
48+
};
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
#### Clear Session
1+
import { ApiEndpoint} from '@doc';
2+
import { clearSessionEndpointData } from './data';
23

3-
Clear a session's message history.
4-
5-
```bash
6-
POST /session/{session_id}/clear
7-
```
8-
9-
**Example curl:**
10-
```bash
11-
curl -X POST https://nebula-api.thirdweb.com/session/abc123/clear \
12-
-H "x-secret-key: YOUR_THIRDWEB_SECRET_KEY"
13-
```
4+
<ApiEndpoint {...clearSessionEndpointData} />
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// data.js
2+
3+
export const createSessionEndpointData = {
4+
title: "Create Session",
5+
method: "POST",
6+
description: "Creates a new session.",
7+
endpointUrl: "/session",
8+
parameters: [],
9+
headers: [
10+
{
11+
name: "x-secret-key",
12+
required: true,
13+
description: "Your thirdweb secret key for authentication.",
14+
type: "string",
15+
},
16+
],
17+
bodyParameters: [
18+
{
19+
name: "session_name",
20+
required: true,
21+
description: "The name for the new session.",
22+
type: "string",
23+
},
24+
{
25+
name: "metadata",
26+
required: false,
27+
description: "Optional metadata to associate with the session.",
28+
type: "object",
29+
},
30+
],
31+
codeExamples: [
32+
{
33+
language: "curl",
34+
code: `curl -X POST https://nebula-api.thirdweb.com/session \\
35+
-H "x-secret-key: YOUR_THIRDWEB_SECRET_KEY" \\
36+
-d '{"session_name": "my_new_session", "metadata": {"key": "value"}}'`,
37+
},
38+
{
39+
language: "JavaScript",
40+
code: `const axios = require('axios');
41+
42+
const secretKey = 'YOUR_THIRDWEB_SECRET_KEY';
43+
44+
axios.post('https://nebula-api.thirdweb.com/session', {
45+
session_name: 'my_new_session',
46+
metadata: { key: 'value' },
47+
}, {
48+
headers: {
49+
'x-secret-key': secretKey,
50+
},
51+
})
52+
.then(response => {
53+
console.log("Session created successfully.", response.data);
54+
})
55+
.catch(error => {
56+
console.error(error);
57+
});`,
58+
},
59+
],
60+
apiResponses: [
61+
{
62+
status: "201",
63+
description: "Session created successfully.",
64+
code: `{
65+
"session_id": "abc123",
66+
"session_name": "my_new_session",
67+
"metadata": {
68+
"key": "value"
69+
},
70+
"created_at": "2024-01-01T00:00:00Z"
71+
}`,
72+
},
73+
{
74+
status: "400",
75+
description: "Invalid input data.",
76+
code: `{
77+
"error": "Invalid session name provided."
78+
}`,
79+
},
80+
],
81+
};
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
#### Create Session
1+
import { ApiEndpoint } from '@doc';
2+
import { createSessionEndpointData } from './data';
23

3-
Create a new chat session.
4-
5-
```bash
6-
POST /session
7-
```
8-
**Request Body:**
9-
```tsx
10-
{
11-
"title": "My DeFi Research", // Optional: Custom session title
12-
"is_public": true, // Optional: Make session publicly accessible
13-
"context_filter": { // Optional: Filter data sources
14-
"chain_ids": [1],
15-
"contract_addresses": ["0x..."]
16-
}
17-
}
18-
```
19-
20-
**Example curl:**
21-
```bash
22-
curl -X POST https://nebula-api.thirdweb.com/session \
23-
-H "Content-Type: application/json" \
24-
-H "x-secret-key: YOUR_THIRDWEB_SECRET_KEY" \
25-
-d '{
26-
"title": "My DeFi Research",
27-
"is_public": true,
28-
"context_filter": {
29-
"chain_ids": [1]
30-
}
31-
}'
32-
```
4+
<ApiEndpoint {...createSessionEndpointData} />

0 commit comments

Comments
 (0)