![](/resources/banner.png)
# nektar
[![](https://images.hive.blog/20x20/https://images.ecency.com/DQmQBYsZc8G6awKZcVbonRsJBUWJ1HTZy3WuTaMXvBreyhj/4511507.png) Nektar](#) a Hive API SDK for Python.
## Official Release
**nektar** can now be used on your Python projects through PyPi by running pip command on a Python-ready environment.
`pip install hive-nektar --upgrade`
Current version is 0.9.\*, but more updates are coming soon.
This is compatible with Python 3.9 or later.
## WARNINGS:
- This package is still under development, some future breakage is inevitable.
- Some AppBase API methods are still under development and subject to change.
- Do NOT copy your private keys in your codes!
## Features
**1.** Lightweight package for small Hive dApps or projects. <br>
**2.** Readily available methods using the `nektar.Waggle()` class. <br>
**3.** Highly costumizable via `appbase` module. <br>
## Nektar Module
Contains the Waggle, Swarm, and Drone classes.
***WARNING:*** Store WIFs securely in a separate file!
**Import Module**
```python
from nektar import Nektar
import json
wifs = { "active": "5*" , "posting": "5*"}
hive = Nektar(username, wifs=wifs)
# Hive Developer Portal > Understanding Configuration Values
# https://developers.hive.io/tutorials-recipes/understanding-configuration-values.html
data = hive.get_config()
print(json.dumps(data, indent=2))
# get configuration values
data = hive.get_config(field="HIVE_CHAIN_ID", fallback="bee*")
print("HIVE_CHAIN_ID: " + str(data))
# get user's resource credits
prin(hive.resource_credits())
print(hive.resource_credits("valid-username"))
# get user's manabar
percentage = hive.manabar()
print("Current Mana: " + str(int(percentage)) + "%")
# transfer HBD to another account
receiver = "valid-username"
amount = 0.001
asset = "HBD"
message = "Thanks for supporting us!"
hive.memo(receiver, amount, asset, message)
# transfer HIVE to another account
receiver = "valid-username"
amount = 0.001
asset = "HIVE"
message = "Thanks for supporting us!"
result = hive.memo(receiver, amount, asset, message)
# transfer HBD to savings
receiver = "valid-username"
amount = 0.001
asset = "HBD"
message = "Thanks for supporting us!"
hive.transfer_to_savings(receiver, amount, asset, message)
# transfer HIVE to savings
receiver = "valid-username"
amount = 0.001
asset = "HIVE"
message = "Thanks for supporting us!"
hive.transfer_to_savings(receiver, amount, asset, message)
# transfer HIVE to vesting (power up)
receiver = "valid-username"
amount = 0.001
hive.transfer_to_vesting(receiver, amount)
# Broadcasting a custom JSON (Posting key)
hive.custom_json(
id_="nektar-tests",
jdata={ "test": "nektar" },
required_posting_auths=["valid-username"]
# Broadcasting a custom JSON (Active key)
hive.custom_json(
id_="nektar-tests",
jdata={ "test": "nektar" },
required_auths=["valid-username"]
```
**Import Module**
```python
from nektar import Nektar
import json
wifs = { "active": "5*" , "posting": "5*"}
hive = Nektar(username, wifs=wifs)
```
## Waggle Class
Methods for blogging and engagement
**Import Module**
```python
from nektar import Waggle
import json
```
**Basic Setup**
```python
from nektar import Waggle
hive = Waggle(username)
```
**Setup Application**
```python
username = "hive-nektar"
app_name = "nektar.app"
version = "2022.10.05"
hive = Waggle(username, app=app_name, version=version)
```
**Setup Application with WIF/s**
***WARNING:*** Store WIFs securely in a separate file!
```python
## option 1
wif = "5*"
role="posting"
username = "hive-nektar"
hive = Waggle(username, wif=wif, role=role)
## option 2
username = "hive-nektar"
wifs = { "active": "5*" }
hive = Waggle(username, wifs=wifs)
```
**Initialize with Custom Parmeters**
```python
custom_nodes = ["testnet.openhive.network"]
CHAIN_ID_TESTNET = "18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e"
hive = Waggle("valid-username", wifs=wifs, nodes=custom_nodes, chain_id=CHAIN_ID_TESTNET, timeout=25, retries=1, warning=True)
```
**Get account details**
```python
metadata = json.loads(hive.account["posting_json_metadata"])
name = metadata["profile"]["name"]
```
**Get Blockchain Constants**
```python
# Hive Developer Portal > Understanding Configuration Values
# https://developers.hive.io/tutorials-recipes/understanding-configuration-values.html
data = hive.get_config()
print(json.dumps(data, indent=4))
data = hive.get_config(field="HIVE_CHAIN_ID", fallback="bee*")
print("HIVE_CHAIN_ID: " + str(data))
```
**Browse Communities**
```python
## get up to 200 communities by rank
communities = hive.communities(limit=200)
for community in communities:
print(community["name"] + "\t" + community["title"])
communities = {}
sorting = ["new", "rank", "subs"]
for sort in sorting:
## get up to 1000 communities per sorting filter
for community in hive.communities(sort=sort):
communities.update({community["name"]: community})
```
**Get Posts with tag**
Get posts in a community by sorting filter:
- `created`
- `trending`
- `hot`
- `promoted`
- `payout`
- `payout_comments`
- `muted`
```python
tag = "travel"
posts = hive.posts(tag, limit=100, sort="created")
print(posts[0]["author"])
print(posts[0]["permlink"])
print(posts[0]["title"])
```
**Get Posts in a Community**
Get posts in a community by sorting filter:
- `created`
- `trending`
- `hot`
- `promoted`
- `payout`
- `payout_comments`
- `muted`
```python
community = "hive-1*" # supply with a valid community name
posts = hive.posts(community, limit=100, sort="created")
print(posts[0]["author"])
print(posts[0]["permlink"])
print(posts[0]["title"])
```
**Get Posts with a Tag**
Get posts in a community by sorting filter:
- `created`
- `trending`
- `hot`
- `promoted`
- `payout`
- `payout_comments`
- `muted`.
```python
tag = "nature"
posts = hive.posts(tag, limit=10, sort="created")
for post in posts:
print(post["title"])
```
**Get Community Sunscribers**
```python
subscribers = {}
community = "hive-1*" # supply with a valid community name
for subscriber in hive.subscribers(community, limit=1000):
subscribers.update({subscriber[0]: subscriber})
print(subscriber[0])
```
**Search Accounts Starting with a *pattern***
```python
accounts = hive.accounts(start="h", limit=1000)
```
**Get Account `raw` Current Resource Credits**
```python
## resource credit of the initialized account
data = hive.resource_credits()
print(json.dumps(data, indent=4))
## specify another account
data = hive.resource_credits("valid-account")
print(json.dumps(data, indent=4))
```
**Get Account Manabar Percentage**
```python
## manabar of the initialized account
percentage = hive.manabar()
print("Current Mana: " + str(int(percentage)) + "%")
## specify another account
percentage = hive.manabar("valid-account")
print("Current Mana: " + str(int(percentage)) + "%")
```
**Get Account Reputation**
```python
## reputation of the initialized account
reputation = hive.reputation(score=False)
print("Reputation: " + str(reputation))
## reputation of the initialized account, converted to score
score = hive.reputation()
print("Reputation score: " + str(score))
## specify another account, converted to score
score = hive.reputation(account="valid-username")
print("Reputation score: " + str(score))
```
**Get the List of Followers**
```python
## followers of the initialized account
followers = hive.followers()
print(followers)
## or using a valid account username
followers = hive.followers(account="valid-username")
print(followers)
```
**Get the Following of an Account**
```python
## followers of the initialized account
following = hive.following()
print("\n".join(following))
## or using a valid account username
following = hive.following(account="valid-username")
print("\n".join(following))
```
**Follow or Unfollow an Account**
```python
account = "valid-username"
hive.follow(account)
# options to unfollow
hive.follow(account, unfollow=True)
hive.unfollow(account)
```
**Get List of Account History**
```python
# up to 1000 operations, most recent first
transactions = hive.history()
print("Transactions:", json.dumps(transactions[1], indent=4))
# up to 1000 upvote operations of another acount
transactions = hive.history(account="oniemaniego", start=1000, low=0)
print("Transactions:", json.dumps(transactions[1], indent=4))
# up to 100 operations of another acount
transactions = hive.history(account="oniemaniego", start=1000, limit=100)
for transaction in transactions[:1]:
print(transaction[0], transaction[1]["op"])
```
**Get the List of Delegators**
```python
## followers of the initialized account
delegators = hive.delegators()
for delegator, data in delegators.items():
print(delegator)
for dt, vests in data.items():
print(dt, vests)
## or using a valid account username
delegators = hive.delegators("valid-username")
for delegator, data in delegators.items():
print(delegator)
for dt, vests in data.items():
print(dt, vests)
## only show active delegations
delegators = hive.delegators(active=True)
for delegator, vests in delegators.items():
print(delegator, vests)
```
**Get the List of Delegatees**
```python
## followers of the initialized account
delegatees = hive.delegatees()
for delegatee, data in delegatees.items():
print(delegatee)
for dt, vests in data.items():
print(dt, vests)
## or using a valid account username
delegatees = hive.delegatees("valid-username")
for delegatee, data in delegatees.items():
print(delegatee)
for dt, vests in data.items():
print(dt, vests)
## only show active delegations
delegatees = hive.delegatees(active=True)
for delegatee, vests in delegatees.items():
print(delegatee, vests)
```
**Get Blog Posts**
Get posts of an account by sorting filter:
- `blog`
- `feed`
- `post`
- `replies`
- `payout`
```python
## blog posts of the initialized account
blogs = hive.blogs(limit=10)
for blog in blogs:
for key, value in blog.items():
print(key + ":", value)
## customized blog search from another account
blogs = hive.blogs(account="valid-username", sort="blog")
for blog in blogs:
for key, value in blog.items():
print(key + ":", value)
```
**Get Outward Comments**
Get comments made by an account/
```python
comments = hive.comments(limit=20)
for comment in comments:
print(comment["body"])
## comments of another account
comments = hive.comments(username="valid-username", limit=100)
for comment in comments:
print(json.dumps(comment, indent=2))
```
**Access a Blog Post/Comment (Bridge API)**
If the post or comment does not exists in the blockchain, it will return an empty dictionary.
```python
author = "valid-username"
permlink = "valid-permlink"
content = hive.get_post(author, permlink)
print(json.dumps(content, indent=4))
author = "valid-username"
permlink = "test-permlink-abc-123-def-456"
content = hive.get_post(author, permlink, retries=5)
if not content:
print("The post is not yet in the blockchain.")
print(json.dumps(content, indent=2))
```
**Access a Blog Post/Comment (Condenser API)**
If the post or comment does not exists in the blockchain, it will return an empty dictionary.
```python
author = "valid-username"
permlink = "valid-permlink"
content = hive.get_post(author, permlink)
print(json.dumps(content, indent=4))
author = "valid-username"
permlink = "test-permlink-abc-123-def-456"
content = hive.get_content(author, permlink, retries=2)
if not content:
print("The post is not yet in the blockchain.")
print(json.dumps(content, indent=2))
```
**Create a Post Programmatically**
***WARNING:*** Do NOT abuse Hive, post only quality contents not more than once a day.
```python
title = "Make Your Title Catchy, But Not ClickBait-y"
body = "# This is a header\n\n" \
"## Adding a `h2` Header" \
"![Image Caption](https://image.link.goes/here)\n\n" \
"<center>How to center a text?</center>\n\n" \
"This is how to make it *itzlic*, **bold**, or ***both***!\n\n" \
"Drink more H<sub>2</sub>O<sup>[citatation needed]</sup> everyday.\n\n" \
"<br> this is a line break, below is a horizontal rule:\n\n" \
"---" \
"Click this [link](https://www.markdownguide.org/) to learn more about Markdowwn.\n\n"
description = "My first blog using Nektar!"
tags = "devtalk nektar hive api coderundebug"
community = "hive-1*" # use a valid community name
hive.new_post(title, body, description, tags, community)
```
**Reblog a Post**
```python
author = "valid-username"
permlink = "valid-permlink"
hive.reblog(author, permlink)
```
**Reply to a Post**
***WARNING:*** Do NOT abuse Hive, do not create spam comments.
```python
author = "valid-username"
permlink = "valid-permlink"
body = "Allows markdown formatted text."
hive.reply(author, permlink, body)
```
**Get all replies on a blog post.**
```python
author = ""
permlink = ""
replies = hive.replies(author, permlink)
print(json.dumps(replies, indent=2))
```
**Get all accounts who reblogged the blog post.**
```python
author = ""
permlink = ""
accounts = hive.reblogs(author, permlink)
print("Reblogged by: " + ", ".join(accounts))
```
**Vote on A Post**
```python
author = ""
permlink = ""
weight = 10000 # -10000 to 10000, where 1000 = 100%
hive.vote(author, permlink, weight)
```
**Get active votes on a blog post.**
```python
author = ""
permlink = ""
votes = hive.votes(author, permlink)
print(json.dumps(votes, indent=2))
```
**Send a Memo**
```python
receiver = "valid-username"
amount = 0.001
asset = "HBD"
message = "Sending you some HBDs..."
hive.memo(receiver, amount, asset, message)
```
**Create a Custom JSON (Active Key)**
```python
protocol_id = "nektar_admin"
json_data = { "app": "nektar.app/2022.10.05" }
required_auths = ["valid-username"]
required_posting_auths = []
hive.custom_json(protocol_id, json_data, required_auths, required_posting_auths)
```
**Check if Transaction has the Neccessary Auths**
Will only check if the necessary WIF has signed the transaction, will not broadcast it.
This is also available in `post`, `reply`, `vote`, and `memo` methods.
```python
protocol_id = "nektar_admin"
json_data = { "app": "nektar.app/2022.10.05" }
required_auths = ["valid-username"]
required_posting_auths = []
hive.custom_json(protocol_id, json_data, required_auths, required_posting_auths, verify_only=True)
```
**Check if a Custom Transaction has the Necessary Signatures**
Will only check if the necessary WIF has signed the transaction, will not broadcast it.
This is also available in `post`, `reply`, `vote`, and `memo` methods.
```python
signed_transaction = [ { "ref_block_num": 0, "ref_block_prefix": 0, "expiration": "1970-01-01T00:00:00", "operations": [], "extensions": [], "signatures": [] }]
verified = hive.verify_authority(signed_transaction)
print("OK:", verified)
```
**Power Up**
```python
hive.power_up("valid-username", 100)
```
## Swarm Class
Community Management methods
```python
from nektar import Swarm
## Initialize Swarm class
hive = Swarm("hive-*", "valid-username", wif="5*", role="posting")
## Initialize Swarm class with dictionary of WIFs
hive = Swarm("hive-*", "valid-username", wifs=wifs)
## Initialize Swarm class with app and version")
hive = Swarm("hive-*", "valid-username", app="nektar.app", version="2022.10.05")
## Initialize Swarm class with custom parameters")
hive = Swarm("hive-*", "valid-username", wifs=wifs, timeout=25, retries=1, warning=True)
## Mute a post
hive.mute("valid-username", "valid-permlink", "Offtopic")
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Unmute a post - option 1
hive.mute("valid-username", "valid-permlink", "Offtopic", mute=False)
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Unmute a post - option 2
hive.unmute("valid-username", "valid-permlink", "On topic, apologies")
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Mark post as spam
hive.mark_spam("valid-username", "valid-permlink")
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Update community properties
title = "Community Name"
about = "About information"
is_nsfw = False
description = "This is a description"
flag_text = "..."
hive.update(title, about, is_nsfw, description, flag_text)
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Subscribe to a community
hive.subscribe()
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Unsubscribe to a community - option 1
hive.subscribe(subscribe=False)
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Unsubscribe to a community - option 2
hive.unsubscribe()
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Pin a post
hive.pin("valid-username", "valid-permlink")
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Unpin a post - option 1
hive.pin("valid-username", "valid-permlink", pin=False)
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Unpin a post - option 2
hive.unpin("valid-username", "valid-permlink")
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
## Flag a post
hive.flag("valid-username", "valid-permlink", "flagging post for reason...")
print("Transaction: " + json.dumps(hive.appbase.signed_transaction, indent=2))
```
## AppBase Module
**Basic Usage**
```python
from appbase import AppBase
CHAIN_ID_MAINNET = "beeab0de00000000000000000000000000000000000000000000000000000000"
CHAIN_ID_TESTNET = "18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e"
## Initialize AppBase Class
hive = AppBase()
## Initialize AppBase Class with custom parameters
custom_nodes = ["testnet.openhive.network"]
hive = AppBase(nodes=custom_nodes, chain_id=CHAIN_ID_TESTNET, timeout=5, retries=1, warning=True)
## Change to custom nodes
hive.custom_nodes(custom_nodes)
## Add new WIF and equivalent role
hive.append_wif(wif="5*", role="posting")
hive.append_wif(wif="5*", role="active")
## Add new dictionary of roles and their equivalent WIFs
wifs = {"posting": "5*", "active": "5*"}
hive.append_wif(wifs)
## Change retries to custom value
hive.set_timeout(15)
## Read the actual Hive API documentation for proper guidance
## https://developers.hive.io/apidefinitions/
## Access API and its methods - generic
hive.api("condenser")
hive.api("condenser_api")
## `account_by_key_api.get_key_references`
# version = hive.api("account_by_key_api").*
params = {"keys": "STM*"]}
data = hive.account_by_key().get_key_references(params)
print("Account by public key: " + json.dumps(data, indent=2))
## `bridge.get_profile`
# version = hive.api("bridge").*
params = {"account": "valid-username1", "observer": "valid-username2"}
data = hive.bridge().get_profile(params)
print("Profile: " + json.dumps(data, indent=2))
## `account_history_api.get_account_history`
# version = hive.api("account_history").*
params = {
"account": "valid-username",
"start": 1000,
"limit": 1000,
"include_reversible": True,
"operation_filter_low": 0,
"operation_filter_high": 1,
}
data = hive.account_history().get_account_history(params)
print("Account history: " + json.dumps(data, indent=2))
## `block_api.get_block`
params = {"block_num": 8675309}
data = hive.block().get_block(params)
print("Block: " + json.dumps(data, indent=2))
## Create an instance for specific API only.
condenser = hive.condenser()
params = "valid-username", "valid-permlink"]
data = condenser.get_content(params)
print("Content #1: " + json.dumps(data, indent=2))
params = "valid-username", 0, 10]
data = condenser.get_blog(params)
print("Content #2: " + json.dumps(data, indent=2))
## Using the `request` method
method = "rc_api.find_rc_accounts"
params = {"accounts": "valid-username"]}
data = hive.request(method, params, strict=False)
print("Accounts: " + json.dumps(data, indent=2))
## Using the `broadcast` method - `condenser_api`
method = "condenser_api.get_transaction_hex"
transaction = {
"ref_block_num": 123456,
"ref_block_prefix": 1234567890,
"expiration": "2022-10-05T18:00:00",
"operations": [
[
"vote",
{
"voter": "valid-username1",
"author": "valid-username2",
"permlink": "valid-permlink",
"weight": 10000,
},
]
],
"extensions": [],
}
data = hive.broadcast(method, transaction, strict=False)
print("Transaction hex: " + data)
```
Raw data
{
"_id": null,
"home_page": "",
"name": "hive-nektar",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "nektar,hive,blockchain,api,sdk",
"author": "Rodney Maniego Jr.",
"author_email": "rodney.maniegojr@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/45/49/fddaeb5437e1467cdaa327c0c10197a545ae1c393c1822278a9bc2651038/hive-nektar-1.1.6.tar.gz",
"platform": null,
"description": "![](/resources/banner.png)\n\n# nektar\n[![](https://images.hive.blog/20x20/https://images.ecency.com/DQmQBYsZc8G6awKZcVbonRsJBUWJ1HTZy3WuTaMXvBreyhj/4511507.png) Nektar](#) a Hive API SDK for Python.\n\n## Official Release\n**nektar** can now be used on your Python projects through PyPi by running pip command on a Python-ready environment.\n\n`pip install hive-nektar --upgrade`\n\nCurrent version is 0.9.\\*, but more updates are coming soon.\n\nThis is compatible with Python 3.9 or later.\n\n## WARNINGS:\n - This package is still under development, some future breakage is inevitable.\n - Some AppBase API methods are still under development and subject to change.\n - Do NOT copy your private keys in your codes!\n\n## Features\n**1.** Lightweight package for small Hive dApps or projects. <br>\n**2.** Readily available methods using the `nektar.Waggle()` class. <br>\n**3.** Highly costumizable via `appbase` module. <br>\n\n## Nektar Module\nContains the Waggle, Swarm, and Drone classes. \n\n***WARNING:*** Store WIFs securely in a separate file!\n\n**Import Module**\n```python\nfrom nektar import Nektar\nimport json\n\nwifs = { \"active\": \"5*\" , \"posting\": \"5*\"}\nhive = Nektar(username, wifs=wifs)\n\n# Hive Developer Portal > Understanding Configuration Values\n# https://developers.hive.io/tutorials-recipes/understanding-configuration-values.html\ndata = hive.get_config()\nprint(json.dumps(data, indent=2))\n\n# get configuration values\ndata = hive.get_config(field=\"HIVE_CHAIN_ID\", fallback=\"bee*\")\nprint(\"HIVE_CHAIN_ID: \" + str(data))\n\n# get user's resource credits\nprin(hive.resource_credits())\nprint(hive.resource_credits(\"valid-username\"))\n\n# get user's manabar\npercentage = hive.manabar()\nprint(\"Current Mana: \" + str(int(percentage)) + \"%\")\n\n# transfer HBD to another account\nreceiver = \"valid-username\"\namount = 0.001\nasset = \"HBD\"\nmessage = \"Thanks for supporting us!\"\nhive.memo(receiver, amount, asset, message)\n\n# transfer HIVE to another account\nreceiver = \"valid-username\"\namount = 0.001\nasset = \"HIVE\"\nmessage = \"Thanks for supporting us!\"\nresult = hive.memo(receiver, amount, asset, message)\n\n# transfer HBD to savings\nreceiver = \"valid-username\"\namount = 0.001\nasset = \"HBD\"\nmessage = \"Thanks for supporting us!\"\nhive.transfer_to_savings(receiver, amount, asset, message)\n\n# transfer HIVE to savings\nreceiver = \"valid-username\"\namount = 0.001\nasset = \"HIVE\"\nmessage = \"Thanks for supporting us!\"\nhive.transfer_to_savings(receiver, amount, asset, message)\n\n# transfer HIVE to vesting (power up)\nreceiver = \"valid-username\"\namount = 0.001\nhive.transfer_to_vesting(receiver, amount)\n\n# Broadcasting a custom JSON (Posting key)\nhive.custom_json(\n id_=\"nektar-tests\",\n jdata={ \"test\": \"nektar\" },\n required_posting_auths=[\"valid-username\"]\n\n# Broadcasting a custom JSON (Active key)\nhive.custom_json(\n id_=\"nektar-tests\",\n jdata={ \"test\": \"nektar\" },\n required_auths=[\"valid-username\"]\n\n```\n\n**Import Module**\n```python\nfrom nektar import Nektar\nimport json\n\nwifs = { \"active\": \"5*\" , \"posting\": \"5*\"}\nhive = Nektar(username, wifs=wifs)\n```\n\n## Waggle Class \nMethods for blogging and engagement\n**Import Module**\n```python\nfrom nektar import Waggle\nimport json\n```\n\n**Basic Setup**\n```python\nfrom nektar import Waggle\n\nhive = Waggle(username)\n```\n\n**Setup Application**\n```python\n\nusername = \"hive-nektar\"\napp_name = \"nektar.app\"\nversion = \"2022.10.05\"\n\nhive = Waggle(username, app=app_name, version=version)\n```\n\n**Setup Application with WIF/s** \n\n***WARNING:*** Store WIFs securely in a separate file!\n```python\n\n## option 1\nwif = \"5*\"\nrole=\"posting\"\nusername = \"hive-nektar\"\n\nhive = Waggle(username, wif=wif, role=role)\n\n## option 2\nusername = \"hive-nektar\"\n\nwifs = { \"active\": \"5*\" }\nhive = Waggle(username, wifs=wifs)\n\n```\n\n**Initialize with Custom Parmeters**\n```python\n\ncustom_nodes = [\"testnet.openhive.network\"]\nCHAIN_ID_TESTNET = \"18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e\"\nhive = Waggle(\"valid-username\", wifs=wifs, nodes=custom_nodes, chain_id=CHAIN_ID_TESTNET, timeout=25, retries=1, warning=True)\n\n```\n\n**Get account details**\n```python\nmetadata = json.loads(hive.account[\"posting_json_metadata\"])\nname = metadata[\"profile\"][\"name\"]\n```\n\n**Get Blockchain Constants** \n\n```python\n# Hive Developer Portal > Understanding Configuration Values\n# https://developers.hive.io/tutorials-recipes/understanding-configuration-values.html\ndata = hive.get_config()\nprint(json.dumps(data, indent=4))\n \ndata = hive.get_config(field=\"HIVE_CHAIN_ID\", fallback=\"bee*\")\nprint(\"HIVE_CHAIN_ID: \" + str(data))\n```\n\n**Browse Communities** \n```python\n\n## get up to 200 communities by rank\ncommunities = hive.communities(limit=200)\nfor community in communities:\n print(community[\"name\"] + \"\\t\" + community[\"title\"])\n\ncommunities = {}\nsorting = [\"new\", \"rank\", \"subs\"]\nfor sort in sorting:\n ## get up to 1000 communities per sorting filter\n for community in hive.communities(sort=sort):\n communities.update({community[\"name\"]: community})\n```\n\n**Get Posts with tag** \nGet posts in a community by sorting filter:\n - `created`\n - `trending`\n - `hot`\n - `promoted`\n - `payout`\n - `payout_comments`\n - `muted`\n\n```python\ntag = \"travel\"\nposts = hive.posts(tag, limit=100, sort=\"created\")\nprint(posts[0][\"author\"])\nprint(posts[0][\"permlink\"])\nprint(posts[0][\"title\"])\n```\n\n**Get Posts in a Community** \nGet posts in a community by sorting filter:\n - `created`\n - `trending`\n - `hot`\n - `promoted`\n - `payout`\n - `payout_comments`\n - `muted`\n\n```python\n\ncommunity = \"hive-1*\" # supply with a valid community name\nposts = hive.posts(community, limit=100, sort=\"created\")\nprint(posts[0][\"author\"])\nprint(posts[0][\"permlink\"])\nprint(posts[0][\"title\"])\n```\n\n**Get Posts with a Tag** \nGet posts in a community by sorting filter:\n - `created`\n - `trending`\n - `hot`\n - `promoted`\n - `payout`\n - `payout_comments`\n - `muted`.\n\n```python\ntag = \"nature\"\nposts = hive.posts(tag, limit=10, sort=\"created\")\nfor post in posts:\n print(post[\"title\"])\n```\n\n**Get Community Sunscribers** \n```python\n\nsubscribers = {}\ncommunity = \"hive-1*\" # supply with a valid community name\nfor subscriber in hive.subscribers(community, limit=1000):\n subscribers.update({subscriber[0]: subscriber})\n print(subscriber[0])\n```\n\n**Search Accounts Starting with a *pattern*** \n```python\naccounts = hive.accounts(start=\"h\", limit=1000)\n```\n\n**Get Account `raw` Current Resource Credits** \n```python\n## resource credit of the initialized account\ndata = hive.resource_credits()\nprint(json.dumps(data, indent=4))\n\n## specify another account\ndata = hive.resource_credits(\"valid-account\")\nprint(json.dumps(data, indent=4))\n```\n\n**Get Account Manabar Percentage** \n```python\n## manabar of the initialized account\npercentage = hive.manabar()\nprint(\"Current Mana: \" + str(int(percentage)) + \"%\")\n\n## specify another account\npercentage = hive.manabar(\"valid-account\")\nprint(\"Current Mana: \" + str(int(percentage)) + \"%\")\n```\n\n**Get Account Reputation** \n```python\n## reputation of the initialized account\nreputation = hive.reputation(score=False)\nprint(\"Reputation: \" + str(reputation))\n\n## reputation of the initialized account, converted to score\nscore = hive.reputation()\nprint(\"Reputation score: \" + str(score))\n\n## specify another account, converted to score\nscore = hive.reputation(account=\"valid-username\")\nprint(\"Reputation score: \" + str(score))\n```\n\n**Get the List of Followers** \n```python\n\n## followers of the initialized account\nfollowers = hive.followers()\nprint(followers)\n\n## or using a valid account username\nfollowers = hive.followers(account=\"valid-username\")\nprint(followers)\n```\n\n**Get the Following of an Account** \n```python\n\n## followers of the initialized account\nfollowing = hive.following()\nprint(\"\\n\".join(following))\n\n## or using a valid account username\nfollowing = hive.following(account=\"valid-username\")\nprint(\"\\n\".join(following))\n```\n\n**Follow or Unfollow an Account**\n```python\naccount = \"valid-username\"\nhive.follow(account)\n\n# options to unfollow\nhive.follow(account, unfollow=True)\nhive.unfollow(account)\n```\n\n**Get List of Account History** \n```python\n \n# up to 1000 operations, most recent first\ntransactions = hive.history()\nprint(\"Transactions:\", json.dumps(transactions[1], indent=4))\n\n# up to 1000 upvote operations of another acount\ntransactions = hive.history(account=\"oniemaniego\", start=1000, low=0)\nprint(\"Transactions:\", json.dumps(transactions[1], indent=4))\n \n# up to 100 operations of another acount\ntransactions = hive.history(account=\"oniemaniego\", start=1000, limit=100)\nfor transaction in transactions[:1]:\n print(transaction[0], transaction[1][\"op\"])\n```\n\n**Get the List of Delegators** \n```python\n\n## followers of the initialized account\ndelegators = hive.delegators()\nfor delegator, data in delegators.items():\n print(delegator)\n for dt, vests in data.items():\n print(dt, vests)\n\n\n## or using a valid account username\ndelegators = hive.delegators(\"valid-username\")\nfor delegator, data in delegators.items():\n print(delegator)\n for dt, vests in data.items():\n print(dt, vests)\n\n## only show active delegations\ndelegators = hive.delegators(active=True)\nfor delegator, vests in delegators.items():\n print(delegator, vests)\n```\n\n**Get the List of Delegatees** \n```python\n\n## followers of the initialized account\ndelegatees = hive.delegatees()\nfor delegatee, data in delegatees.items():\n print(delegatee)\n for dt, vests in data.items():\n print(dt, vests)\n\n\n## or using a valid account username\ndelegatees = hive.delegatees(\"valid-username\")\nfor delegatee, data in delegatees.items():\n print(delegatee)\n for dt, vests in data.items():\n print(dt, vests)\n\n## only show active delegations\ndelegatees = hive.delegatees(active=True)\nfor delegatee, vests in delegatees.items():\n print(delegatee, vests)\n```\n\n**Get Blog Posts** \nGet posts of an account by sorting filter:\n - `blog`\n - `feed`\n - `post`\n - `replies`\n - `payout`\n\n```python\n## blog posts of the initialized account\nblogs = hive.blogs(limit=10)\nfor blog in blogs:\n for key, value in blog.items():\n print(key + \":\", value)\n \n## customized blog search from another account\nblogs = hive.blogs(account=\"valid-username\", sort=\"blog\")\nfor blog in blogs:\n for key, value in blog.items():\n print(key + \":\", value)\n```\n\n**Get Outward Comments** \nGet comments made by an account/\n\n```python\ncomments = hive.comments(limit=20)\nfor comment in comments:\n print(comment[\"body\"])\n\n## comments of another account\ncomments = hive.comments(username=\"valid-username\", limit=100)\nfor comment in comments:\n print(json.dumps(comment, indent=2))\n```\n\n**Access a Blog Post/Comment (Bridge API)** \nIf the post or comment does not exists in the blockchain, it will return an empty dictionary.\n\n```python\n\nauthor = \"valid-username\"\npermlink = \"valid-permlink\"\ncontent = hive.get_post(author, permlink)\nprint(json.dumps(content, indent=4))\n \nauthor = \"valid-username\"\npermlink = \"test-permlink-abc-123-def-456\"\ncontent = hive.get_post(author, permlink, retries=5)\nif not content:\n print(\"The post is not yet in the blockchain.\")\nprint(json.dumps(content, indent=2))\n```\n\n**Access a Blog Post/Comment (Condenser API)** \nIf the post or comment does not exists in the blockchain, it will return an empty dictionary.\n\n```python\n\nauthor = \"valid-username\"\npermlink = \"valid-permlink\"\ncontent = hive.get_post(author, permlink)\nprint(json.dumps(content, indent=4))\n \nauthor = \"valid-username\"\npermlink = \"test-permlink-abc-123-def-456\"\ncontent = hive.get_content(author, permlink, retries=2)\nif not content:\n print(\"The post is not yet in the blockchain.\")\nprint(json.dumps(content, indent=2))\n```\n\n**Create a Post Programmatically** \n\n***WARNING:*** Do NOT abuse Hive, post only quality contents not more than once a day.\n\n```python\n \ntitle = \"Make Your Title Catchy, But Not ClickBait-y\"\nbody = \"# This is a header\\n\\n\" \\\n \"## Adding a `h2` Header\" \\\n \"![Image Caption](https://image.link.goes/here)\\n\\n\" \\\n \"<center>How to center a text?</center>\\n\\n\" \\\n \"This is how to make it *itzlic*, **bold**, or ***both***!\\n\\n\" \\\n \"Drink more H<sub>2</sub>O<sup>[citatation needed]</sup> everyday.\\n\\n\" \\\n \"<br> this is a line break, below is a horizontal rule:\\n\\n\" \\\n \"---\" \\\n \"Click this [link](https://www.markdownguide.org/) to learn more about Markdowwn.\\n\\n\"\ndescription = \"My first blog using Nektar!\"\ntags = \"devtalk nektar hive api coderundebug\"\ncommunity = \"hive-1*\" # use a valid community name\n\nhive.new_post(title, body, description, tags, community)\n```\n\n**Reblog a Post**\n```python\nauthor = \"valid-username\"\npermlink = \"valid-permlink\"\nhive.reblog(author, permlink)\n```\n\n**Reply to a Post** \n***WARNING:*** Do NOT abuse Hive, do not create spam comments.\n```python\n\nauthor = \"valid-username\"\npermlink = \"valid-permlink\"\nbody = \"Allows markdown formatted text.\"\nhive.reply(author, permlink, body)\n```\n\n**Get all replies on a blog post.** \n```python\n\nauthor = \"\"\npermlink = \"\"\n\nreplies = hive.replies(author, permlink)\nprint(json.dumps(replies, indent=2))\n```\n\n**Get all accounts who reblogged the blog post.** \n```python\n\nauthor = \"\"\npermlink = \"\"\n\naccounts = hive.reblogs(author, permlink)\nprint(\"Reblogged by: \" + \", \".join(accounts))\n```\n\n**Vote on A Post** \n```python\n\nauthor = \"\"\npermlink = \"\"\nweight = 10000 # -10000 to 10000, where 1000 = 100%\n\nhive.vote(author, permlink, weight)\n```\n\n**Get active votes on a blog post.** \n```python\n\nauthor = \"\"\npermlink = \"\"\n\nvotes = hive.votes(author, permlink)\nprint(json.dumps(votes, indent=2))\n```\n\n**Send a Memo** \n```python\n\nreceiver = \"valid-username\"\namount = 0.001\nasset = \"HBD\"\nmessage = \"Sending you some HBDs...\"\nhive.memo(receiver, amount, asset, message)\n```\n\n**Create a Custom JSON (Active Key)** \n```python\n\nprotocol_id = \"nektar_admin\"\njson_data = { \"app\": \"nektar.app/2022.10.05\" }\nrequired_auths = [\"valid-username\"]\nrequired_posting_auths = []\nhive.custom_json(protocol_id, json_data, required_auths, required_posting_auths)\n```\n\n**Check if Transaction has the Neccessary Auths** \nWill only check if the necessary WIF has signed the transaction, will not broadcast it.\nThis is also available in `post`, `reply`, `vote`, and `memo` methods.\n```python\nprotocol_id = \"nektar_admin\"\njson_data = { \"app\": \"nektar.app/2022.10.05\" }\nrequired_auths = [\"valid-username\"]\nrequired_posting_auths = []\nhive.custom_json(protocol_id, json_data, required_auths, required_posting_auths, verify_only=True)\n```\n\n**Check if a Custom Transaction has the Necessary Signatures** \nWill only check if the necessary WIF has signed the transaction, will not broadcast it.\nThis is also available in `post`, `reply`, `vote`, and `memo` methods.\n```python\n\nsigned_transaction = [ { \"ref_block_num\": 0, \"ref_block_prefix\": 0, \"expiration\": \"1970-01-01T00:00:00\", \"operations\": [], \"extensions\": [], \"signatures\": [] }]\n\nverified = hive.verify_authority(signed_transaction)\nprint(\"OK:\", verified)\n```\n\n**Power Up** \n```python\nhive.power_up(\"valid-username\", 100)\n```\n\n## Swarm Class \nCommunity Management methods\n```python\nfrom nektar import Swarm\n\n## Initialize Swarm class\nhive = Swarm(\"hive-*\", \"valid-username\", wif=\"5*\", role=\"posting\")\n\n## Initialize Swarm class with dictionary of WIFs\nhive = Swarm(\"hive-*\", \"valid-username\", wifs=wifs)\n\n## Initialize Swarm class with app and version\")\nhive = Swarm(\"hive-*\", \"valid-username\", app=\"nektar.app\", version=\"2022.10.05\")\n\n## Initialize Swarm class with custom parameters\")\nhive = Swarm(\"hive-*\", \"valid-username\", wifs=wifs, timeout=25, retries=1, warning=True)\n\n## Mute a post\nhive.mute(\"valid-username\", \"valid-permlink\", \"Offtopic\")\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Unmute a post - option 1\nhive.mute(\"valid-username\", \"valid-permlink\", \"Offtopic\", mute=False)\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Unmute a post - option 2\nhive.unmute(\"valid-username\", \"valid-permlink\", \"On topic, apologies\")\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Mark post as spam\nhive.mark_spam(\"valid-username\", \"valid-permlink\")\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Update community properties\ntitle = \"Community Name\"\nabout = \"About information\"\nis_nsfw = False\ndescription = \"This is a description\"\nflag_text = \"...\"\nhive.update(title, about, is_nsfw, description, flag_text)\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Subscribe to a community\nhive.subscribe()\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Unsubscribe to a community - option 1\nhive.subscribe(subscribe=False)\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Unsubscribe to a community - option 2\nhive.unsubscribe()\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Pin a post\nhive.pin(\"valid-username\", \"valid-permlink\")\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Unpin a post - option 1\nhive.pin(\"valid-username\", \"valid-permlink\", pin=False)\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Unpin a post - option 2\nhive.unpin(\"valid-username\", \"valid-permlink\")\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n\n## Flag a post\nhive.flag(\"valid-username\", \"valid-permlink\", \"flagging post for reason...\")\nprint(\"Transaction: \" + json.dumps(hive.appbase.signed_transaction, indent=2))\n```\n\n## AppBase Module\n**Basic Usage**\n```python\nfrom appbase import AppBase\n\nCHAIN_ID_MAINNET = \"beeab0de00000000000000000000000000000000000000000000000000000000\"\nCHAIN_ID_TESTNET = \"18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e\"\n\n## Initialize AppBase Class\nhive = AppBase()\n\n## Initialize AppBase Class with custom parameters\ncustom_nodes = [\"testnet.openhive.network\"]\nhive = AppBase(nodes=custom_nodes, chain_id=CHAIN_ID_TESTNET, timeout=5, retries=1, warning=True)\n\n## Change to custom nodes\nhive.custom_nodes(custom_nodes)\n\n## Add new WIF and equivalent role\nhive.append_wif(wif=\"5*\", role=\"posting\")\nhive.append_wif(wif=\"5*\", role=\"active\")\n\n## Add new dictionary of roles and their equivalent WIFs\nwifs = {\"posting\": \"5*\", \"active\": \"5*\"}\nhive.append_wif(wifs)\n\n## Change retries to custom value\nhive.set_timeout(15)\n\n## Read the actual Hive API documentation for proper guidance\n## https://developers.hive.io/apidefinitions/\n\n## Access API and its methods - generic\nhive.api(\"condenser\")\nhive.api(\"condenser_api\")\n\n## `account_by_key_api.get_key_references`\n# version = hive.api(\"account_by_key_api\").*\nparams = {\"keys\": \"STM*\"]}\ndata = hive.account_by_key().get_key_references(params)\nprint(\"Account by public key: \" + json.dumps(data, indent=2))\n\n## `bridge.get_profile`\n# version = hive.api(\"bridge\").*\nparams = {\"account\": \"valid-username1\", \"observer\": \"valid-username2\"}\ndata = hive.bridge().get_profile(params)\nprint(\"Profile: \" + json.dumps(data, indent=2))\n\n## `account_history_api.get_account_history`\n# version = hive.api(\"account_history\").*\nparams = {\n \"account\": \"valid-username\",\n \"start\": 1000,\n \"limit\": 1000,\n \"include_reversible\": True,\n \"operation_filter_low\": 0,\n \"operation_filter_high\": 1,\n}\ndata = hive.account_history().get_account_history(params)\nprint(\"Account history: \" + json.dumps(data, indent=2))\n\n## `block_api.get_block`\nparams = {\"block_num\": 8675309}\ndata = hive.block().get_block(params)\nprint(\"Block: \" + json.dumps(data, indent=2))\n\n## Create an instance for specific API only.\ncondenser = hive.condenser()\n\nparams = \"valid-username\", \"valid-permlink\"]\ndata = condenser.get_content(params)\nprint(\"Content #1: \" + json.dumps(data, indent=2))\n\nparams = \"valid-username\", 0, 10]\ndata = condenser.get_blog(params)\nprint(\"Content #2: \" + json.dumps(data, indent=2))\n\n## Using the `request` method\nmethod = \"rc_api.find_rc_accounts\"\nparams = {\"accounts\": \"valid-username\"]}\ndata = hive.request(method, params, strict=False)\nprint(\"Accounts: \" + json.dumps(data, indent=2))\n\n## Using the `broadcast` method - `condenser_api`\nmethod = \"condenser_api.get_transaction_hex\"\ntransaction = {\n \"ref_block_num\": 123456,\n \"ref_block_prefix\": 1234567890,\n \"expiration\": \"2022-10-05T18:00:00\",\n \"operations\": [\n [\n \"vote\",\n {\n \"voter\": \"valid-username1\",\n \"author\": \"valid-username2\",\n \"permlink\": \"valid-permlink\",\n \"weight\": 10000,\n },\n ]\n ],\n \"extensions\": [],\n}\ndata = hive.broadcast(method, transaction, strict=False)\nprint(\"Transaction hex: \" + data)\n\n```\n",
"bugtrack_url": null,
"license": "LICENSE.txt",
"summary": "Nektar, Hive API SDK for Python",
"version": "1.1.6",
"split_keywords": [
"nektar",
"hive",
"blockchain",
"api",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "52db014f5f7b498eca73a92a5a435c0f6628cea995a5a7a28786e8e4bf973710",
"md5": "1741992c083f80e2141090eecb7f9e61",
"sha256": "fe9fae7024e23936e1e00b63b98ebb6397f1c685b40f77882246df3defef3396"
},
"downloads": -1,
"filename": "hive_nektar-1.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1741992c083f80e2141090eecb7f9e61",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 37781,
"upload_time": "2023-01-23T20:13:34",
"upload_time_iso_8601": "2023-01-23T20:13:34.344605Z",
"url": "https://files.pythonhosted.org/packages/52/db/014f5f7b498eca73a92a5a435c0f6628cea995a5a7a28786e8e4bf973710/hive_nektar-1.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4549fddaeb5437e1467cdaa327c0c10197a545ae1c393c1822278a9bc2651038",
"md5": "dd35cdfda4d97d7bc38d73959e10406c",
"sha256": "a6f27781fd16695e3f04fd990330104bafd262b6f3adbd31d5464e9e9e324f99"
},
"downloads": -1,
"filename": "hive-nektar-1.1.6.tar.gz",
"has_sig": false,
"md5_digest": "dd35cdfda4d97d7bc38d73959e10406c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 45861,
"upload_time": "2023-01-23T20:13:37",
"upload_time_iso_8601": "2023-01-23T20:13:37.091852Z",
"url": "https://files.pythonhosted.org/packages/45/49/fddaeb5437e1467cdaa327c0c10197a545ae1c393c1822278a9bc2651038/hive-nektar-1.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-23 20:13:37",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "hive-nektar"
}