![](/_next/image?url=https%3A%2F%2Fblog.indexer.xyz%2Fcontent%2Fimages%2F2023%2F04%2FScreenshot-2023-04-04-at-5.58.46-PM.png&w=3840&q=75)
Hello Indexer.xyz users!
We are beyond excited to announce the launch of our upgraded API, Indexer.xyz API v2! Our team has been tirelessly working to improve the API experience, making it even easier to use while adding new features that enable you to access even more NFT data.
![](https://blog.indexer.xyz/content/images/2023/04/Screenshot-2023-04-04-at-5.42.16-PM.png)
What's New in API v2?
Simplified Schema and Relationships
We have revamped the schema and relationships in the v2 API, making it easier to understand and navigate. By improving the naming conventions for entities and fields, you can quickly access the information you need without getting lost in the complexity.
Here's a quick comparison of the v1 and v2 APIs:
v1 API Entities:
- action: This entity stores information about contract events such as transfers, mints, listings, sales, bids, and more.
- bid_state: Holds data related to bids, including bid price, buyer, seller, bid type, bid contract, nonce, and status.
- collection: Represents an NFT collection and contains information such as title, description, collection size, cover image, floor price, volume, and related metadata.
- collection_attribute: Contains collection-specific attributes such as the attribute type and value.
- collection_creator: Stores information about the creator of a collection.
- commission: Holds commission data, including commission percentages, commission type, and related contract information.
- nft_meta: Stores metadata about individual NFTs, including asset name, token ID, image URL, properties, rarity, ranking, and associated smart contract ID.
- nft_meta_attribute: Contains NFT-specific attributes such as the attribute type, value, and rarity.
- nft_state: Stores the state data of an NFT, including whether it is listed, staked, or burned.
- nft_state_list: Holds information about the NFT listing state, including list price, list seller, and list contract.
- smart_contract: Contains data about smart contracts, including chain ID, contract key, name, specifications, and associated collections and NFTs.
- smart_contract_function: Stores information about the smart contract functions, such as the function name, input parameters, and output parameters.
v2 API Entities:
- actions: Similar to the v1 "action" entity, it stores contract event information such as transfers, mints, listings, sales, bids, and more.
- attributes: Contains NFT attribute data like rarity, type, value, and their relationship to the NFT.
- bids: Holds bid information such as price, bidder, receiver, and related contracts and NFTs.
- collections: Represents an NFT collection and features improved field names and structure, including title, description, supply, cover URL, floor price, volume, and related contracts and NFTs.
- commissions: Stores commission data such as market fee, artist royalty, and associated contract ID.
- contracts: Contains information about smart contracts like type, name, key, and custodial contract ID.
- crypto_rates: Provides current conversion rates of fiat currencies to cryptocurrencies.
- listings: Holds listing data such as price, seller, listed status, and relationships to commissions, contracts, and NFTs.
- nfts: Stores NFT data with improved fields like token ID, name, media URL, media type, owner, and relationships to actions, attributes, bids, collections, contracts, and listings.
- collections_search: A fuzzy search
New Fields
The v2 API introduces several new fields that provide you with even more information about NFTs and their associated data. Some of these new fields include:
- Media types for NFTs (jpeg, mp4, etc.)
- Collection fuzzy text search query
- Commission data (e.g. Market Fee, Artist Royalty, etc.)
- Crypto_rates for current conversion rates of fiat currencies to cryptocurrencies
![New Fields in API v2](https://blog.indexer.xyz/content/images/2023/04/Screenshot-2023-04-04-at-5.52.40-PM.png)
Improved Documentation and GraphQL Explorer
Our updated documentation makes it easier than ever to learn how to use the API and build queries. Plus, the GraphQL Explorer allows you to interactively explore the schema, view available entities and fields, and build your queries by selecting the fields you need.
Example Queries and Use Cases
To demonstrate the difference between v1 and v2 APIs, let's look at some example queries:
Example 1: Fetching Basic Collection Information
v1 API Query:
query fetchCollectionInfo($slug: String!) {
near {
collection(where: {slug: {_eq: $slug}}) {
id
slug
title
cover_image
collection_size
description
floor
volume
}
}
}
v2 API Query:
query fetchCollectionInfo($slug: String!) {
near {
collections(where: {slug: {_eq: $slug}}) {
id
slug
title
cover_url
supply
description
floor
volume
}
}
}
Example 2: Fetching NFTs and Their Attributes in a Collection
v1 API Query:
query fetchNftsByCollection($where: nft_meta_bool_exp!) {
near {
nft_meta(where: $where) {
id
token_id
name
image
collection {
title
}
nft_meta_attributes {
attribute_type
attribute_value
attribute_rarity
}
}
}
}
v2 API Query:
query fetchNftsByCollection($where: nfts_bool_exp!) {
near {
nfts(where: $where) {
id
token_id
name
media_url
media_type
collection {
title
}
attributes {
type
value
rarity
}
}
}
}
In these example queries, the v2 API provides more detailed information about the NFT media and attributes.
Get Started with Indexer.xyz API v2 Today!
- Ready to dive into the new API? Here's how to get started:
- Request an API key here.
- Check out the API documentation and GraphQL explorer at https://indexer.xyz/api-explorer.
- Explore our cookbooks and example queries to get a head start on using the new features and fields.
Need Help?
We're here to support you! If you have any questions or run into any issues, please feel free to reach out to our support team or join our community discord.
We're confident that the Indexer.xyz API v2 will provide you with a better and more streamlined experience, enabling you to build even more powerful and innovative NFT projects. We can't wait to see what you create with the new API!
Happy building!