SDKs overview

Steem offers Software Development Kits (SDKs) and libraries designed to simplify interaction with its blockchain. These tools abstract away the complexities of direct blockchain communication, allowing developers to focus on application logic. The official SDKs support key functionalities such as managing user accounts, publishing content, voting on posts, and transferring tokens. Community-contributed libraries further extend the ecosystem, offering specialized functionalities or support for additional programming languages.

The primary goal of these SDKs is to provide a structured and efficient way to build decentralized applications (dApps) on the Steem blockchain. Developers can use these libraries to integrate Steem's features into web, mobile, or desktop applications, facilitating the creation of platforms centered around content creation, curation, and community engagement. Detailed guides and API references are available on the Steem developer portal to assist with integrating these tools.

Official SDKs by language

Steem provides official SDKs for popular programming languages, ensuring broad accessibility for developers. These SDKs are maintained to offer stable and up-to-date interfaces for the Steem blockchain's features. The core functionalities covered by these SDKs include:

  • Account Management: Creating, updating, and retrieving user account information.
  • Content Operations: Posting, editing, and deleting articles or comments.
  • Voting and Curation: Upvoting or downvoting content and managing curation rewards.
  • Token Transfers: Sending and receiving STEEM and SBD (Steem Blockchain Dollars) between accounts.
  • Blockchain Queries: Retrieving historical data, current block information, and transaction details.

The following table lists the official SDKs:

Language Package Name Installation Command Maturity
JavaScript steem-js npm install steem or yarn add steem Stable
Python steem-python pip install steem Stable

These SDKs are designed to be cross-platform, allowing developers to build applications for various environments, including web browsers, Node.js servers, and Python-based backend services. The Steem API reference documentation provides comprehensive details on the methods and parameters available within each SDK.

Installation

Installing Steem SDKs typically involves using the respective language's package manager. The process is straightforward for both JavaScript and Python environments.

JavaScript (steem-js)

For JavaScript projects, steem-js can be installed via npm (Node Package Manager) or Yarn. This SDK is compatible with both Node.js environments and modern web browsers, often requiring a bundler like Webpack or Rollup for browser usage.

Using npm:

npm install steem

Using Yarn:

yarn add steem

After installation, you can import the library into your JavaScript files. For Node.js, a require statement is commonly used, while ES6 import syntax is prevalent in modern front-end frameworks.

Python (steem-python)

The steem-python library is installed using pip, Python's package installer. It is compatible with Python 3.6+ environments.

Using pip:

pip install steem

It is recommended to install Python packages within a virtual environment to manage dependencies effectively. Tools like venv or conda can be used to create isolated environments for your projects.

Quickstart example

This section provides basic quickstart examples for interacting with the Steem blockchain using the official JavaScript and Python SDKs. These examples demonstrate fundamental operations such as fetching blockchain information or posting content.

JavaScript Quickstart (steem-js)

This example demonstrates how to fetch the latest block number and global properties of the Steem blockchain using steem-js.

const steem = require('steem');

// Set the Steem API host (e.g., a public Steem node)
steem.api.setOptions({
  url: 'https://api.steemit.com'
});

async function getBlockchainInfo() {
  try {
    const props = await steem.api.getDynamicGlobalPropertiesAsync();
    console.log('Latest Block Number:', props.head_block_number);
    console.log('Total STEEM supply:', props.total_vesting_fund_steem.split(' ')[0]);

    const version = await steem.api.getVersionAsync();
    console.log('Steem API Version:', version.steem_version);

  } catch (error) {
    console.error('Error fetching blockchain info:', error);
  }
}

getBlockchainInfo();

To run this JavaScript example:

  1. Save the code as index.js.
  2. Ensure Node.js is installed.
  3. Run npm install steem in your project directory.
  4. Execute with node index.js.

For more complex operations like posting or voting, you would typically use private keys for signing transactions. The steem-js documentation provides guidance on signing transactions securely.

Python Quickstart (steem-python)

This Python example shows how to connect to the Steem blockchain and retrieve a user's account balance and post history.

from steem import Steem

# Connect to a Steem node
s = Steem(nodes=['https://api.steemit.com'])

def get_account_info(account_name):
    try:
        # Get account details
        account = s.get_account(account_name)
        if account:
            print(f"Account: {account['name']}")
            print(f"STEEM Balance: {account['balance']}")
            print(f"SBD Balance: {account['sbd_balance']}")
            print(f"Voting Power: {account['voting_power'] / 100}%\n")

            # Get latest posts by the account
            # 'blog' returns posts, 'posts' returns all content including comments
            posts = s.get_discussions('blog', {'tag': account_name, 'limit': 3})
            print(f"Latest 3 posts by {account_name}:")
            for post in posts:
                print(f"  - Title: {post['title']} (Permlink: {post['permlink']})")
        else:
            print(f"Account '{account_name}' not found.")

    except Exception as e:
        print(f"Error fetching account info: {e}")

# Replace 'youraccountname' with an actual Steem account name
get_account_info('steemitblog')

To run this Python example:

  1. Save the code as steem_example.py.
  2. Ensure Python 3.6+ and pip are installed.
  3. Run pip install steem in your virtual environment.
  4. Execute with python steem_example.py.

The Steem Python library also supports advanced features like broadcasting custom JSON operations and managing wallets, as detailed in the Steem Python documentation.

Community libraries

Beyond the official SDKs, the Steem ecosystem benefits from various community-driven libraries and tools. These resources often fill specific niches, provide alternative implementations, or support languages not officially covered. While these libraries may not carry the same level of official support as steem-js or steem-python, they can be valuable for certain development needs.

Examples of community contributions might include:

  • Wrappers for other languages: Libraries that provide interfaces for Rust, Go, or PHP, allowing developers to interact with Steem using their preferred language.
  • Specialized tools: Applications or modules focused on specific tasks, such as creating Steem-based games, analytics dashboards, or integration with external services.
  • UI components: Front-end libraries that offer reusable components for building Steem-enabled user interfaces, simplifying the creation of dApp front-ends.

When considering community libraries, it is advisable to check their active maintenance, community support, and security implications. Resources like GitHub and Steem's official forums (though the official forums are now less active) are common places to discover and evaluate these contributions. The growth of community-driven tools is a common characteristic of decentralized ecosystems, fostering innovation and broader adoption, similar to how Google Maps Platform offers various community libraries for extended functionality.

Developers are encouraged to explore the broader Steem developer community for these resources, often found on platforms like GitHub by searching for steem-related repositories. Engaging with the community can also provide insights into best practices and emerging tools within the ecosystem.