Installation

NodeJS SDK

1. Install Moralis NodeJS SDK

To install Moralis NodeJS SDK, use one of the following commands:

npm install moralis
yarn add moralis
pnpm add moralis

2. Initialize Moralis' NodeJS SDK

🚧

Make Sure to Store the apiKey Value Inside a .env File

To initialize the SDK, add the following code to your NodeJS dapp:

const Moralis = require("moralis").default;

await Moralis.start({
  apiKey: "YOUR_API_KEY",
  // ...and any other configuration
});
import Moralis from "moralis";

await Moralis.start({
  apiKey: "YOUR_API_KEY",
  // ...and any other configuration
});

Here, Moralis.start, with apiKey as a required input, will initialize the Moralis SDK.

Once the Moralis NodeJS SDK is initialized, you will be able to use all the powerful APIs provided by Moralis to build your dapps.

3. Configuration

You can set the configuration for your Moralis instance when you call Moralis.start(config). For example:

Moralis.start({
  apiKey: "YOUR_API_KEY",
  formatEvmAddress: 'checksum',
  formatEvmChainId: 'decimal',
  logLevel: 'verbose'
})

Below, you can find the possible options for the configuration:

OptionDescriptionDefaultRequired
apiKeyYour secret Moralis ApiKeynullyes
formatEvmAddressFormat style for evm addresses. Possible values: 'lowercase', 'checksum''lowercase'no
formatEvmChainIdFormat style for chains. Possible values: 'decimal', 'hex''hex'no
logLevelLevel of detail for log messages. Possible values: 'verbose', 'debug', 'info', 'warning', 'error', 'off''info'no

Python SDK

To install the Moralis Python SDK, use the following command:

pip install moralis

A simple example of how to call the web3_api_version API function:

import moralis

print(moralis.utils.web3_api_version(api_key='API_KEY_HERE'))

# it prints {'version': '0.0.53'}

You can check here the syntax for all the other functions from the Python SDK: https://moralisweb3.github.io/Moralis-Python-SDK/.