Skip to content

Commit

Permalink
yashim/chore: update default endpoint url (#221)
Browse files Browse the repository at this point in the history
* chore: update default endpoint url
* chore: update jsdocs - remove outdated endpoint
  • Loading branch information
yashim-deriv committed Feb 12, 2024
1 parent 3da98d8 commit 946caa3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const DerivAPI = require('@deriv/deriv-api/dist/DerivAPI');

// app_id 1089 is for testing, create your own app_id and use it here.
// go to api.deriv.com to register your own app.
const connection = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1089');
const connection = new WebSocket('wss://ws.derivws.com/websockets/v3?app_id=1089');
const api = new DerivAPI({ connection });
const basic = api.basic;

Expand All @@ -73,7 +73,7 @@ import WebSocket from 'ws';

// app_id 1089 is for testing, create your own app_id and use it here.
// go to api.deriv.com to register your own app.
const connection = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1089');
const connection = new WebSocket('wss://ws.derivws.com/websockets/v3?app_id=1089');
const api = new DerivAPIBasic({ connection });

api.ping().then(console.log);
Expand All @@ -90,7 +90,7 @@ const DerivAPIBasic = require('@deriv/deriv-api/dist/DerivAPIBasic');

// app_id 1089 is for testing, create your own app_id and use it here.
// go to api.deriv.com to register your own app.
const connection = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=1089');
const connection = new WebSocket('wss://ws.derivws.com/websockets/v3?app_id=1089');
const api = new DerivAPIBasic({ connection });

api.ping().then(console.log);
Expand All @@ -104,7 +104,7 @@ api.ping().then(console.log);
<script src="https://unpkg.com/@deriv/deriv-api/dist/DerivAPIBasic.js"></script>
<script>
const api = new DerivAPIBasic({
endpoint: 'ws.binaryws.com',
endpoint: 'ws.derivws.com',
app_id: 1089 /* 1089 is a default test app_id, replace with your own app_id */,
lang: 'EN'
});
Expand All @@ -119,13 +119,13 @@ There are two ways to establish a connection:

1. Use a previously opened connection:
```js
const connection = new WebSocket('wss://ws.binaryws.com/websockets/v3?app_id=YOUR_APP_ID');
const connection = new WebSocket('wss://ws.derivws.com/websockets/v3?app_id=YOUR_APP_ID');
const api = new DerivAPI({ connection });
```

2. Pass the arguments needed to create a connection:
```js
const api = new DerivAPI({ endpoint: 'ws.binaryws.com', app_id: /* your app_id */, lang: 'EN' });
const api = new DerivAPI({ endpoint: 'ws.derivws.com', app_id: /* your app_id */, lang: 'EN' });
```

# Documentation
Expand Down
4 changes: 2 additions & 2 deletions docs/DerivAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ API.
- `options` **[Object][331]** (optional, default `{}`)
- `options.app_id` **[Number][346]** Application ID of the API user
- `options.connection` **[WebSocket][347]?** A ready to use connection
- `options.endpoint` **[String][333]** API server to connect to (optional, default `'frontend.binaryws.com'`)
- `options.endpoint` **[String][333]** API server to connect to (optional, default `'ws.derivws.com'`)
- `options.lang` **[String][333]** Language of the API communication (optional, default `'EN'`)
- `options.brand` **[String][333]** Brand name (optional, default `''`)
- `options.middleware` **[Object][331]** A middleware to call on certain API actions (optional, default `{}`)
Expand All @@ -473,7 +473,7 @@ API.

```javascript
const apiFromOpenConnection = new DerivAPI({ connection });
const apiFromEndpoint = new DerivAPI({ endpoint: 'ws.binaryws.com', app_id: 1234 });
const apiFromEndpoint = new DerivAPI({ endpoint: 'ws.derivws.com', app_id: 1234 });
```

#### closeHandler
Expand Down
4 changes: 2 additions & 2 deletions src/deriv_api/DerivAPIBasic.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
*
* @example
* const apiFromOpenConnection = new DerivAPI({ connection });
* const apiFromEndpoint = new DerivAPI({ endpoint: 'ws.binaryws.com', app_id: 1234 });
* const apiFromEndpoint = new DerivAPI({ endpoint: 'ws.derivws.com', app_id: 1234 });
*
* @param {Object} options
* @param {WebSocket=} options.connection - A ready to use connection
Expand All @@ -42,7 +42,7 @@ export default class DerivAPIBasic extends DerivAPICalls {
app_id,
connection,
cache = new InMemory(),
endpoint = 'ws.binaryws.com',
endpoint = 'ws.derivws.com',
lang = 'EN',
brand = '',
middleware = {},
Expand Down

0 comments on commit 946caa3

Please sign in to comment.