{"id":24856,"library":"ypricemagic","title":"ypricemagic","description":"A Python library for extracting historical on-chain price data from an archive node, supporting a wide range of tokens and protocols including Yearn, Curve, Balancer, Uniswap, and more. Current version 5.2.16, actively maintained with frequent releases.","status":"active","version":"5.2.16","language":"python","source_language":"en","source_url":"https://github.com/BobTheBuidler/ypricemagic","tags":["ethereum","defi","price-oracle","on-chain-data","archive-node"],"install":[{"cmd":"pip install ypricemagic","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Core dependency for Ethereum node interaction","package":"web3","optional":false},{"reason":"Middleware for efficient multi-call and batch requests","package":"dank_mids","optional":true},{"reason":"Used for ABI management and contract interaction","package":"eth-brownie","optional":true}],"imports":[{"note":"get_price is exposed at the top-level package","wrong":"from ypricemagic.magic import get_price","symbol":"get_price","correct":"from ypricemagic import get_price"},{"note":"Price class is also top-level","wrong":"from ypricemagic.price import Price","symbol":"Price","correct":"from ypricemagic import Price"}],"quickstart":{"code":"import os\nfrom ypricemagic import get_price\n\n# Requires an Ethereum archive node RPC URL\nrpc_url = os.environ.get('ETH_RPC_URL', 'https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY')\n\n# Get ETH price in USD at a specific block\nprice = get_price('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', block=15000000, fail_on_multiple_locators=True)\nprint(f'Price at block 15000000: {price}')","lang":"python","description":"Fetch the price of WETH at block 15,000,000. Set ETH_RPC_URL environment variable to your archive node endpoint."},"warnings":[{"fix":"Use an archive node RPC (e.g., Alchemy, Infura archive plan, or local archive node).","message":"Requires an archive node; non-archive nodes will fail with missing state errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from ypricemagic import get_price` directly.","message":"The old import path `from ypricemagic import magic` is deprecated and will be removed.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Ensure any custom price locators inherit from the new base classes; consult migration guide.","message":"In v5.0.0, the internal price fetching API was restructured; custom locator classes may break.","severity":"breaking","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Manually provide a price locator via the `locator` parameter or ensure the token is supported.","cause":"Token address not found in the built-in price magic database.","error":"KeyError: '0x...'"},{"fix":"Switch to an archive node endpoint.","cause":"Connected to a non-archive node that does not have historical state.","error":"Web3.exceptions.BadFunctionCallOutput: No data available - did you connect to an archive node?"},{"fix":"Use only keyword arguments: `get_price(token, block=123)`","cause":"Passing block as both positional and keyword argument.","error":"TypeError: get_price() got multiple values for argument 'block'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}