Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit d0e6842

Browse files
committed
Merge branch 'master' into markupvalue
2 parents f217fdd + bc14e9f commit d0e6842

File tree

24 files changed

+125
-81
lines changed

24 files changed

+125
-81
lines changed

docs/_intro_backup.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ tags:
99
keywords:
1010
- deriv
1111
- api
12-
- getting
13-
- started
12+
- getting started
1413
description: Getting started with Deriv API
1514
---
1615

docs/core-concepts/api-calls-anatomy/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ keywords:
1515
- anatomy
1616
description: Deriv API calls' anatomy
1717
---
18+
1819
## Subscribe and send
1920

2021
All API calls have a send functionality for making a request and receiving a response. Certain API calls also offer a subscribe functionality allowing for updates to be sent to your application when new information becomes available.
2122

2223
### Subscribe
2324

24-
Several API calls provide the `subscribe` functionality. When you subscribe to an API call, you will receive a continuous stream of data of this particular API call.
25+
Several API calls provide the `subscribe` functionality. When you subscribe to an API call, you will receive a continuous stream from data of this particular API call.
2526

2627
Some of these API calls automatically subscribe (e.g. [ticks](https://api.deriv.com/api-explorer#ticks)) and some have an optional `subscribe` field. If you pass `1` to the `subscribe` field, the subscription will start and the server will continue to send the requested data until you unsubscribe by calling the `Forget` or `Forget all` API calls.
2728

@@ -43,7 +44,6 @@ If you want to stop the message stream created by `subscribe`, you will have to
4344
For more information on the `Forget` API call, have a look at [Forget](https://api.deriv.com/api-explorer#forget) and [Forget All](https://api.deriv.com/api-explorer#forget_all) in the API explorer.
4445
:::
4546

46-
4747
## Request data
4848

4949
To make it easier for you to handle the request and response flow of your WebSocket connection, each Deriv WebSocket API call follows a standardised structure. You can use it for caching, validation, request, and response synchronisation.
@@ -84,7 +84,7 @@ Whatever you pass to this field will be returned back to you inside a `response`
8484

8585
#### The `req_id` field
8686

87-
You may need to `tag` your requests and pass them through our `WebSocket` calls. You can do so by passing a `number` to this field. it can be helpful when you need to map `requests` to `responses`.
87+
You may need to `tag` your requests and pass them through our `WebSocket` calls. You can do so by passing a `number` to this field. It can be helpful when you need to map `requests` to `responses`.
8888

8989
:::caution
9090
To learn about additional optional fields specific to each API call, please refer to our [API Explorer](https://api.deriv.com/api-explorer).

docs/core-concepts/authorization-authentication/index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ keywords:
1212
- deriv-authorisation
1313
description: Deriv API authorisation and authentication
1414
---
15+
1516
Without authorisation and authentication you'll only get access to roughly half of our API calls and features. For example, in order to buy contracts or utilise the `Copy Trading` features, your users must be authenticated and authorised by our **OAuth** provider and **WebSocket Server**.
1617

1718
## Before we start
@@ -20,12 +21,12 @@ Please make sure you have all the requirements mentioned below to continue.
2021

2122
### Requirements
2223

23-
1. Deriv account
24+
1. Deriv account
2425
2. Deriv API token with the appropriate access level
25-
3. Deriv app ID
26+
3. Deriv app ID
2627

2728
:::note
28-
Please refer to [Setting up a Deriv application](docs/setting-up-a-deriv-application.md) for detailed instructions how to create a Deriv API token and application.
29+
Please refer to [Setting up a Deriv application](docs/setting-up-a-deriv-application.md) for detailed instructions on how to create a Deriv API token and application.
2930
:::
3031

3132
### API token
@@ -84,14 +85,17 @@ const user_accounts = [
8485
},
8586
];
8687
```
87-
To authorise the user based on the user's **selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **selected** account **session token**:
88+
89+
To authorise the user based on the user's **selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **selected** account **session token**:
90+
8891
```js
8992
{
9093
"authorize": "a1-f7pnteezo4jzhpxclctizt27hyeot"
9194
}
9295
```
9396

9497
The response for the `authorize` call would be an object as below:
98+
9599
```js
96100
{
97101
"account_list": [
@@ -145,4 +149,5 @@ The response for the `authorize` call would be an object as below:
145149
"user_id": 12345678
146150
}
147151
```
152+
148153
Now, the user is authorised, and you can use Deriv API calls on behalf of the account.

docs/core-concepts/websocket/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ WebSockets are an essential client-server communication tool. To benefit the mos
8383

8484
Use WebSockets in the following cases:
8585

86-
1. ‍When you're developing a real-time web application.
87-
The most customary use of WebSocket is in real-time application development wherein it assists in a continual display of data at the client end. As the back-end server sends back this data continuously, a WebSocket allows uninterrupted pushing or transmitting of this data in the already open connection. The use of WebSockets makes such data transmission quick and leverages the application's performance.
88-
2. For trading websites, such as Deriv.
89-
Here, WebSocket assist in data handling that is impelled by the deployed back-end server to the client.
86+
1. ‍When you're developing a real-time web application.
87+
The most customary use of WebSocket is in real-time application development wherein it assists in a continual display of data at the client end. As the back-end server sends back this data continuously, a WebSocket allows uninterrupted pushing or transmitting of this data in the already open connection. The use of WebSockets makes such data transmission quick and leverages the application's performance.
88+
2. For trading websites, such as Deriv.
89+
Here, WebSocket assists in data handling that is impelled by the deployed back-end server to the client.
9090
3. ‍When creating a chat application.
91-
Chat application developers call out WebSockets for help in operations like a one-time exchange and publishing/broadcasting messages. As the same WebSocket connection is used for sending/receiving messages, communication becomes easy and quick.
91+
Chat application developers call out WebSockets for help in operations like a one-time exchange and publishing/broadcasting messages. As the same WebSocket connection is used for sending/receiving messages, communication becomes easy and quick.
9292

9393
Now that we've established where WebSockets should be used, let's see where it is best to avoid them. This will help you steer clear of unnecessary operational hassles.
9494

docs/intro.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ sidebar_label: Introduction
66
sidebar_position: 0
77
tags:
88
- introduction
9-
- getting
10-
- started
11-
- quick
12-
- start
9+
- getting started
10+
- quick startup
1311
keywords:
1412
- deriv
1513
- api
16-
- getting
17-
- started
18-
- quick
19-
- start
14+
- getting started
15+
- quick startup
2016
description: Getting started with Deriv API
2117
---
2218

@@ -49,4 +45,5 @@ When using our code examples, we also suggest to have a look at our [Languages](
4945
If you want to know for example how you can `monetize your application` or how to create a `secure way for users to log in` to your application, then we provide a handful of [Guides](/docs/category/guides) that can assist you with that.
5046

5147
#### Setting up a Deriv application
48+
5249
If you want to know more about the essentials that are needed to setup your own application, then have a look at the [Setting up a Deriv application](/docs/setting-up-a-deriv-application) section.

docusaurus.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const config = {
9999
label: 'API Explorer',
100100
},
101101
{ to: 'https://tech.deriv.com/', label: 'Blog', position: 'left' },
102+
{ to: 'https://hackerone.com/deriv?type=team', label: 'Bug bounty', position: 'left' },
102103
{
103104
type: 'custom-navbar-separator',
104105
position: 'right',

examples/keep_alive/index.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const connection = new WebSocket(`wss://ws.binaryws.com/websockets/v3?app_id=${a
55

66
const api = new DerivAPIBasic({ connection });
77

8-
const keepAlive = () => {
8+
const proposal = () => {
99
api.subscribe({
1010
proposal: 1,
1111
subscribe: 1,
@@ -18,17 +18,21 @@ const keepAlive = () => {
1818
symbol: 'R_100',
1919
barrier: '+0.1',
2020
});
21-
/*
22-
* Send a ping ever 30 seconds to keep the connection alive, needs to use the same
23-
* websocket connection as the one you want to maintain.
24-
*/
2521
};
2622

27-
const keepAliveRes = async (res) => {
23+
// Send a ping every 30 seconds to keep the connection alive
24+
// Needs to use the same websocket connection as the one you want to maintain.
25+
const ping = () => {
26+
setInterval(() => {
27+
api.ping();
28+
}, 30000);
29+
};
30+
31+
const wsResponse = async (res) => {
2832
const data = JSON.parse(res.data);
2933
if (data.error !== undefined) {
3034
console.log('Error: %s ', data.error.message);
31-
connection.removeEventListener('message', keepAliveRes, false);
35+
connection.removeEventListener('message', wsResponse, false);
3236
await api.disconnect();
3337
} else if (data.msg_type === 'proposal') {
3438
console.log('Details: %s', data.proposal.longcode);
@@ -40,14 +44,15 @@ const keepAliveRes = async (res) => {
4044
}
4145
};
4246

43-
const checkSignal = async () => {
44-
await keepAlive();
45-
connection.addEventListener('message', keepAliveRes);
47+
const checkSignal = () => {
48+
proposal();
49+
ping();
50+
connection.addEventListener('message', wsResponse);
4651
};
4752

4853
const endCall = () => {
49-
connection.removeEventListener('message', keepAliveRes, false);
50-
keepAlive().unsubscribe();
54+
connection.removeEventListener('message', wsResponse, false);
55+
proposal().unsubscribe();
5156
};
5257

5358
const keep_alive_button = document.querySelector('#keep_alive');

src/components/ApiTokenNavbarItem/api_token_switcher.module.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
width: rem(1.2);
4343
height: rem(1.2);
4444
transform: rotate(0deg);
45-
transition: transform .2s;
45+
transition: transform 0.2s;
4646
}
4747
&:hover {
4848
text-decoration: none;
@@ -75,7 +75,7 @@
7575
width: rem(1.5);
7676
height: rem(1.5);
7777
transform: rotate(0deg);
78-
transition: transform .2s ease-in-out;
78+
transition: transform 0.2s ease-in-out;
7979
}
8080
&.active::after {
8181
transform: rotate(-180deg);
@@ -115,6 +115,8 @@
115115
display: flex;
116116
flex-direction: column;
117117
gap: rem(0.8);
118+
overflow-y: scroll;
119+
max-height: rem(40);
118120
}
119121
@media (max-width: 1200px) {
120122
position: fixed;

src/components/Header/__tests__/Header.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import React from 'react';
22
import { Header } from '..';
33
import { render, screen } from '@testing-library/react';
44

5+
beforeAll(() => {
6+
const script_tag = document.createElement('div');
7+
script_tag.setAttribute('id', '__docusaurus');
8+
document.body.appendChild(script_tag);
9+
});
10+
511
describe('Header', () => {
612
it('should be able to render the header with links', () => {
713
render(<Header />);

src/components/Header/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import styles from './Header.module.scss';
33
import Link from '@docusaurus/Link';
44
export const Header = () => {
5+
useEffect(() => {
6+
const s = document.createElement('script');
7+
s.src =
8+
'https://survey.survicate.com/workspaces/83b651f6b3eca1ab4551d95760fe5deb/web_surveys.js';
9+
s.async = true;
10+
const e = document.getElementById('__docusaurus');
11+
e.parentNode.insertBefore(s, e);
12+
}, []);
513
return (
614
<div className={styles.Navtop}>
715
<div className={styles.NavtopContainer}>

0 commit comments

Comments
 (0)