diff --git a/docs/_client-libraries/_category_.json b/docs/_client-libraries/_category_.json index fd5dfe08..81c50334 100644 --- a/docs/_client-libraries/_category_.json +++ b/docs/_client-libraries/_category_.json @@ -1,5 +1,5 @@ { - "label": "Client Libraries", + "label": "Client libraries", "position": 5, "link": { "type": "generated-index", diff --git a/docs/_client-libraries/flutter/project-setup/index.md b/docs/_client-libraries/flutter/project-setup/index.md index a148a6b5..45b6add8 100644 --- a/docs/_client-libraries/flutter/project-setup/index.md +++ b/docs/_client-libraries/flutter/project-setup/index.md @@ -1,5 +1,5 @@ --- -title: Project Setup +title: Project setup sidebar_label: Setup sidebar_position: 0 --- diff --git a/docs/_client-libraries/typescript/project-setup/index.md b/docs/_client-libraries/typescript/project-setup/index.md index 94071224..85f2ea6c 100644 --- a/docs/_client-libraries/typescript/project-setup/index.md +++ b/docs/_client-libraries/typescript/project-setup/index.md @@ -1,5 +1,5 @@ --- -title: Project Setup +title: Project setup sidebar_label: Setup sidebar_position: 0 --- diff --git a/docs/_terminology/trading/landing-company-calls/landing-company/index.md b/docs/_terminology/trading/landing-company-calls/landing-company/index.md index b88c8f9e..0d912a72 100644 --- a/docs/_terminology/trading/landing-company-calls/landing-company/index.md +++ b/docs/_terminology/trading/landing-company-calls/landing-company/index.md @@ -23,4 +23,4 @@ The company has a number of licensed subsidiaries in various jurisdictions, whic This call will return the appropriate Landing Company for clients of a given country. -The landing company may differ for Gaming contracts (Synthetic Indices) and Financial contracts (Forex, Stock Indices, Commodities). +The landing company may differ for Synthetic Indices and Financial contracts (Forex, Stock Indices, Commodities). diff --git a/docs/code-examples/javascript/_category_.json b/docs/code-examples/javascript/_category_.json index c74ab713..aee9aaa7 100644 --- a/docs/code-examples/javascript/_category_.json +++ b/docs/code-examples/javascript/_category_.json @@ -1,8 +1,8 @@ { - "label": "Javascript Examples", + "label": "JavaScript Examples", "position": 1, "link": { "type": "generated-index", - "description": "Javascript code examples" + "description": "JavaScript code examples" } } diff --git a/docs/core-concepts/_category_.json b/docs/core-concepts/_category_.json index ca2ce668..42ad99a5 100644 --- a/docs/core-concepts/_category_.json +++ b/docs/core-concepts/_category_.json @@ -1,8 +1,8 @@ { - "label": "Core Concepts", + "label": "Core concepts", "position": 2, "link": { "type": "generated-index", - "description": "Learn core concepts of Deriv API websocket server and it's features" + "description": "Learn core concepts of the Deriv API WebSocket server and its features" } } diff --git a/docs/core-concepts/api-calls-anatomy/index.md b/docs/core-concepts/api-calls-anatomy/index.md index c7b84f48..e2fe1f8e 100644 --- a/docs/core-concepts/api-calls-anatomy/index.md +++ b/docs/core-concepts/api-calls-anatomy/index.md @@ -1,17 +1,21 @@ --- -title: API Calls Anatomy -hide_title: true +title: API calls' anatomy +hide_title: false draft: false -sidebar_label: API Calls anatomy +sidebar_label: API calls' anatomy sidebar_position: 1 tags: - concept + - calls + - anatomy keywords: - trading - concept -description: Deriv API calls Anatomy + - calls + - anatomy +description: Deriv API calls' anatomy --- -## Subscribe and Send +## Subscribe and send 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. @@ -23,42 +27,42 @@ Some of these API calls automatically subscribe (e.g. [ticks](https://api.deriv. For example, you can call [Tick History](https://api.deriv.com/api-explorer#ticks_history) to receive tick history data. But when you add the `subscribe` option to this call, you will receive the tick history data you requested in the first response, and you will continue to receive a new response every time there is a new tick published by the server for the given symbol. -In the message stream from `subscribe` there is a field called `subscription`, this is the `Stream ID`. with this ID you can identify the message stream in your logic and stop the stream with `Forget` and `Forget All` API calls. +In the message stream from `subscribe`, there is a field called `subscription`. This is the `Stream ID`. With this ID, you can identify the message stream in your logic and stop the stream with `Forget` and `Forget All` API calls. The data provided by API calls with the `subscribe` functionality can be used as a data source for other API calls and features. ### Send -If you call the API with the `send` functionality, then the server will only send back the requested data one time. In order to get updated data you have to send the API call again. Usually, this method is used when you get other API call responses or UI events such as `Click`, `Scroll` and more. +If you call the API with the `send` functionality, then the server will only send back the requested data one time. In order to get updated data, you have to send the API call again. Usually, this method is used when you get other API call responses or UI events such as `Click`, `Scroll`, and more. ### Forget -If you want to stop the message Stream created by `subscribe`, you will have to call the `Forget` API call with the correct `Stream ID`. Otherwise, you can use the `Forget All` API call to stop streams by their `Method name`. +If you want to stop the message stream created by `subscribe`, you will have to call the `Forget` API call with the correct `Stream ID`. Otherwise, you can use the `Forget All` API call to stop streams by their `Method name`. :::caution -For more information on the `Forget` API call, you can 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. +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. ::: -## Request Data +## Request data -In order to make it easier for you to handle the `request` and `response` flow of your websocket connection, every deriv websocket API calls has a general structure. you can use it for caching, validation, request and response synchronization are some of the things you can use it for. +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. -#### API Call Method Name +#### API call method name Every `request` in the WebSocket API includes a `method name` field that serves as a unique identifier for the request. In most cases, this `method name` will get a numerical value of `1`. However, there are some cases where the identifier property may have a string value. :::caution -API Call Method Name is always required. this field determines the data you'll get from our websocket server. +API Call Method Name is always required. this field determines the data you'll get from our WebSocket server. ::: -### Required Fields +### Required fields -Every request data has several required fields which you must provide them and they may contain optional fields as well, let's explore this with an example on `Residence List`: +Each request data has mandatory fields that you must provide, and it may also include optional fields. Let's explore this with an example from `Residence List`. -`Residence List` Call returns a list of countries and 2-letter country codes, suitable for populating the account opening form. +A `Residence List` call returns a list of countries and 2-letter country codes, suitable for populating the account opening form. -Request data for this call is like so: +The request data for this call is as below: ```ts { @@ -68,27 +72,27 @@ Request data for this call is like so: } ``` -The `residence_list` field is the `method name` for the call and is required. There may be other required fields which are related to this type of the request you want to send. if you want to know more about `Residence List` and other API calls please check them out in the [API Explorer](https://api.deriv.com/api-explorer#residence_list). +The `residence_list` field is the `method name` for the call and is required. There may be other required fields related to this type of the request you want to send. To know more about `Residence List` and other API calls, please check them out in [API Explorer](https://api.deriv.com/api-explorer#residence_list). -### Optional Fields +### Optional fields -Every Call has several `Optional` fields as well, `passthrough` and `req_id` are always part of the request data but you can choose to opt-out and not use them. +Every call has several `Optional` fields as well. `Passthrough` and `req_id` are always part of the request data but you can choose to opt out and not use them. -#### `passthrough` Field +#### The `passthrough` field -Whatever you pass to this field will be returned back to you inside a `response` object, this can be helpful when you need to simulate a stateful flow for your `requests` and `responses`. +Whatever you pass to this field will be returned back to you inside a `response` object. This can be helpful when you need to simulate a stateful flow for your `requests` and `responses`. -#### `req_id` Field +#### The `req_id` field -You may need to `tag` your requests and pass them through our `websocket` calls. you can do it by passing a `number` to this field. it can be helpful when you need to map `requests` to `responses`. +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`. :::caution -There may be other optional fields for a request which are only related to that API call, please check our [API Explorer](https://api.deriv.com/api-explorer) to get familiar with them. +To learn about additional optional fields specific to each API call, please refer to our [API Explorer](https://api.deriv.com/api-explorer). ::: -## Response Data +## Response data -When you get the response for the call, there will be a `Field` with the same name as the `method name`. and it contains the actual data. +When you get the response for the call, there will be a `Field` with the same name as the `method name`, which contains the actual data. The response for the `Residence List` call: @@ -159,15 +163,15 @@ The response for the `Residence List` call: }; ``` -Here the `residence_list` is the `method name` and it contains the actual data you requested. rest of the array is removed here for brevity sake, you can check the actual response [here](https://api.deriv.com/api-explorer#residence_list). +Here the `residence_list` is the `method name`, and it contains the actual data you requested. To keep it short, we haven't included the rest of the array. You can check the actual response [here](https://api.deriv.com/api-explorer#residence_list). -#### The `echo_req` Field +#### The `echo_req` field This `Field` contains the exact `Request Data` you sent to the server. -#### The `msg_type` Field +#### The `msg_type` field -This `Field` helps you determine which `message` data you're getting on the message event of the websocket connection. For example, your `onmessage` event handler for your websocket connection in `Javascript` would be: +This `Field` helps you determine which `message` data you're getting on the message event of the WebSocket connection. For example, your `onmessage` event handler for your WebSocket connection in `JavaScript` would be: ```js socket.onmessage = (event) => { @@ -186,7 +190,7 @@ socket.onmessage = (event) => { } ``` -#### The `req_id` Field +#### The `req_id` field This is the `Optional` passed to the `Request Data`, you can use it for `validation`, `synchronization`, `caching`, etc. diff --git a/docs/core-concepts/authorization-authentication/index.md b/docs/core-concepts/authorization-authentication/index.md index 714235ba..3584dd69 100644 --- a/docs/core-concepts/authorization-authentication/index.md +++ b/docs/core-concepts/authorization-authentication/index.md @@ -1,37 +1,36 @@ --- -title: Authorization and Authentication +title: Authorisation and authentication hide_title: false draft: false -sidebar_label: Authorization and Authentication +sidebar_label: Authorisation and authentication sidebar_position: 2 tags: - authentication - - authorization + - authorisation keywords: - deriv-authentication - - deriv-authorization -description: deriv api authentication and authorization + - deriv-authorisation +description: Deriv API authorisation and authentication --- - -Without authentication and authorization you'll only get access to roughly half of our API calls and features. for example in order to buy contracts or utilize the `Copy Trading` features your users must be authenticated and authorized by our **OAuth** provider and **Websocket Server**. +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**. ## Before we start -You have to make sure you have all the requirements mentioned bellow to continue. +Please make sure you have all the requirements mentioned below to continue. ### Requirements -1. Deriv Account -2. Deriv API Token with the appropriate access level -3. Deriv App ID +1. Deriv account +2. Deriv API token with the appropriate access level +3. Deriv app ID :::note -Please refer to [Setting up a Deriv Application](/docs/setting-up-a-deriv-application.md) for detailed instruction how to create Deriv API token and Applications +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. ::: -### API Token +### API token -An API token is a unique identifier of a client that requests access from a server. It's the simplest way of authorization. +An API token is a unique identifier of a client that requests access from a server. It's the simplest way of authorisation. The access level for each API token has to match the required access level of each API call, which can be found in the [API Explorer](https://api.deriv.com/api-explorer) as well. @@ -39,37 +38,37 @@ For example, on the screenshot below, you can see that to be able to use the Acc  -Following the authorization of a Websocket connection, subsequent calls on that connection will be considered user actions. +Following the authorisation of a WebSocket connection, subsequent calls on that connection will be considered user actions. Please bear in mind that the API token can be used with any app, so both your app and your clients need to keep it secure. ### OAuth2 -OAuth stands for Open Authorization - a protocol that allows a client access resources hosted on a server on behalf of the user without revealing the credentials. +OAuth stands for `Open Authorisation` — a protocol that allows a client to access resources hosted on a server on behalf of the user without revealing the credentials. -This type of authorization allows clients to log in to third-party apps using their Deriv accounts without creating an API token. In this case, the third-party app does not see the user's password or permanent API token, which makes it safer. +This type of authorisation allows clients to log in to third-party apps using their Deriv accounts without creating an API token. In this case, the third-party app does not see the user's password or permanent API token, which makes it safer. The OAuth2 authentication requires more steps to set up, but it is the safest way for developers to share access to their app with their clients. For more information on OAuth2, visit [this guide](https://aaronparecki.com/oauth-2-simplified/). -Here is the visual representation of how the OAuth authorization connection works: +Here is the visual representation of how the OAuth authorisation connection works:  -## Authentication Process +## The authentication process -In order to Authenticate your user, specify the URL that will be used as the OAuth Redirect URL on the [Dashboard](/dashboard) page, **Register application** tab in the **OAuth details** fields and then Add a login button on your website or app and direct users to **`https://oauth.binary.com/oauth2/authorize?app_id=your_app_id`** where your_app_id is the ID of your app. +In order to authenticate your user, specify the URL that will be used as the OAuth Redirect URL on the [Dashboard](/dashboard) page, **Register application** tab in the **OAuth details** fields. Then, add a login button on your website or app and direct users to **`https://oauth.binary.com/oauth2/authorize?app_id=your_app_id`** where your_app_id is the ID of your app.  -Once a user signs up / signs in, they will be redirected to the URL that you entered as the Redirect URL. This URL will have arguments added to it with the user's session tokens, and will look similar to this: +Once a user signs up/logs in, they will be redirected to the URL that you entered as the Redirect URL. This URL will have arguments added to it with the user's session tokens, and will look similar to this: `https://[YOUR_WEBSITE_URL]/redirect/?acct1=cr799393& token1=a1-f7pnteezo4jzhpxclctizt27hyeot&cur1=usd& acct2=vrtc1859315& token2=a1clwe3vfuuus5kraceykdsoqm4snfq& cur2=usd` -## Authorization Process +## The authorisation process -The query params in the redirect URL are the user's accounts and their related session tokens. you can map the query params to an array like so: +The query parameters in the redirect URL are the user's accounts and their related session tokens. You can map the query parameters to an array using the following approach: ```js const user_accounts = [ @@ -85,17 +84,14 @@ const user_accounts = [ }, ]; ``` - -To authorize 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**: - +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**: ```js { "authorize": "a1-f7pnteezo4jzhpxclctizt27hyeot" } ``` -The response for the `authorize` call would be an object like so: - +The response for the `authorize` call would be an object as below: ```js { "account_list": [ @@ -149,5 +145,4 @@ The response for the `authorize` call would be an object like so: "user_id": 12345678 } ``` - -Now user is authorized and you use Deriv API calls on behalf of the account. +Now, the user is authorised, and you can use Deriv API calls on behalf of the account. diff --git a/docs/core-concepts/websocket/index.md b/docs/core-concepts/websocket/index.md index 7b9cc26a..bba96da7 100644 --- a/docs/core-concepts/websocket/index.md +++ b/docs/core-concepts/websocket/index.md @@ -1,8 +1,8 @@ --- -title: Websocket +title: WebSocket hide_title: true draft: false -sidebar_label: Websocket +sidebar_label: WebSocket sidebar_position: 0 tags: - concept @@ -11,41 +11,41 @@ keywords: - trading - concept - websockets -description: What is websocket? +description: What is a WebSocket? --- -## What is WebSocket? +## What are WebSockets? -The `WebSocket` protocol, described in the specification [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455), provides a way to exchange data between browser and server via a persistent connection. The data can be passed in both directions as “packets”, without breaking the connection and the need of additional HTTP-requests. +The `WebSocket` protocol, described in the specification [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455), provides a way to exchange data between the browser and the server via a persistent connection. The data can be passed in both directions as “packets” without breaking the connection or needing additional HTTP requests. WebSocket is especially great for services that require continuous data exchange, e.g. real-time trading systems and so on. -## A Simple example +## A simple example -To open a websocket connection, we need to create `new WebSocket` using the special protocol `ws`or `wss` in the url: +To open a WebSocket connection, we need to create `new WebSocket` using the special protocol `ws`or `wss` in the url. Here is how you can do that in `JavaScript`: ```js let socket = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1089'); ``` :::caution -Always prefer `wss://`. The `wss://` protocol is not only encrypted, but also more reliable. +Using `wss://` is always the better choice. The `wss://` protocol is not only encrypted, but also more reliable. -That’s because ws:// data is not encrypted, visible for any intermediary. Old proxy servers do not know about WebSocket, they may see “strange” headers and abort the connection. +On the other hand, the `ws://` data is not encrypted and can be visible to intermediaries. Old proxy servers may encounter "strange" headers and terminate the connection. -On the other hand, `wss://` is WebSocket over TLS, (same as HTTPS is HTTP over TLS), the transport security layer encrypts the data at the sender and decrypts it at the receiver. So data packets are passed encrypted through proxies. They can’t see what’s inside and let them through. +`wss://` stands for WebSocket over TLS, similar to how HTTPS is HTTP over TLS. With the transport security layer, data is encrypted by the sender and decrypted by the receiver. This means that encrypted data packets can successfully pass through proxies without being inspected. ::: -Once the socket is created, we should listen to events on it. There are totally 4 events: +Once the socket is created, we should listen to events on it. There are 4 events altogether: -- open – connection established, -- message – data received, -- error – websocket error, -- close – connection closed. +- Open – Connection established +- Message – Data received +- Error – WebSocket error +- Close – Connection closed -And if we’d like to send a message then socket.send(data) will do that. +Sending a message can be done via socket.send(data). -Here’s an example in `Javascript`: +Here’s an example in `JavaScript`: ```js const app_id = 1089; // Replace with your app_id or leave as 1089 for testing. @@ -77,43 +77,44 @@ socket.onerror = function (error) { }; ``` -## Why do we need websocket and when should we avoid it? +## Why do we need WebSockets and when should we avoid them? -Websocket are an essential client-server communication tool and one needs to be fully aware of its utility and avoid scenarios to benefit from its utmost potential. It’s explained extensively in the next section. +WebSockets are an essential client-server communication tool. To benefit the most from their potential, it's important to understand how they can be helpful and when it's best to avoid using them. It’s explained extensively in the next section. -Use WebSocket When You Are: +Use WebSockets in the following cases: -1. Developing real-time web application - 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 backend server sends back this data continuously, Websocket allows uninterrupted pushing or transmitting this data in the already open connection. The use of Websockets makes such data transmission quick and leverages the application's performance. -2. A real-life example of such Websocket utility is in the trading websites such as deriv. Here, Websocket assist in data handling that is impelled by the deployed backend server to the client. -3. Creating a chat application - Chat application developers call out Websocket for help in operations like a one-time exchange and publishing/broadcasting the messages. As the same Websocket connection is used for sending/receiving messages, communication becomes easy and quick. +1. When you're developing a real-time web application. + 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. +2. For trading websites, such as Deriv. + Here, WebSocket assist in data handling that is impelled by the deployed back-end server to the client. +3. When creating a chat application. + 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. -Now that it’s clear where Websocket should be used, don’t forget to know the cases where it should be avoided and keep yourself away from tons of operational hassles. +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. -Websocket shouldn’t be taken onboard when old data fetching is the need of the hour or need data only for one-time processing. In these cases, using HTTP protocols is a wise choice. +WebSockets shouldn't be taken onboard when all that is needed is fetching old data or data that's to be processed only once. In these cases, using HTTP protocols is a wise choice. -## Websocket vs HTTP +## WebSocket vs HTTP -As both HTTP and Websocket are employed for application communication, people often get confused and find it difficult to pick one out of these two. Have a look at the below-mentioned text and gain better clarity on HTTP and WebSocket. +As both HTTP and WebSocket protocols are employed for application communication, people often get confused and find it difficult to pick one. -As told previously, Websocket is a framed and bidirectional protocol. On the contrary, to this, HTTP is a unidirectional protocol functioning above the TCP protocol. +As told previously, WebSocket is a framed and bidirectional protocol. On the other hand, HTTP is a unidirectional protocol functioning above the TCP protocol. -As Websocket protocol is capable to support continual data transmission, it’s majorly used in real-time application development. HTTP is stateless and is used for the development of [RESTful](https://de.wikipedia.org/wiki/Representational_State_Transfer) and [SOAP](https://de.wikipedia.org/wiki/SOAP) applications. Soap can still use HTTP for implementation, but REST is widely spread and used. +As the WebSocket protocol is capable of supporting continual data transmission, it’s majorly used in real-time application development. HTTP is stateless and is used for the development of [RESTful](https://de.wikipedia.org/wiki/Representational_State_Transfer) and [SOAP](https://de.wikipedia.org/wiki/SOAP) applications. SOAP can still use HTTP for implementation, but REST is widely spread and used. -In Websocket, communication occurs at both ends, which makes it a faster protocol. In HTTP, the connection is built at one end, making it a bit sluggish than Websocket. +In WebSocket, communication occurs at both ends, which makes it a faster protocol. In HTTP, the connection is built at one end, making it a bit more sluggish than WebSocket. -Websocket uses a unified TCP connection and needs one party to terminate the connection. Until it happens, the connection remains active. HTTP needs to build a distinct connection for separate requests. Once the request is completed, the connection breaks automatically. +WebSocket uses a unified TCP connection and needs one party to terminate the connection. Until it happens, the connection remains active. HTTP needs to build a distinct connection for separate requests. Once the request is completed, the connection breaks automatically. -## How are Websocket connections established? +## How are WebSocket connections established? -The process starts with a Websocket handshake that involves using a new scheme ws or wss. To understand quickly, you may consider them equivalent to HTTP and secure HTTP (HTTPS) respectively. +The process starts with a WebSocket handshake that involves using a new scheme (ws or wss). To help you understand, consider them equivalent to HTTP and secure HTTP (HTTPS) respectively. -Using this scheme, servers and clients are expected to follow the standard WebSocket connection protocol. The Websocket connection establishment begins with HTTP request upgrading that features a couple of headers such as Connection: Upgrade, Upgrade: WebSocket, Sec-WebSocket- Key, and so on. +Using this scheme, servers and clients are expected to follow the standard WebSocket connection protocol. The WebSocket connection establishment begins with a HTTP request upgrading that features a couple of headers such as Connection: Upgrade, Upgrade: WebSocket, Sec-WebSocket- Key, and so on. Here is how this connection is established: -1. **The Request :** Connection Upgrade header denotes the Websocket handshake while the Sec-WebSocket-Key features Base64-encoded random value. This value is arbitrarily generated during every WebSocket handshake. Besides the above, the key header is also a part of this request. +1. **The Request :** The Connection Upgrade header denotes the WebSocket handshake while the Sec-WebSocket-Key features Base64-encoded random value. This value is arbitrarily generated during every WebSocket handshake. Besides the above, the key header is also a part of this request. The above-listed headers, when combined, form an HTTP GET request. It will have similar data in it: @@ -128,7 +129,7 @@ Sec-WebSocket-Version: 13 Sec-WebSocket-Key: b6gjhT32u488lpuRwKaOWs== ``` -To clarify, Sec-WebSocket-Version, one can explain the Websocket protocol version ready to use for the client. +To clarify Sec-WebSocket-Version, one can explain the WebSocket protocol version ready to use for the client. 2. **The Response:** The response header, Sec-WebSocket-Accept, features the rest of value submitted in the Sec-WebSocket-Key request header. This is connected with a particular protocol specification and is used widely to keep misleading information at bay. In other words, it enhances the API security and stops ill-configured servers from creating blunders in the application development. @@ -143,5 +144,5 @@ Sec-WebSocket-Accept: rG8wsswmHTJ85lJgAE3M5RTmcCE= ## References -- ** [Websockets APIs - MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)** -- ** [Websocket - Javascript Info](https://javascript.info/websocket)** +- ** [WebSockets APIs - MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)** +- ** [WebSocket - Javascript Info](https://javascript.info/websocket)** diff --git a/docs/intro.md b/docs/intro.md index 79ebbe42..8343d742 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -6,26 +6,47 @@ sidebar_label: Introduction sidebar_position: 0 tags: - introduction + - getting + - started + - quick + - start keywords: - deriv - api - getting - started + - quick + - start description: Getting started with Deriv API --- Our Documentation is divided in several sections: -- [Core Concepts](category/core-concepts) -- [Code Examples](category/code-examples) +- [Core concepts](category/core-concepts) +- [Code examples](category/code-examples) - [Languages](category/languages) - [Guides](category/guides) - [Setting up a deriv app](/docs/setting-up-a-deriv-application.md) ### Quick Start -Have a look at the [Core Concept](category/core-concepts) page and take your time to read through it. These concepts will help you get familiar with our websocket server api and how to use it more efficiently. They are not related to any of our frameworks or libraries. +#### Core Concepts + +Have a look at the [Core Concept](/docs/category/core-concepts) pages and take your time to read through it. These concepts will help you get familiar with our WebSocket server api and how to use it more efficiently. They are not related to any of our frameworks or libraries. + +When you read through the [Core Concept](/docs/category/core-concepts) page, you can start choosing your implementation approach based on the language, framework or library you want to use in your application. + +#### Code Examples + +If you want to know how you can implement our API within your code, then we suggest to have a look at our [Code Examples](/docs/category/code-examples). These code examples come in `CodeSandboxes`. This allows you to easily fork the code examples and experiment with them for personal use. For now we only have JavaScript code examples, but, we plan to add more examples that are created with different languages, frameworks and libraries in the near future. + +#### Languages + +When using our code examples, we also suggest to have a look at our [Languages](/docs/category/languages) section. Here, we describe in detail how you can setup your personal project properly to make use of our API. This will surely come helpful when you try to integrate some of our code examples in your own project. + +#### Guides -When you read through the [Core Concept](category/core-concepts) page, you can start choosing your implementation approach based on the language / framework / library you want to use in your application. +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. -have a look at the [Languages Section](category/languages) and continue your journey from there. +#### Setting up a Deriv application +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. diff --git a/docs/languages/_category_.json b/docs/languages/_category_.json index 019e27cb..84ec3202 100644 --- a/docs/languages/_category_.json +++ b/docs/languages/_category_.json @@ -3,6 +3,6 @@ "position": 4, "link": { "type": "generated-index", - "description": "Learn how to use Deriv websocket API features with your Language of your choice" + "description": "Learn how to use Deriv WebSocket API features with your language of your choice" } } diff --git a/docs/languages/intro.md b/docs/languages/intro.md index 5ba95f54..0003fa60 100644 --- a/docs/languages/intro.md +++ b/docs/languages/intro.md @@ -5,8 +5,8 @@ sidebar_position: 0 description: Introduction to languages --- -Each language section contains step-by-step instructions on how to use the `Deriv Websocket Server APIs` with pure language features. So if it's the first time you're using our docs please go through each section in order to get the most out of them. +Each language section contains step-by-step instructions on how to use the `Deriv WebSocket Server APIs` with pure language features. So if it's the first time you're using our docs please go through each section in order to get the most out of them. :::tip -You can jump right in to any section, there are links to requirements to help get started in each step. +You can jump right in to any section. There are links to requirements to help get started in each step. ::: diff --git a/docs/languages/javascript/_category_.json b/docs/languages/javascript/_category_.json index d260c728..467bc53f 100644 --- a/docs/languages/javascript/_category_.json +++ b/docs/languages/javascript/_category_.json @@ -1,8 +1,8 @@ { - "label": "Javascript", + "label": "JavaScript", "position": 1, "link": { "type": "generated-index", - "description": "Learn how to use Deriv Websocket APIs with Javascript and HTML & CSS" + "description": "Learn how to use Deriv WebSocket APIs with JavaScript." } } diff --git a/docs/languages/javascript/get-country-list/index.md b/docs/languages/javascript/get-country-list/index.md index 5cb4a107..1e44c8c6 100644 --- a/docs/languages/javascript/get-country-list/index.md +++ b/docs/languages/javascript/get-country-list/index.md @@ -1,6 +1,6 @@ --- -title: Get list of countries -sidebar_label: Get list of countries +title: Get a list of countries +sidebar_label: Get a list of countries sidebar_position: 2 tags: - country_list @@ -8,14 +8,14 @@ tags: keywords: - country_list - javascript -description: How to get the list of countries in Deriv api? +description: How to get a list of countries in Deriv api? --- -To get the countries list, you can update the `open` event listener like so: +To get a list of countries, update the open event listener using the following approach: ```js title="index.js" const ping_interval = 12000; // it's in milliseconds, which equals to 120 seconds @@ -36,7 +36,7 @@ websocket.addEventListener('open', (event) => { }); ``` -Now update the `message` event listener to render the data: +Now, update the `message` event listener to render the data: ```js title="index.js" // subscribe to `message` event @@ -56,7 +56,7 @@ websocket.addEventListener('message', (event) => { }); ``` -the response should be an object: +The response should be an object: ```json { @@ -118,30 +118,30 @@ the response should be an object: } ``` -With this call, you'll get useful information for the supported countries, such as: +With this call, you will get useful information about supported countries, such as: -- `2-letter` code for each country +- A `2-letter` code for each country - `Identity` service providers for each country - Country Tax Identifier Format (`tin_format`) -- etc +- etc. -This can be useful to account creation forms, in which you need to ask your users to provide validated information about their identity base, depending on their country of residence. +This can be useful for account creation forms, in which you need to ask users to provide validated information about their identity base, depending on their country of residence. :::caution For address and tax ID validations, please use the provided 'tin_format' for the country. ::: -The country of your users is important for our next steps. With it, you can determine which assets and features the client can use. +User's country is important for your next steps. It determines which assets and features they can use. :::tip -It's better if you get the list of countries before populating your form. +It's better to get the list of countries before populating your form. ::: :::danger -We need detailed content about `IDV` and `ONFIDO` identity services, their differences and possibilities +You will need detailed content about `IDV` and `ONFIDO` identity services, their differences and possibilities. ::: -your final code should be: +Your final code will be: ```js title="index.js" const app_id = 1089; // Replace with your app_id or leave as 1089 for testing. diff --git a/docs/languages/javascript/project-setup/index.md b/docs/languages/javascript/project-setup/index.md index 07df0258..deeac713 100644 --- a/docs/languages/javascript/project-setup/index.md +++ b/docs/languages/javascript/project-setup/index.md @@ -1,45 +1,45 @@ --- -title: Project Setup -sidebar_label: Project Setup +title: Project setup +sidebar_label: Project setup sidebar_position: 0 tags: - javascript keywords: - js - project-setup -description: js deriv api project setup +description: Deriv API JavaScript project setup --- -### Create Project +### Create a project -We're gonna create a simple `HTML` page with our javascript scripts which handles our websocket connection. create a directory for you next project: +We are going to create a simple `HTML` page that contains our JavaScript file, which will handle our WebSocket connection. First, create a directory for your next project: ```bash mkdir deriv-websocket-demo ``` -navigate to the `deriv-websocket-demo` folder: +Navigate to the `deriv-websocket-demo` folder: ```bash cd deriv-websocket-demo ``` -next create the needed files like so: +Next, create the required files as you see below: ```bash touch index.html index.css index.js ``` -Now open the folder with your prefered code editor or IDE - :::tip -We suggest using [Visual Studio Code](https://code.visualstudio.com/) with [Live Server Extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) enabled, it will help you a lot going forward in implementations. +We suggest using [Visual Studio Code](https://code.visualstudio.com/) with [Live Server Extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) enabled. This will help you a lot with implementations. ::: -Now Change the content of the files like so: +Now, open the `index.html` file or use the [Live Server Extension](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). + +Now, change the content of the files using the following approach: ```js title="index.js" -console.log("we're gonna create websocket connection and all the other cool stuff here"); +console.log("we will create our websocket connection here"); ``` ```html title="index.html" @@ -49,37 +49,15 @@ console.log("we're gonna create websocket connection and all the other cool stuf -