# 0xAPI reference Source: https://docs.ormilabs.com/api-reference/0xAPI/overview ## Introduction 0xAPI gives you instant access to structured, decoded blockchain data - both real-time and historical. Whether you’re building wallets, analytics dashboards, or DeFi apps, 0xAPI eliminates the need to run your own indexers with one unified, high-performance API. ## Components of 0xAPI
Blocks

An API for querying blocks, and searching for block number.

{" "}
Events

An API for fetching smart contract event logs.

{" "}
NFT

An API for managing and searching NFT contract, metadata, and token.

Wallet

An API for fetching a complete viow of a wallet across tokens, and NFTs.

{" "}
Tokens

An API for searching token metadata, token holders, wallet balances, and more.

{" "}
Transactions

An API for searching transaction hash, transaction by account, and more.

# CLI reference Source: https://docs.ormilabs.com/api-reference/0xGraph/cli/reference A detailed list of commands for The Graph CLI, including their purposes, use cases, and examples. ## Initializing a subgraph ``` graph init ``` ### Purpose Creates a new Subgraph project using an example template or an existing smart contract. ### Use case * Use this command when starting a new Subgraph project. * It sets up the necessary folder structure, configuration files `subgraph.yaml`, and example code. * You can specify a contract address and network to scaffold a Subgraph tailored to a specific smart contract. ### Example ```bash theme={null} graph init --from-contract --network mainnet ``` ## Generating code from subgraph files ``` graph codegen ``` ### Purpose Generates AssemblyScript types for smart contract ABIs and the Subgraph schema. ### Use case * Use this command after making changes to your `schema.graphql` file or when adding/updating smart contract ABIs. * It creates type-safe classes that make it easier to interact with blockchain data in your mappings. ## Build your subgraph ``` graph build ``` ### Purpose Compiles the Subgraph to WebAssembly (WASM), preparing it for deployment. ### Use Case * Run this command after completing your mappings and configuration. * It ensures your Subgraph is ready for deployment by converting it into the WASM format required by 0xGraph. ## Deploy your subgraph ``` graph deploy ``` ### Purpose Deploys the compiled Subgraph to the 0xGraph hosting service. ### Use case * After building your Subgraph, use this command to upload and activate it on 0xGraph. * Specify the deployment target (e.g., staging or production) and the Subgraph name. ### Example ```bash theme={null} graph deploy --node https://api.subgraph.ormilabs.com/deploy --ipfs https://api.subgraph.ormilabs.com/ipfs --deploy-key ``` ## Run the subgraph locally ``` graph local ``` ### Purpose Runs a local test environment (e.g., using Ganache or Hardhat) to test the Subgraph with simulated blockchain data. ### Use Case * Use this command when developing and testing your Subgraph locally. * It allows you to simulate blockchain events and validate mappings. * Ideal for testing without deploying to a live environment. ## Executes unit tests ``` graph test ``` ### Purpose Downloads and runs the Matchstick Rust binary to execute unit tests for a Subgraph. ### Use Case * Use this command to write and run unit tests for your mappings and ensure that your Subgraph logic works correctly. * Matchstick is a testing framework built specifically for The Graph. ## Add new data source ``` graph add ``` ### Purpose Adds a new data source to your Subgraph’s manifest file (subgraph.yaml) and updates relevant files such as schema.graphql, ABIs, and mappings. ### Use case * Use this command when adding additional smart contracts or data sources to your Subgraph. * It automates the process of updating your Subgraph configuration and related files. ### Example ```bash theme={null} graph add --from-contract ``` Ensure you have the latest version of The Graph CLI installed to avoid potential issues with deprecated or updated commands. # 0xGraph API reference Source: https://docs.ormilabs.com/api-reference/0xGraph/overview ## Introduction 0xGraph is a next-generation hosted Subgraph solution, fully compatible with The Graph and built for real-time, high-throughput blockchain applications. It lets developers index, and query smart contract data at sub-second latency - without managing infrastructure. ## References # Get Wallet Balances Source: https://docs.ormilabs.com/api-reference/0xapi/tokens/get-wallet-balances open-api/0xapi.yaml get /v2/{chain_name}/wallets/{wallet_address}/balances Retrieves a paginated list of token balances for a specific wallet address. This can include both fungible tokens like ERC-20 tokens and native currency and non-fungible tokens like ERC-721 and ERC-1155. For non-fungible tokens, each token is grouped under its collection contract address. # Get Transactions By Wallet Source: https://docs.ormilabs.com/api-reference/0xapi/transactions/get-transactions-by-wallet open-api/0xapi.yaml get /v2/{chain_name}/wallets/{wallet_address}/transactions Retrieves a paginated list of all transactions associated with a specific wallet address. # Get Wallet Transaction Summary Source: https://docs.ormilabs.com/api-reference/0xapi/transactions/get-wallet-transaction-summary open-api/0xapi.yaml get /v2/{chain_name}/wallets/{wallet_address}/transactions/summary Provides a summary of a wallet's transaction history, including the total transaction count and details of the first and last transactions. # Get NFTs By Wallet Source: https://docs.ormilabs.com/api-reference/0xapi/wallet/get-nfts-by-wallet open-api/0xapi.yaml get /v2/{chain_name}/wallets/{wallet_address}/nfts Fetches a paginated list of all Non-Fungible Tokens (NFTs) currently owned by a specific wallet address. # Get Blocks Source: https://docs.ormilabs.com/api-reference/blocks/get-blocks open-api/0xapi.yaml get /v2/{chain_name}/blocks Retrieves a paginated list of the most recent blocks on the blockchain. # Lookup Block By Number Source: https://docs.ormilabs.com/api-reference/blocks/lookup-block-by-number open-api/0xapi.yaml get /v2/{chain_name}/blocks/{block_number} Retrieves the full details of a specific block, identified by its block number or the "latest" tag. # Lookup Block By Timestamp Source: https://docs.ormilabs.com/api-reference/blocks/lookup-block-by-timestamp open-api/0xapi.yaml get /v2/{chain_name}/blocks/by-timestamp/{timestamp} Finds and retrieves the details of the closest block to a given timestamp. The lookup can be directed to find the block immediately before or after the specified time. # Create tag Source: https://docs.ormilabs.com/api-reference/create-tag open-api/0xgraph.yaml post /public_api/v1/0xGraph/tags/create-tag Create a new tag for a subgraph version # Delete tag Source: https://docs.ormilabs.com/api-reference/delete-tag open-api/0xgraph.yaml post /public_api/v1/0xGraph/tags/delete-tag Delete an existing tag from a subgraph # Get Events Source: https://docs.ormilabs.com/api-reference/events/get-events open-api/0xapi.yaml get /v2/{chain_name}/events Fetches a paginated list of smart contract event logs. Can be filtered by contract address and event signatures (topic0). # Get NFT Collection Traits Source: https://docs.ormilabs.com/api-reference/nfts/get-nft-collection-traits open-api/0xapi.yaml get /v2/{chain_name}/collections/{collection_address}/traits Retrieves a list of all trait types and their values for a specific NFT collection. # Get NFTs By Collection Source: https://docs.ormilabs.com/api-reference/nfts/get-nfts-by-collection open-api/0xapi.yaml get /v2/{chain_name}/collections/{collection_address}/nfts Fetches a paginated list of all NFTs that belong to a specific collection contract address. # Lookup NFT By Token ID Source: https://docs.ormilabs.com/api-reference/nfts/lookup-nft-by-token-id open-api/0xapi.yaml get /v2/{chain_name}/collections/{collection_address}/nfts/{token_id} Retrieves detailed information about a specific NFT token within a collection, identified by its token ID. # API reference by product Source: https://docs.ormilabs.com/api-reference/overview