Skip to content

Latest commit

 

History

History
55 lines (32 loc) · 1.45 KB

File metadata and controls

55 lines (32 loc) · 1.45 KB

x402

It is possible to use :ref:`Zyte API <zyte-api>` without a Zyte API account by using the x402 protocol to handle payments.

During :ref:`installation <install>`, make sure to install the x402 extra.

Then, configure the private key of your Ethereum account as follows so that it can be used to authorize payments.

It is recommended to configure your Ethereum private key through an environment variable, so that it can be picked by both the :ref:`command-line client <command_line>` and the :ref:`Python client library <api>`:

  • On Windows’ CMD:

    > set ZYTE_API_ETH_KEY=YOUR_ETH_PRIVATE_KEY
  • On macOS and Linux:

    $ export ZYTE_API_ETH_KEY=YOUR_ETH_PRIVATE_KEY

Alternatively, you may pass your Ethereum private key to the clients directly:

  • To pass your Ethereum private key directly to the command-line client, use the --eth-key switch:

    zyte-api --eth-key YOUR_ETH_PRIVATE_KEY …
  • To pass your Ethereum private key directly to the Python client classes, use the eth_key parameter when creating a client object:

    from zyte_api import ZyteAPI
    
    client = ZyteAPI(eth_key="YOUR_ETH_PRIVATE_KEY")
    from zyte_api import AsyncZyteAPI
    
    client = AsyncZyteAPI(eth_key="YOUR_ETH_PRIVATE_KEY")