Forums

API example for console send_input /api/v0/user/{username}/consoles/{id}/send_input/

Hi,

I was wondering if there are any examples around for how to use POST ...../consoles/{id}/send_input/, especially which parameters are required and the expected Content-Type and format of the commands. I see from the docs that newline (\n) terminated commands are expected, but without an example I'm struggling to know exactly what payload is expected, and have tried a few things without luck.

I also scoured the helper scripts on GitHub, but they seem to expect to be run interactively in a PythonAnywhere web console.

Am I right in assuming that console send_input is the main remote-automation interface available?

Thanks Brett

Our documentation for that API endpoint is wrong -- sorry about that! Tomorrow's system update will fix that.

The content-type should be text/json, and the only value you need to POST is input -- the text that you want to "type", including the explicit string "\n" for a newline.

The content-type should be text/json

I think that's supposed to be application/json, which does work.

The documentation for POST ... /consoles/ to create a new console could benefit from the same doc update e.g. set application/json and send:

{ "executable": "bash" }

Thanks Brett

Sorry, you're quite right -- application/json. I think that holds for all of our API endpoints.

There are a number of fixes to the API documentation going in tomorrow, hopefully things will be clearer after that.