Skip to content

Latest commit

 

History

History
66 lines (38 loc) · 1.7 KB

File metadata and controls

66 lines (38 loc) · 1.7 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:

  1. Read the Zyte Terms of Service. By using Zyte API, you are accepting them.
  2. During :ref:`installation <install>`, make sure to install the x402 extra.
  3. :ref:`Configure <eth-key>` the private key of your Ethereum account to authorize payments.

Configuring your Ethereum private key

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")