What sort of API can be used for this? Is it a special proxy setting, extension or WebDriver client?
There's also somewhat equivalent surface exposed by WebDriver BiDi: https://w3c.github.io/webdriver-bidi/#module-network-command...
If you want to read more about these sorts of protocols, see: https://firefox-source-docs.mozilla.org/remote/index.html