0

I am looking for a way to stream data, using Emacs, which is accessible through an API that requires the submission of JavaScript code to a browser console:

https://developer.tdameritrade.com/content/streaming-data

There is an existing wraparound of this particular API, which uses Python:

https://tda-api.readthedocs.io/en/latest/streaming.html

I am currently using an Emacs start-process to run the Python wraparound for the API to stream the data, and this works.

However, I would like to access the API more directly through Emacs without using a third-party Python repository. A third-party utility (e.g., w3m or something similar), combined with an Emacs interface, would be an acceptable solution. How can Irun JavaScript in a browser console?

1 Answer 1

1

If you want to run Javascript in a browser console, open your favorite web browser and then open its developer tools to find the console. Emacs doesn’t run Javascript code, it runs Emacs Lisp instead. It has features equivalent to the browser console, but it is frequently called a REPL instead.

That said, I took a brief look at the API documentation that you referenced and there is nothing in there that requires you to use Javascript in order to access the API. The example code at the beginning is in Javascript merely because Javascript is a common choice, not because it is required.

You can access the API by making HTTP GET or POST requests, or by opening an HTTP WebSocket connection. Emacs provides several ways of doing HTTP requests. I recommend starting with url-retrieve-synchronously since that’s the simplest.

If you want to use the WebSocket protocol, then you should look into using the websocket library available on ELPA.

1
  • Thank you for the answer. I read it promptly after it was posted and upvoted, but I haven't yet had an opportunity to digest and investigate ... It may take me a few days to catch-up on what's on my plate before being able to move forwards. Your help is greatly appreciated!
    – lawlist
    Jan 3, 2022 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.