### Create Webhook (TypeScript) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/webhook/getting-started.mdx Example of how to create a new webhook using the Mobula API with a POST request. It includes specifying chain IDs, events, filters, and the callback URL. The API key is mandatory for this operation. ```typescript const url = 'https://production-stream.mobula.io/api/1/webhooks'; await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ "name": "FirstWebhook", "chainIds": ["evm:1"], "events": ["trace"], "apiKey": "xxxxx", "filters": { "eq": ["action.input", "0xd55ec697"] }, "url": "https://webhook.com/xxxxx" }) }); ``` -------------------------------- ### WebSocket: Connect and Send Message (TypeScript) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/getting-started.mdx Establishes a WebSocket connection to the Mobula stream and sends an initial message to subscribe to specific events and chains. This example demonstrates the client-side implementation for receiving real-time data. ```typescript const socket = new WebSocket("wss://production-stream.mobula.io"); socket.addEventListener("open", () => { socket.send(`{ "type": "stream", "payload": { "chainIds": ["evm:1", "evm:56"], "events": ["trace", "log", "trasaction", "block", "swap"], } }`); }); socket.addEventListener("message", (event) => { const data = JSON.parse(event.data); if (event.reorg) { // Handle reorg return; } }); // No need to close the socket, it will close automatically. ``` -------------------------------- ### Example Response Body Structure Source: https://github.com/mobulafi/mobula-api-docs/blob/main/sdk/introduction.mdx Illustrates the typical structure of a response body when fetching wallet data. It includes wallet identifiers, balance information, and a balance history array. ```json body: '{"data":{"wallet":["0x77a89c51f106d6cd547542a3a83fe73cb4459135"],"balance_usd":186.11174894116627,"balance_history": [[1650788304000,0],[1650788305000,0],[1650874705000,40.94737444508439], [1650961105000,41.43979364186007],[1651047505000,41.52255389488385], [1651133905000,39.98507396566903],[1651220305000,41.36797682434358], [1651306705000,39.94252843778348],[1651393105000,38.42918052538283], [1651479505000,38.44553804299468],[1651565905000,42.12988132520523], [1651652305000,41.08260516823677],[1651738705000,42.932806984287325], [1651825105000,40.20314283431752],[1661265693000,61.1200498094'... 51976 more characters, ``` -------------------------------- ### Webhook: Create Webhook (TypeScript) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/getting-started.mdx Demonstrates how to create a webhook subscription using a POST request to the Mobula API. This includes specifying the webhook name, target chains, events to monitor, an API key, and the callback URL. ```typescript await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: { "name": "FirstWebhook", "chainIds": ["evm:1"], "events": ["trace"], "apiKey": "xxxxx", "filters": { "eq": ["action.input", "0xd55ec697"] }, "url": "https://webhook.com/xxxxx" } }); ``` -------------------------------- ### Webhook API Endpoint Details (APIDOC) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/webhook/getting-started.mdx Details for the Mobula Webhook API endpoint, including the URL and the structure of the JSON request body for creating a webhook. This endpoint allows for real-time event notifications. ```APIDOC URL: https://production-stream.mobula.io/api/1/webhooks Request Body (JSON): { "name": "MyFirstWebhook", "chainIds": ["evm:1", "evm:56"], "events": ["trace", "log", "trasaction", "block", "swap"], "apiKey": "xxxxxxxxxx", "url": "https://webhook.com/xxxxxxxxxxx" } Parameters: - name: (string) A unique name for the webhook. - chainIds: (array of strings) Specifies the blockchain networks to listen to (e.g., "evm:1" for Ethereum mainnet, "evm:56" for BSC). - events: (array of strings) Types of events to receive (e.g., "trace", "log", "transaction", "block", "swap"). - apiKey: (string) Your Mobula API key, required for authentication. - url: (string) The callback URL where the event data will be sent. - filters: (object, optional) Allows for advanced filtering of events. See [details here](/indexing-stream/stream/filters). ``` -------------------------------- ### Install Mobula SDK Source: https://github.com/mobulafi/mobula-api-docs/blob/main/sdk/introduction.mdx Installs the Mobula SDK package using npm. This is the first step to integrate the SDK into your Node.js project. ```bash npm install mobula-sdk ``` -------------------------------- ### Delete Webhook (TypeScript) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/webhook/getting-started.mdx Example of how to delete an existing webhook using the Mobula API with a DELETE request. This requires the webhook's unique ID to be appended to the API endpoint URL. ```typescript const url = 'https://production-stream.mobula.io/api/1/webhooks'; const webhook_id = 'your_webhook_id'; // Replace with the actual webhook ID await fetch(url + `/${webhook_id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', }, }); // Expected successful response: // { // "message": "Webhook deleted successfully" // } ``` -------------------------------- ### Start Mintlify Development Server Source: https://github.com/mobulafi/mobula-api-docs/blob/main/README.md Starts the local development server for Mintlify. Run this command at the root of your documentation project to preview changes. ```shell mintlify dev ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/mobulafi/mobula-api-docs/blob/main/README.md Installs the Mintlify Command Line Interface globally using npm. This is required to preview documentation changes locally. ```shell npm i -g mintlify ``` -------------------------------- ### Re-install Mintlify Dependencies Source: https://github.com/mobulafi/mobula-api-docs/blob/main/README.md Re-installs project dependencies for Mintlify, often used to resolve issues when 'mintlify dev' is not running. ```shell mintlify install ``` -------------------------------- ### Delete Mobula Webhook with TypeScript Fetch API Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/webhook/getting-started.mdx Illustrates how to delete an existing Mobula webhook using the TypeScript `fetch` API. The example shows a DELETE request to the webhook endpoint, appending the `webhook_id` to the URL. Proper headers are included. ```typescript await fetch(url + `/${webhook_id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', }, }); ``` -------------------------------- ### Example API Response for Market History Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-historical-price-of-any-crypto.mdx An example of the JSON response structure returned by the Mobula API when requesting market history data. ```json { "data": { "price_history": [ [1624623325000, 1.113340820039224e-9], [1624626986000, 2.2957561345049817e-10], [1683309600000, 1.7181969777003686e-7] ] } } ``` -------------------------------- ### Initialize SDK and Fetch Wallet Transactions Source: https://github.com/mobulafi/mobula-api-docs/blob/main/sdk/introduction.mdx Demonstrates how to initialize the Mobula SDK with an API key and fetch wallet transactions. It shows an asynchronous function that makes a call to `fetchWalletTransactions` and checks the response status code. ```typescript async function run() { const sdk = new Mobula({ apiKeyAuth: "", }); const res = await sdk.fetchWalletTransactions({ blockchains: "56,Ethereum", wallet: "0xd99cB89A20822B0448936DF4f36803778CA5a003", }); if (res.statusCode == 200) { // handle response } } run(); ``` -------------------------------- ### Market Data Query Example Source: https://github.com/mobulafi/mobula-api-docs/blob/main/rest-api-reference/endpoint/market-multi-history.mdx An example JSON payload demonstrating how to query historical market data for multiple assets and blockchains. ```json { "assets": "Bitcoin,0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0,Hedera,0x23d29d30e35c5e8d321e1dc9a8a61bfd846d4c5c", "blockchains": "1,137" } ``` -------------------------------- ### Run and Deploy Bot Commands Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-token-prices-on-discord.mdx Commands for running the bot locally and deploying it to a hosting service like Heroku. Includes starting the Node.js script and configuring the deployment environment with a Procfile. ```bash # Run locally: node bot.js # Deploy to Heroku (example): # Ensure you have Heroku CLI installed and logged in # git push heroku master # heroku ps:scale web=0 worker=1 # Ensure a Procfile exists with: worker: node bot.js ``` -------------------------------- ### Market Data Query Example Source: https://github.com/mobulafi/mobula-api-docs/blob/main/rest-api-reference/endpoint/market-multi-data.mdx An example JSON payload demonstrating how to structure a request to the /market/multi-data endpoint. It specifies assets by their names and contract addresses, along with their corresponding blockchain IDs. ```JSON { "assets": "Bitcoin,0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0,Hedera,0x23d29d30e35c5e8d321e1dc9a8a61bfd846d4c5c", "blockchains": "1,137" } ``` -------------------------------- ### Fetch Crypto Price with Axios Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-any-crypto-price.mdx Shows how to fetch market data using the Axios HTTP client in TypeScript. This example makes a GET request to the Mobula API and includes basic error handling. ```typescript import axios from "axios"; axios.get('https://production-api.mobula.io/api/1/market/data?asset=Bitcoin') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) ``` -------------------------------- ### Trending Asset Example Source: https://github.com/mobulafi/mobula-api-docs/blob/main/rest-api-reference/endpoint/metadata-trendings.mdx An example JSON object representing a trending asset, including its identifier, name, symbol, contract details, logo, calculated trending score, platform rankings, and 24-hour price change. ```json { "id": 100005597, "name": "Hedera", "symbol": "HBAR", "contracts": [ { "address": "0x0000000000000000000000000000000000163b5a", "blockchain": "Hedera", "decimals": 8 } ], "logo": "https://metacore.mobula.io/66cb844bf3f59d5593f48ef2954b8a439455a629c23d00faf38813820bac2119.png", "trending_score": 25.4, "platforms": [ { "name": "CoinMarketCap", "rank": 1, "weight": 1 }, { "name": "CoinGecko", "rank": 3, "weight": 0.8 } ], "price_change_24h": -6.780622, "pair": "0xc5b707348da504e9be1bd4e21525459830e7b11d" } ``` -------------------------------- ### Fetch OHLCV Data using Axios Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-ohlcv-prices-for-crypto-tokens.mdx Retrieve historical OHLCV data using the Axios JavaScript library. This example demonstrates making a GET request to the Mobula API endpoint and handling the response or errors. ```javascript import axios from "axios"; axios.get('https://production-api.mobula.io/api/1/market/history?asset=base&blockchain=base') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) ``` -------------------------------- ### Mobula GraphQL API Endpoint Source: https://github.com/mobulafi/mobula-api-docs/blob/main/graphql-api-reference/introduction.mdx The primary endpoint for querying the Mobula GraphQL API. This is the base URL for all API requests. ```APIDOC Endpoint: https://production-gql.mobula.io/v1/graphql Description: This is the main GraphQL endpoint for accessing Mobula's data. Users can send queries and mutations to this URL. Related Resources: - GraphQL Schema: /graphql-api-reference/schema/assets - GraphQL Playground: https://production-gql.mobula.io/ ``` -------------------------------- ### Install The Graph CLI Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-matchain-the-graph.mdx Installs The Graph command-line interface globally using npm, which is required for subgraph development and deployment. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### API Response Structure for Wallet History Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-historical-balance-of-a-crypto-wallet.mdx Example of the JSON response structure returned by the Mobula API for historical wallet balance queries. ```json { "data": { "wallet": [ "0x77a89c51f106d6cd547542a3a83fe73cb4459135" ], "balance_usd": 241.16725574204617, "balance_history": [ [1650788304000, 0], [1650788305000, 0], [1650874705000, 40.94737444508439], [1651940430000, 47.36438419453997] ] } } ``` -------------------------------- ### Install Python Libraries Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/build-telegram-buy-bot.mdx Installs the necessary Python libraries, `websocket-client` for WebSocket communication and `python-telegram-bot` for interacting with the Telegram Bot API, required for the monitoring script. ```bash pip install websocket-client pip install python-telegram-bot ``` -------------------------------- ### Setup Chart Component with TradingView Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/setup-trading-view-chart-with-real-time-crypto-price.mdx This TypeScript component sets up the TradingView charting library. It requires the library files to be hosted locally and configures the widget with datafeed, symbol, interval, theme, and disabled features. It handles widget initialization and cleanup. ```typescript import React, { useRef, useEffect } from "react"; import { useTheme } from "next-themes"; import { IChartingLibraryWidget, ResolutionString, Timezone } from "../public/static/charting_library/charting_library"; // Assuming Asset and ChartBoxProps are defined elsewhere // import { Asset, ChartBoxProps } from "./types"; // import { Datafeed } from "./datafeed"; // import { overrides } from "./theme"; // Placeholder types for compilation type Asset = { symbol: string; name: string; price: number; contracts: string[]; blockchains: string[]; }; type ChartBoxProps = { baseAsset: Asset | null; mobile?: boolean; custom_css_url?: string; extraCss?: string; }; // Placeholder for Datafeed and overrides functions const Datafeed = (baseAsset: Asset) => ({ /* ... datafeed methods ... */ }); const overrides = (isWhiteMode: boolean) => ({}); const ChartBox = ({ baseAsset, mobile = false, custom_css_url = "../themed.css", extraCss }: ChartBoxProps) => { const ref = useRef(null); const { resolvedTheme } = useTheme(); const isWhiteMode = resolvedTheme === "light"; useEffect(() => { if (!baseAsset) return () => {}; let freshWidget: IChartingLibraryWidget | null = null; import("../public/static/charting_library").then( ({ widget: Widget }) => { if (!ref.current) return; freshWidget = new Widget({ // Datafeed datafeed: Datafeed(baseAsset), symbol: baseAsset?.symbol + "/USD", interval: "60" as ResolutionString, // Settings container: ref.current, container_id: ref.current.id, library_path: "/static/charting_library/", // UI & Behavior locale: "en", fullscreen: false, disabled_features: [ "header_saveload", "header_symbol_search", ...(mobile ? ["left_toolbar"] : []), ], timezone: Intl.DateTimeFormat().resolvedOptions() .timeZone as Timezone, autosize: true, // Theme theme: isWhiteMode ? "Light" : "Dark", // TO DO: Overrites don't work rn. overrides: overrides(isWhiteMode), custom_css_url, }); } ); return () => { freshWidget?.remove(); }; }, [baseAsset, custom_css_url, mobile]); return (
); }; export default ChartBox; ``` -------------------------------- ### Webhook: Delete Success Response (JSON) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/getting-started.mdx The expected JSON response upon successful deletion of a webhook. It confirms the operation with a simple success message. ```json { "message": "Stream deleted successfully" } ``` -------------------------------- ### Install The Graph CLI Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-gnosis-xdai-the-graph.mdx Install The Graph Command Line Interface globally using npm. This tool is essential for managing and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Mobula Webhook Deletion Success JSON Response Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/webhook/getting-started.mdx Shows the expected JSON response body returned by the Mobula API upon successful deletion of a webhook, confirming the operation. ```json { "message": "Webhook deleted successfully" } ``` -------------------------------- ### Install The Graph CLI Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-ethereum-the-graph.mdx Installs The Graph Command Line Interface globally using npm. This tool is essential for managing and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Install The Graph CLI (Bash) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-bsc-the-graph.mdx Installs The Graph Command Line Interface globally using npm. This tool is essential for managing and deploying subgraphs. Requires Node.js and npm to be installed. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Clone Subgraph Template Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-ethereum-the-graph.mdx Clones the Uniswap V2 subgraph template for Ethereum. This serves as a starting point for creating your own Ethereum subgraph. Ensure you have Git installed. ```bash git clone https://github.com/MobulaFi/univ2-subgraph-ethereum ``` -------------------------------- ### Webhook: Delete Webhook (TypeScript) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/stream/getting-started.mdx Shows how to delete an existing webhook subscription by sending a DELETE request to the Mobula API endpoint, using the webhook's unique identifier. ```typescript await fetch(url + `/${webhook_id}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json', }, }); ``` -------------------------------- ### Create Subgraph on Node Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-matchain-the-graph.mdx Initializes a subgraph on the specified Matchain node, preparing the deployment environment. ```bash graph create --node https://subgraph.mobula.io:8020 ``` -------------------------------- ### SQL Query for Wallet Transactions Source: https://github.com/mobulafi/mobula-api-docs/blob/main/rest-api-reference/endpoint/warehouse/wallet-transactions-count.mdx Example SQL query to fetch transactions from the warehouse.transactions table. It filters records where either the 'from' or 'to' column matches the provided wallet address. ```sql SELECT * FROM postgres.`warehouse.transactions` WHERE from = {walletAddress:String} or to = {walletAddress:String} ``` -------------------------------- ### Fetch Crypto Price with cURL Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-any-crypto-price.mdx Demonstrates how to fetch market data for a specific asset using a cURL command. This example targets the `/api/1/market/data` endpoint and requires an API key for production environments. ```bash curl --location --request GET 'https://production-api.mobula.io/api/1/market/data?asset=Bitcoin' \ --header 'Content-Type: application/json' \ --header 'Authorization: YOUR_API_KEY_HERE' ``` -------------------------------- ### Install The Graph CLI Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-celo-the-graph.mdx Installs The Graph Command Line Interface globally. This tool is essential for managing and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Install Graph CLI (Bash) Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-fantom-the-graph.mdx Installs The Graph Command Line Interface globally using npm. This tool is essential for managing and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Install The Graph CLI Source: https://github.com/mobulafi/mobula-api-docs/blob/main/indexing-stream/guide/deploy-subgraph-bahamut-the-graph.mdx Installs The Graph Command Line Interface globally using npm. This tool is essential for managing and deploying subgraphs. ```bash npm install -g @graphprotocol/graph-cli ``` -------------------------------- ### Fetch Market Data with Axios Source: https://github.com/mobulafi/mobula-api-docs/blob/main/guides/query-latest-created-pairs.mdx Shows how to use the Axios library in JavaScript to call the Mobula API and retrieve market data. This example makes a GET request to the market query endpoint and logs the response or any errors encountered. ```javascript import axios from "axios"; axios.get('https://production-api.mobula.io/api/1/market/query/token?sortBy=listed_at&sortOrder=desc&blockchain=Base') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) ```