Skip to main content

Hedera Agent Kit - CoinCap Plugin Python version

A plugin for Hedera Agent Kit PY that provides integration with the CoinCap API

In this plugin we use CoinCap to get the current price in USD of one HBAR and combine it with the power of the Hedera Agent Kit to get your current balance of HBA in USD currency.

Overview

This plugin enables AI agents to interact with the CoinCap API

Installation in the example index.js agent

1.- Install the plugin

pip install coincap-hedera-agent-kit-plugin

2.- Add your CoinCap API Bearer token in the .env file ( You get it in the CoinCap website )

# Coincap API needed by coincap-hedera-plugin
COINCAP_BEARER_TOKEN=******************************

3.- Import the plugin code in your index.js (Hedera Agent)

from coincap_hedera_plugin import conincap_h_plugin

4.- Import the core_account_query_plugin plugin code

This core plugin is already provided by the Hedera, it is needed to query the account (read its balance)

from hedera_agent_kit.plugins import core_account_query_plugin

5.- Add the plugin in the plugins secion of the agent

async def main():
        ...
        configuration=Configuration(
            tools=[],
            plugins=[
                core_account_query_plugin,
                conincap_h_plugin  # <---- add the plugin here

6.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:

response = await agent.ainvoke(
    {"messages": [{"role": "user", "content": "Get my balance in HBAR and also convert it to USD please"}]},

7.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency

python main.py

Tools

Get HBAR price in USD

Invoke the CoinCap API to get the current price in USD of one HBAR

Python Function

def get_hbar_price_from_coincap():

Input Parameters

None

Output Values

Value Type Description
Result float Value in USD currency of 1 HBAR according to CoinCap

Example Prompt

Get my balance in HBAR and also convert it to USD please

Optional - Code building, only needed when working on the source code

Use a code formatter, for example black

pip install black
black .

Optional - Distribution, only needed when creating your own python package) How to publish a PyPi package

1.- Read the instructions

1.- Create the distribution package

python setup.py sdist

2.- Install twine

pip install twine

3.- Upload package

twine upload dist/*

Metadata

Release files for coincap-hedera-agent-kit-plugin 0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coincap-hedera-agent-kit-plugin 0.9
File Size Uploaded
coincap_hedera_agent_kit_plugin-0.9.tar.gz 5.5 kB Details

Release files / coincap_hedera_agent_kit_plugin-0.9.tar.gz

Download URL coincap_hedera_agent_kit_plugin-0.9.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
47ae04fa0848d2bdcdba957945e35a8d4db8f579b67fba6bd77d8feb9ce7edbb
BLAKE2b-256 checksum
How to use checksums
143cda3d8e73d4e556260038592a0280e69c96843631e998a8c35d60a386c77b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.9 This release

1 release file

0.8.1

1 release file

0.8

1 release file

0.5

1 release file

0.4

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page