A Node.js client library that demonstrates API interaction with chat.deepseek.com. This project is created for educational purposes only to understand API interactions, WebAssembly usage, and streaming responses in Node.js.
⚠️ Disclaimer: This project is meant for educational purposes only. It is designed to help developers understand:
- How to work with streaming APIs
- WebAssembly integration in Node.js
- Session management and authentication
- Real-time data processing
- API reverse engineering concepts
Please respect DeepSeek's terms of service and API usage policies.
Visit MCPCore - Your one-stop platform for AI services:
- Access to 30+ AI models in one place
- Advanced AI image generation capabilities
- Premium models including Flux 1 Ultra
- Unified API access
- Production-ready implementations
- Session management with persistent storage
- WebAssembly-based proof-of-work challenge solving
- Streaming response handling
- Message history tracking
- Clean OOP design
-
Clone and Install
# Clone the repository git clone https://github.com/springmusk026/DeepSeek-Chat-API-Client.git # Navigate to the project directory cd DeepSeek-Chat-API-Client # Install dependencies npm install
-
Configure Environment
# Create your environment file cp .env.example .env -
Get Your Token
- Visit chat.deepseek.com
- Sign in to your account
- Open DevTools (F12 or right-click -> Inspect)
- Go to "Application" tab
- In left sidebar, expand "Local Storage"
- Click on "https://chat.deepseek.com"
- Find "userToken" key
- Copy its value and add to your .env file:
DEEPSEEK_TOKEN=your_token_here
# Run with default message
npm start
# Run with custom message
npm start "What is JavaScript?"const { chat } = require('./src');
async function main() {
const token = process.env.DEEPSEEK_TOKEN;
await chat(token, "Hello! How are you?");
}
main().catch(console.error);const DeepseekClient = require('./src/client/DeepseekClient');
async function customChat() {
const client = new DeepseekClient(process.env.DEEPSEEK_TOKEN);
await client.initialize();
const session = await client.createSession();
const response = await client.sendMessage('Hello!', session, {
thinking_enabled: true, // Show AI's thinking process
search_enabled: false // Disable web search
});
// Handle streaming response
for await (const chunk of client.streamResponse(response)) {
process.stdout.write(chunk);
}
}src/
├── client/
│ ├── DeepseekClient.js # Main client implementation
│ └── ChatSession.js # Session management
├── services/
│ └── PowService.js # Proof-of-work implementation
└── config/
└── constants.js # API endpoints & configuration
-
DeepseekClient
- Session management
- Message sending
- Response streaming
-
ChatSession
- Session creation and management
- Message ID tracking
- Parent message handling
-
PowService
- WebAssembly integration
- Proof-of-work challenge solving
- User messages: Odd IDs (1, 3, 5, ...)
- Assistant messages: Even IDs (2, 4, 6, ...)
- Parent message IDs for conversation threading
This project demonstrates:
- API reverse engineering methodology
- WebAssembly integration in Node.js
- Streaming response handling
- Session management patterns
- Clean code architecture
- Error handling best practices
This is an educational project. To contribute:
- Fork the repository
- Create a feature branch
- Submit a pull request
MIT License - See LICENSE file for details.
This project is not affiliated with DeepSeek. It is an educational demonstration of API interaction patterns and should not be used in production environments or to circumvent any service limitations or terms of use.
⚠️ Note: This is a proof-of-concept implementation for educational purposes. Always respect API providers' terms of service and usage policies.