
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
deriv-api-ts
Advanced tools
A typescript wrapper around Deriv API.
yarn add deriv-api-ts
npm install deriv-api-ts
import { DerivAPIWrapper } from 'deriv-api-ts';
const appId = 1234;
const api = new DerivAPIWrapper(appId);
const websiteStatus = await api.websiteStatus();
console.log(websiteStatus);
// You will have intellisense on the return types...
console.log(websiteStatus.api_call_limits.max_requests_outcome.hourly);
You can authenticate whenever you want by calling authorize
function. When you call an endpoint that needs
authentication (e.g. profitTable
), it will first check if the session is already authenticated. If not, it will try to
authenticate with the token that is passed either to the constructor or to the last call of authorize
function. If no
token is found, an error will be thrown.
import { DerivAPIWrapper } from 'deriv-api-ts';
const appId = 1234;
const api = new DerivAPIWrapper(appId);
const authResult = await api.authorize('YOUR API TOKEN');
OR
import { DerivAPIWrapper } from 'deriv-api-ts';
const appId = 1234;
const api = new DerivAPIWrapper(appId, 'YOUR API TOKEN');
@deriv/api-types
package is used internally to provide support for types.
import { DerivAPIWrapper, Exception, Types as binaryTypes } from 'deriv-api-ts';
const appId = 1234;
const api = new DerivAPIWrapper(appId, 'YOUR API TOKEN');
const params: binaryTypes.ProfitTableRequest = {
contract_type : [ 'CALL' ],
profit_table : 1,
};
api.profitTable(params)
.then((profitTableResult: binaryTypes.ProfitTable) =>
{
// Your code
})
.catch((err: Exception) =>
{
console.log(`Code: ${ errObj.code } Message: ${ errObj.message } Details: ${ JSON.stringify(errObj.getParams()) }`);
})
// Closing the websocket connection gracefully.
.finally(() => api.disconnect());
import { DerivAPIWrapper, Exception, Types } from 'deriv-api-ts';
const appId = 1234;
const api = new DerivAPIWrapper(1234, 'YOUR API TOKEN');
const params: Types.ProfitTableRequest = {
contract_type : [],
profit_table : 1,
};
api.profitTable(params)
.then((profitTableResult) =>
{
// Your code
})
.catch((err: Exception) =>
{
console.log(`Code: ${ errObj.code } Message: ${ errObj.message } Details: ${ JSON.stringify(errObj.getParams()) }`);
})
// Closing the websocket connection gracefully.
.finally(() => api.disconnect());
OR
import { DerivAPIWrapper, Exception, Types } from 'deriv-api-ts';
const appId = 1234;
const api = new DerivAPIWrapper(1234, 'YOUR API TOKEN');
const params: Types.ProfitTableRequest = {
contract_type : [],
profit_table : 1,
};
try
{
const profitTableResult = await api.profitTable(params);
}
catch (err)
{
const errObj = err as Exception;
console.log(`Code: ${ errObj.code } Message: ${ errObj.message } Details: ${ JSON.stringify(errObj.getParams()) }`);
}
finally
{
// Closing the websocket connection gracefully.
api.disconnect();
}
FAQs
A typescript wrapper around Deriv API
The npm package deriv-api-ts receives a total of 13 weekly downloads. As such, deriv-api-ts popularity was classified as not popular.
We found that deriv-api-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.