bybit-p2p-sdk
v1.0.0
Published
Bybit P2P Node.js SDK (TypeScript)
Maintainers
Readme
bybit-p2p-sdk
Bybit P2P API SDK for Node.js (TypeScript)
bybit-p2p-sdk is the unofficial Node.js SDK for Bybit's P2P API, enabling seamless integration of your software solutions with Bybit's P2P trading platform.
- Full Type Support: Written in TypeScript with complete definitions.
- Easy Authentication: Handles HMAC signature generation automatically.
- Actively Maintained: Supports latest V5 P2P endpoints.
Features
This SDK implements all key methods available for the P2P API:
- Create, edit, delete, activate advertisements
- Get pending orders, mark orders as paid, release assets
- Get, send text messages, and upload files to chat
- Get all public advertisements
- And more!
Installation
npm install bybit-p2p-sdkUsage
TypeScript
import { P2P } from 'bybit-p2p-sdk';
const client = new P2P({
testnet: false, // Set to true for testnet
apiKey: "YOUR_API_KEY",
apiSecret: "YOUR_API_SECRET"
});
// 1. Get current balance
const balance = await client.getCurrentBalance({ accountType: "FUND", coin: "USDT" });
console.log(balance);
// 2. Get pending orders
const orders = await client.getPendingOrders({ page: 1, size: 10 });
console.log(orders);Configuration
The P2P constructor accepts the following config:
testnet:boolean(default: false)apiKey:stringapiSecret:stringrecvWindow:number(default: 20000) - Time window for request validity
Documentation
This library provides a direct wrapper around Bybit's P2P REST API. Official Documentation: P2P API Guide
API Method Mapping
Here is how the SDK methods map to the API endpoints:
Advertisements
| SDK Method | API Endpoint | Description |
| --- | --- | --- |
| getOnlineAds() | /v5/p2p/item/online | Get public online ads |
| postNewAd() | /v5/p2p/item/create | Post a new ad |
| removeAd() | /v5/p2p/item/cancel | Cancel an ad |
| updateAd() | /v5/p2p/item/update | Update or relist an ad |
| getAdsList() | /v5/p2p/item/personal/list | Get my ads list |
| getAdDetails() | /v5/p2p/item/info | Get ad details |
Orders
| SDK Method | API Endpoint | Description |
| --- | --- | --- |
| getOrders() | /v5/p2p/order/simplifyList | Get all orders |
| getOrderDetails() | /v5/p2p/order/info | Get order details |
| getPendingOrders() | /v5/p2p/order/pending/simplifyList | Get pending orders |
| markAsPaid() | /v5/p2p/order/pay | Mark order as paid |
| releaseAssets() | /v5/p2p/order/finish | Release crypto to buyer |
| sendChatMessage() | /v5/p2p/order/message/send | Send a chat message |
| uploadChatFile() | /v5/p2p/oss/upload_file | Upload a file to chat |
| getChatMessages() | /v5/p2p/order/message/listpage | Get chat history |
User Info
| SDK Method | API Endpoint | Description |
| --- | --- | --- |
| getAccountInformation() | /v5/p2p/user/personal/info | Get my account info |
| getCounterpartyInfo() | /v5/p2p/user/order/personal/info | Get counterparty info |
| getUserPaymentTypes() | /v5/p2p/user/payment/list | Get my payment methods |
Misc
| SDK Method | API Endpoint | Description |
| --- | --- | --- |
| getCurrentBalance() | /v5/asset/transfer/query-account-coins-balance | Get wallet balance |
Development
Contributions are welcome!
Build
npm run buildRun Examples
npx ts-node examples/quickstart.ts🤝 Contributing
Contributions are welcome! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Code Style
- Follow TypeScript best practices
- Use ESLint and Prettier (configured in project)
- Write tests for new features
- Update documentation as needed
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Links
- Issues: GitHub Issues
- Discussions: GitHub Discussions
📞 Support
For questions and support:
- Check the Documentation section
- Open an Issue
Built with ❤️ for traders by ENGR-ABI
