Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.0

Install Moralis SDK

What is the Moralis SDK?​

With the Moralis SDK, you can implement all of Moralis' products quickly and easily in your backend. The SDK comes with numerous features, such as:

  • Easily query data from the EVM and Solana API (such as block info, transaction info, NFT metadata, token prices, user balances, owner list of an NFT, etc.)
  • Web3 authentication, integrated into your own backend
  • Several utilities to transform and format data

What are the Languages Moralis Support?​

We currently support the following languages for our SDKs:

  • NodeJS
  • Python

For other programming languages, you can call our API as you would for a normal REST API.

Install Moralis SDK​

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

First register your Moralis account and get your Moralis API Key.

Once you have your Moralis API Key, install the Moralis SDK in your project.

npm install moralis

Initialize Moralis SDK​

caution

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

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

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

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.

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