Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch to support FTX.us #2

Closed
buildgreatthings opened this issue Apr 14, 2021 · 5 comments · Fixed by #3
Closed

Add switch to support FTX.us #2

buildgreatthings opened this issue Apr 14, 2021 · 5 comments · Fixed by #3

Comments

@buildgreatthings
Copy link

Hi there,

Is there a way to pass in FTX.us through this API?

@tiagosiebler
Copy link
Owner

If the endpoints and methods are the same (except for the ones missing on the US exchange), you could try to just override the base URL.

There's a third parameter to the RestClient where you can pass client-specific configuration options. Something like this should work, assuming everything else about ftx.us is consistent:

const restClientOptions = {
  baseUrl: 'https://ftx.us/api'
};
const client = new RestClient(key, secret, restClientOptions);

The websocket client has the same configurability, although the constructor is slightly different. The time sync also uses the rest client, so it's important to also include the restClientOptions as well as the custom ws URL. Pseudo example:

const restClientOptions = {
  baseUrl: 'https://ftx.us/api'
};

const wsConfig = {
  key: 'apikeyhere',
  secret: 'apisecrethere',
  // subAccountName: 'sub1',
  wsUrl: 'wss://ftx.us/ws/',
  restOptions: restClientOptions
};

const ws = new WebsocketClient(wsConfig);

Let me know if this works. Would be good to add a sample to the examples folder.

@buildgreatthings
Copy link
Author

Thanks for the fast response! I am using rest only, but the headers are changed too for key, subaccount, secret.

In the documentation, they use ftxus-key instead of key I believe. It's a pretty straightforward change I think. If you push something, I can test since I am a US user.

@tiagosiebler tiagosiebler changed the title FTX.us Add switch to support FTX.us Apr 14, 2021
@tiagosiebler
Copy link
Owner

Thanks for the fast response! I am using rest only, but the headers are changed too for key, subaccount, secret.

In the documentation, they use ftxus-key instead of key I believe. It's a pretty straightforward change I think. If you push something, I can test since I am a US user.

I've whipped up an implementation to deal with it, can you try it out? Websocket too please 😄

Changes can be seen here:
#3

It's available on npm via the beta tag:
npm install ftx-api@1.0.1-beta.1

Usage example:
https://github.com/tiagosiebler/ftx-api/blob/ftxus/examples/ftxus.ts

@buildgreatthings
Copy link
Author

We tested Rest API and can confirm it works!

Thank you so much for this! Unfortunately we don't have web socket enabled on our system, so I can't confirm.

@tiagosiebler
Copy link
Owner

Thanks for confirming! I've published the same version as the latest release on this package (ftx-api@1.0.2). It should be available shortly if you install ftx-api@latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants