2023-01-04 09:51:09 +00:00
|
|
|
(python-api)=
|
|
|
|
|
2021-03-22 08:39:09 +00:00
|
|
|
# Python API
|
|
|
|
|
|
|
|
Backward compatibility of the API is not guaranteed at this point.
|
|
|
|
|
2021-09-29 08:01:53 +00:00
|
|
|
**JavaScript Modules**
|
2021-04-06 08:14:07 +00:00
|
|
|
|
2021-09-29 08:01:53 +00:00
|
|
|
By default there are two JavaScript modules. More can be added with
|
2023-02-01 19:00:58 +00:00
|
|
|
{js:func}`pyodide.registerJsModule`. You can import these modules using the Python
|
2021-07-26 23:00:27 +00:00
|
|
|
`import` statement in the normal way.
|
2021-04-06 08:14:07 +00:00
|
|
|
|
|
|
|
```{eval-rst}
|
|
|
|
.. list-table::
|
|
|
|
|
|
|
|
* - ``js``
|
2021-09-29 08:01:53 +00:00
|
|
|
- The global JavaScript scope.
|
2021-04-06 08:14:07 +00:00
|
|
|
* - :js:mod:`pyodide_js <pyodide>`
|
2021-09-29 08:01:53 +00:00
|
|
|
- The JavaScript Pyodide module.
|
2021-04-06 08:14:07 +00:00
|
|
|
```
|
2021-03-22 08:39:09 +00:00
|
|
|
|
2022-06-28 13:31:58 +00:00
|
|
|
**Python Modules**
|
|
|
|
|
|
|
|
```{eval-rst}
|
|
|
|
.. list-table::
|
|
|
|
|
|
|
|
* - :py:mod:`pyodide.code`
|
|
|
|
- Utilities for evaluating Python and JavaScript code.
|
|
|
|
* - :py:mod:`pyodide.console`
|
|
|
|
- Similar to the Python builtin `code` module but handles top level await. Used
|
|
|
|
for implementing the Pyodide console.
|
|
|
|
* - :py:mod:`pyodide.ffi`
|
2023-02-01 19:00:58 +00:00
|
|
|
- The :py:class:`~pyodide.ffi.JsProxy` class and utilities to help interact with JavaScript code.
|
2022-06-28 13:31:58 +00:00
|
|
|
* - :py:mod:`pyodide.http`
|
2023-02-01 19:00:58 +00:00
|
|
|
- Defines :py:func:`~pyodide.http.pyfetch` and other functions for making network requests.
|
2022-06-28 13:31:58 +00:00
|
|
|
* - :py:mod:`pyodide.webloop`
|
|
|
|
- The Pyodide event loop implementation. This is automatically configured
|
|
|
|
correctly for most use cases it is unlikely you will need it outside of niche
|
|
|
|
use cases.
|
|
|
|
```
|
|
|
|
|
2021-03-22 08:39:09 +00:00
|
|
|
```{eval-rst}
|
2022-06-28 13:31:58 +00:00
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
2021-03-22 08:39:09 +00:00
|
|
|
|
2022-06-28 13:31:58 +00:00
|
|
|
python-api/code.md
|
|
|
|
python-api/console.md
|
|
|
|
python-api/ffi.md
|
|
|
|
python-api/http.md
|
|
|
|
python-api/webloop.md
|
2021-03-24 09:24:06 +00:00
|
|
|
```
|