Pokémon Showdown has a Node.js API. It currently only works in Node, not browsers, although we're working on unifying it to work in browsers.
You can install it with the usual:
npm install pokemon-showdown
And you can use it to do the following things:
See: sim/SIMULATOR.md
Also available as a command-line API!
See: sim/TEAMS.md
Also available as a command-line API!
See: sim/DEX.md
Pokémon Showdown's Node.js package has TypeScript definitions for everything it exports, including a lot of undocumented APIs.
Please be aware that any undocumented API is unstable and should not be relied upon not to change. We do not follow semver for undocumented APIs. If you really want to use an undocumented API, remember to pin the exact PS version in your dependencies. You probably also want to follow the API update channel in the Discord server: https://psim.us/devdiscord