Mobula Docs
Search…
⌃K

Static API - Installation

Mobula's protocol data are available to builders through several APIs. The Static API allows you to enter a crypto-token and get in response meta-data like the website, twitter, logo, etc. of the project. Mobula's APIs are extremely simple to integrate.

Request Static API access

To obtain access to Mobula Static API, simply fill out the form https://form.typeform.com/to/o8JAVzDV If you have any questions or need any help, do not hesitate to DM us.

Mobula JS - 3 lines of code integration

We built a javascript client for the API: if you're not a javascript developper, you can skip this part to go to the in-depth integration.
First thing first, let's download Mobula JS.
npm i mobulajs
To get data from Mobula, use the getData function :
const Mobula = require('mobulajs');
const mobula = new Mobula();
//This is your query token, for this example the Example token
const QUERY_TOKEN = '0x1010101010101010101010101010101010101010'
const data = await mobula.getData(QUERY_TOKEN)
The structure of the object you're getting is the following JSON:
{
"contracts": ["0x1010101010101010101010101010101010101010"],
"name": "Example",
"symbol": "EXP",
"logo": "https://s2.coinmarketcap.com/static/img/coins/64x64/19214.png",
"chains": ["Ethereum"],
"twitter": "https://twitter.com/example",
"description": "Here is an example of the description of the crypto-token you will query. It should be approximately this long.",
"website": "https://www.example.com/",
"chat": "https://t.me/example",
"audit": "https://certik.com/example",
"kyc": "https://staysafu.org/kyc/example"
}
That's it. You're done.

In-depth integration (20 lines of code)

The API interface is an EVM-compatible smart-contract. At the moment, the API is only available on the Main-net Polygon, which means that you will have to set up your provider with a Polygon RPC to be able to connect to it. You can use the following URL: https://polygon-rpc.com
To connect to it with a library like Ethers, you just need a code snippet like this :
const ethers = require('ethers');
const provider = ethers.getDefaultProvider('https://polygon-rpc.com');
Once connected to the provider, you can call our smart-contract API.
The smart-contract address is 0x4f93eed1fC945b5bC3FaAEc5C057DFf27dB31DBA
The method to call is staticData. In input, an address, in output, a string which is an IPFS hash containing the data. Here is an example of code:
const ethers = require('ethers');
const provider = ethers.getDefaultProvider('https://polygon-rpc.com');
const API_ADDRESS = '0x4f93eed1fC945b5bC3FaAEc5C057DFf27dB31DBA'
//This is your query token, for this example the Example token
const QUERY_TOKEN = '0x1010101010101010101010101010101010101010'
const apiContract = new ethers.Contract(API_ADDRESS,
['function staticData(address token) external view returns(string)'], provider)
async function getDataHash(tokenAddress) {
return await apiContract.staticData(tokenAddress)
}
getDataHash(QUERY_TOKEN).then(console.log)
Once the hash is obtained, a simple request to the IPFS network allows you to retrieve the JSON containing the data. The IPFS network endpoint is https://gateway.ipfs.io/ipfs/ + your hash.
const axios = require('axios')
//This is the hash you've got from getDataHash, for this example it's a random token
const dataHash = 'QmcMdhZ6odZhqa7V4JUguDg4RczTT8mdhhiKh8hgmTj7w6'
axios.get('https://gateway.ipfs.io/ipfs/' + dataHash).then(r => {
//This is simply for axios to extract data, nothing to do with Mobula
const data = r.data
//In this data object, you have all the informations needed about the token.
console.log(data.website, data.logo)
})
The structure of the received JSON is as follows:
{
"contract": "0x1010101010101010101010101010101010101010",
"name": "Example",
"symbol": "EXP",
"logo": "https://s2.coinmarketcap.com/static/img/coins/64x64/19214.png",
"chain": "Ethereum",
"twitter": "https://twitter.com/example",
"description": "Here is an example of the description of the crypto-token you will query. It should be approximately this long.",
"website": "https://www.example.com/",
"chat": "https://t.me/example",
"audit": "https://certik.com/example",
"kyc": "https://staysafu.org/kyc/example"
}
Let's recap by making a script in order to get the Mobula website from the crypto-token.
const ethers = require('ethers');
const axios = require('axios')
const provider = ethers.getDefaultProvider('https://polygon-rpc.com');
const API_ADDRESS = '0x4f93eed1fC945b5bC3FaAEc5C057DFf27dB31DBA'
//This is your query token, for this example it'll be Mobula's token
const QUERY_TOKEN = '0x1010101010101010101010101010101010101010'
const apiContract = new ethers.Contract(API_ADDRESS,
['function staticData(address token) external view returns(string)'], provider)
async function getDataHash(tokenAddress) {
return await apiContract.staticData(tokenAddress)
}
getDataHash(QUERY_TOKEN).then(dataHash => {
axios.get('https://gateway.ipfs.io/ipfs/' + dataHash).then(r => {
const data = r.data
console.log(data.description)
})
})
If your Ethereum framework doesn't support shortened ABIs like this one, here is the ABI of the API smart-contract : https://gist.github.com/NBMSacha/2517d428ebb33dfb872121bc7693128f