OKX API Connect is a TypeScript library for seamless integration with the OKX exchange API. This library streamlines the process of making public and private API calls to OKX, providing endpoints for retrieving market data, managing orders, and more.
Install the package via npm:
npm install okx-api-connect
Before making API calls, initialize the API configuration.
import { ApiConfiguration } from "okx-api-connect/types/types";
const apiConfig: ApiConfiguration = {
apiKey: "your-api-key",
secretKey: "your-secret-key",
passphrase: "your-passphrase",
};
The OkxPublicService class provides methods for making public API calls.
import { OkxPublicService } from "okx-api-connect/services/publicService";
const publicService = new OkxPublicService(apiConfig);
// Example: Get currencies
publicService.getCurrencies().then((response) => {
console.log(response);
});
The OkxOrderService class provides methods for making order-related API calls.
import { OkxOrderService } from "okx-api-connect/services/orderService";
const orderService = new OkxOrderService(apiConfig);
// Example: Get order history
orderService.getOrderHistory({ instType: "SPOT" }).then((response) => {
console.log(response);
});
- Package Name: okx-api-connect
- Version: 1.2.0
- dev: Start the development server using ts-node-dev.
- build: Build the project using ts-node.
- build-ex: Build the project using tsc.
- @types/node: ^20.10.1
- ts-node: ^10.9.1
- ts-node-dev: ^2.0.0
- typescript: ^5.3.2
This project is licensed under the ISC License - see the LICENSE.md file for details.