[//]: # { "title": "@mintbase-js/data", "order": "2" }
@mintbase-js/data
Built-in methods to help fetch data from our indexer. These methods aim to make it as easy as possible to get blockchain data.
If the data you want to get is more specific also check out our GraphQL schema instead.
Source Configuration
You can set network and in some cases default contract configuration using the SDK's mbjs.config
method. Read about config global variables on: Config SDK method
Usage Options
The default export methods return a wrapped result object with error and data properties. For example const { error, data } = myApiMethod()
will provide any network errors inside of error in the event of failure, and the expected result in data on success.
If you prefer to catch errors, you can import the method from @mintbase-js/data/lib/unwrap
instead. e.g. import { ownedTokens } from '@mintbase-js/data/lib/unwrap
which will re-throw in the event of an error.
use our GraphQL Fetch Method
check our GraphQl Fetch Method
ex:
import { QUERIES, fetchGraphQl } from '@mintbase-js/data'
import { mbjs } from '@mintbase-js/sdk'
const myFetchMethod = ({showOnlyListed, pagination, network}) => {
const { data, error } = await fetchGraphQl<MyResultType>({
query: QUERIES.storeNftsQuery,
variables: {
condition: {
nft_contract_id: { _in: mbjs.keys.contractAddress },
...(showOnlyListed && { price: { _is_null: false } }),
},
limit: pagination?.limit ?? 12,
offset: pagination?.offset ?? 0,
},
...(network && { network:network }),
});
}
Use our Queries on your own GraphQL Service Implementation
check our Queries here
API Methods
method name | params | description |
---|
ownedNftsByStore | ownerId: string,contractAddress: string, pagination: {limit: number, offset:number} | get all nfts from a single store |
ownedTokens | ownerId: string,{limit: number, offset:number} | get all tokens/nfts from a owner |
tokenById | tokenId: string, contractAddress: string | get token data by id of certain contract |
tokenListingCountsByMetaId | metadataId: string | get token listings from metadata id |
tokensByStatus | metadataId: string, ownedBy: string | get token by status on metadataId, and owner |
tokenOwner | tokenId: string, contractAddress: string | get token owner by token id and certain contract |
tokenProvenance | tokenId: string, contractAddress: string, pagination?: {limit: number, offset:number} | get token provenance by token id and certain contract |
tokenOwnersByMetadataId | metadataId: string, pagination?: {limit: number, offset:number} | get token owners by metadata id |
ownedStores | ownerId: string | get stores owned by owner id |
nearPrice | - | get near price in usd |
checkStoreName | name: string | check if store name already exists |
storeData | `contractAddress: string | string[]` |
storeNfts | `contractAddress: string | string[], showOnlyListed?: boolean, pagination?: {limit: number, offset:number}` |
metadataByMetadataId | metadataId: string | get metadata by metadataId |
tokenByAttributes | contractId: string, filters: AttributesFilters | get tokens of a certain contract and filters |
attributesByContract | contractId: string | get attributes of a certain contract |
attributeRarity | contractId: string, attributeType: string, attributeValue: string | get attribute rarity of a certain contract, attribute type and attribute value |
While we will continue to provide public and our new mb_views schema objects, we will also begin to introduce helper methods here that can be used to query data without having to write any graphql.
For now, reference our existing graphql docs and be sure to check back here soon for updates concerning our data layer API.