1.1.0 • Published 5 months ago

okx-api-connection v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

OKX API CONNECTION

OKX API CONNECTION is a Node.js package for interacting with the OKX API.

Installation

To use the package, follow these steps:

1. Add the package to your project:

npm install okx-api-connection
  • Start using the package in your project:
const { apiCall, apiConfiguration } = require('okx-api-connection');

// Set up API configuration
const apiKey = {
apiKey: 'YOUR_API_KEY',
secretKey: 'YOUR_SECRET_KEY',
passphrase: 'YOUR_PASSPHRASE'
};
const config = apiConfiguration(apiKey);

// Example API call
apiCall({
method: 'GET',
url: '/your-api-endpoint',
apiConfiguration: config,
query: { param1: 'value1', param2: 'value2' }
})
.then(response => {
console.log('API Response:', response);
})
.catch(error => {
console.error('Error:', error);
});

Functions

apiCall

The apiCall function is used to make an HTTP request to the OKEx API.

apiCall({
method: 'GET' | 'POST',
url: '/your-api-endpoint',
apiConfiguration: config,
query?: { param1: string, param2: string },
requestBody?: Record<string, string>
})
  • method: The HTTP method ('GET' or 'POST').
  • url: The API endpoint.
  • apiConfiguration: API keys and other configuration.
  • query: Optional, URL query parameters.
  • requestBody: Optional, body data for a POST request.

apiConfiguration

The apiConfiguration function is used to configure your API keys.

const apiKey = {
apiKey: 'YOUR_API_KEY',
secretKey: 'YOUR_SECRET_KEY',
passphrase: 'YOUR_PASSPHRASE'
};
const config = apiConfiguration(apiKey);
1.1.0

5 months ago

1.0.0

5 months ago