How to retrieve complete NFT metadata from a specific collection on NEAR blockchain?

I’m working on a backend project where I need to collect and store metadata for all tokens in a particular NFT collection on the NEAR protocol. I’m wondering what would be the most efficient approach to accomplish this task.

There are several methods I’m considering but I’m not sure which one works best:

  • Using existing tools or APIs available in the NEAR ecosystem
  • Making direct calls to the smart contract to fetch metadata information
  • Setting up an indexer service to capture data from blockchain events

My goal is to populate a database with this NFT metadata information for my application. What approach would you recommend for this use case? Are there any performance considerations I should keep in mind when dealing with large collections?

Wait, which collection are you trying to index? Some older NFT contracts on NEAR have quirky implementations that’ll affect your strategy.

What’s the scale here - a few hundred tokens or something massive like 10k+ pieces? That really changes the approach.

The Graph Protocol has NEAR indexing capabilities now, but I haven’t tested it for NFT metadata specifically. Anyone here tried that route? Could save you from building your own indexer.

Also @StrummingMelody - is this real-time metadata updates or a one-time sync? If tokens get transferred or metadata updates on-chain, you’ll need to handle those changes in your db.

Quick heads up - some collections store metadata on IPFS while others put everything in contract storage. Check how your target collection handles that before diving into implementation.

I’ve tackled this recently and mixing approaches works best in production. NEAR Lake indexer was rock solid for my project, especially with collections holding thousands of tokens. Don’t rely on direct contract calls alone - they’ll timeout on bigger collections because of gas limits. Use NEAR API JS with batch processing instead. Query 50-100 tokens at a time so you don’t overwhelm the RPC. Here’s what blindsided me: NFT contracts on NEAR have wildly inconsistent metadata standards. Some stick to NEP-171, others do their own thing. Build your parsing logic to handle different formats or you’ll get burned. For database storage, set up a queue system for the async blockchain queries. Your app won’t freeze waiting for responses, and you can handle failed requests properly.

honestly, just use near-api-js with the view_call method to hit nft_tokens_for_owner and nft_token functions. way simpler than setting up indexers unless you need real-time data. i’d skip direct rpc contract calls - the js library handles retries and connection pooling better. just watch the rate limits or you’ll get blocked.