|
| 1 | +.. _x402: |
| 2 | + |
| 3 | +==== |
| 4 | +x402 |
| 5 | +==== |
| 6 | + |
| 7 | +It is possible to use :ref:`Zyte API <zyte-api>` without a Zyte API account by |
| 8 | +using the x402_ protocol to handle payments: |
| 9 | + |
| 10 | +#. Read the `Zyte Terms of Service`_. By using Zyte API, you are accepting |
| 11 | + them. |
| 12 | + |
| 13 | + .. _Zyte Terms of Service: https://www.zyte.com/terms-policies/terms-of-service/ |
| 14 | + |
| 15 | +#. During :ref:`installation <install>`, make sure to install the ``x402`` extra. |
| 16 | + |
| 17 | +#. :ref:`Configure <eth-key>` the *private* key of your Ethereum_ account to |
| 18 | + authorize payments. |
| 19 | + |
| 20 | + .. _Ethereum: https://ethereum.org/ |
| 21 | + |
| 22 | + |
| 23 | +.. _eth-key: |
| 24 | + |
| 25 | +Configuring your Ethereum private key |
| 26 | +===================================== |
| 27 | + |
| 28 | +It is recommended to configure your Ethereum private key through an environment |
| 29 | +variable, so that it can be picked by both the :ref:`command-line client |
| 30 | +<command_line>` and the :ref:`Python client library <api>`: |
| 31 | + |
| 32 | +- On Windows’ CMD: |
| 33 | + |
| 34 | + .. code-block:: shell |
| 35 | +
|
| 36 | + > set ZYTE_API_ETH_KEY=YOUR_ETH_PRIVATE_KEY |
| 37 | +
|
| 38 | +- On macOS and Linux: |
| 39 | + |
| 40 | + .. code-block:: shell |
| 41 | +
|
| 42 | + $ export ZYTE_API_ETH_KEY=YOUR_ETH_PRIVATE_KEY |
| 43 | +
|
| 44 | +Alternatively, you may pass your Ethereum private key to the clients directly: |
| 45 | + |
| 46 | +- To pass your Ethereum private key directly to the command-line client, use |
| 47 | + the ``--eth-key`` switch: |
| 48 | + |
| 49 | + .. code-block:: shell |
| 50 | +
|
| 51 | + zyte-api --eth-key YOUR_ETH_PRIVATE_KEY … |
| 52 | +
|
| 53 | +- To pass your Ethereum private key directly to the Python client classes, |
| 54 | + use the ``eth_key`` parameter when creating a client object: |
| 55 | + |
| 56 | + .. code-block:: python |
| 57 | +
|
| 58 | + from zyte_api import ZyteAPI |
| 59 | +
|
| 60 | + client = ZyteAPI(eth_key="YOUR_ETH_PRIVATE_KEY") |
| 61 | +
|
| 62 | + .. code-block:: python |
| 63 | +
|
| 64 | + from zyte_api import AsyncZyteAPI |
| 65 | +
|
| 66 | + client = AsyncZyteAPI(eth_key="YOUR_ETH_PRIVATE_KEY") |
0 commit comments