We announced Ordhook in September, a client indexer for ordinals data. Reliable indexers are particularly important for metaprotocols like ordinals where standards, such as what counts as an inscription and what does not, are changing seemingly every day.
Ordhook is a powerful tool that gives developers an easier way to access raw ordinals inscription data and customize what information they want to consume—in order to iterate, splice, dice and build. In fact, Ordhook powers all of Hiro’s ordinals tooling, including our Ordinals Explorer and Ordinals API.
Since you can customize what data you ingest, ordinals offers a nimble solution to power your app while also being reliable: ordhook is reorg-aware and will automatically roll back any invalid transactions in your database in the event of a fork or reorg.
Ordhook is a powerful tool that gives you an easier way to access raw ordinals inscription data and customize what information you want to consume.
If you’re a visual learner, watch a recording of our recent webinar, where we walk through some of these steps, beginning at 12:50:
Set Up Ordhook
Before you begin, you’ll need to set up Ordhook. This involves two main steps:
- Set up a Bitcoin node: Ordinals are built on Bitcoin, and you’ll need to run a node in order for Ordhook to pull new inscription data from the Bitcoin blockchain. For more detailed instructions, start here.
- Connect Ordhook to your Bitcoin node: This will allow the Ordhook indexer to index (sorry) the data from your Bitcoin node and push that data to a database that is application-friendly.
Once the Bitcoin node and Ordhook index are synced, the fun can begin. There are two main commands you can use:
- <code-rich-text>scan<code-rich-text> allows you to scan any section of the blockchain by block height to then return a given type of information, in this case, BRC-20 inscription data.
- <code-rich-text>service<code-rich-text> allows you to run ordhook as a service for running an ongoing observer.
Now that Ordhook is configured, and your Bitcoin node is set up, try out the following Ordhook command:
Ordhook will return any inscription data it finds between whichever two blocks you indicate. In this instance, the block height above corresponds to the first two inscriptions ever made.
Once you’ve run the <code-rich-text>scan<code-rich-text> command, you can inspect the data manually in your terminal, or deliver the payload to an API or to any observer. To do the latter, you will use the HTTP post method.
Ordhook will return any inscription data it finds between whichever two blocks you indicate.
One of the powerful things you can do with Ordhook is quick iterative development if you’re interested in building metaprotocols with ordinals. Ordhook is powerful enough to enable custom views of raw blockchain data, whether you want to index particular blocks or particular subsets of inscriptions.
Let’s look at a specific example. Run the following Ordhook command:
With this command, you can push an entire block’s raw data to the display in your web server. However, there’s a lot of information to parse, and you might only want specific types of data, say only data related to BRC-20 tokens.
From there, you can use this refined data to build your own database (and then build your own custom API or service around it).
Ordinals API vs Ordhook
We also offer the Ordinals API, which is another way for you to pull inscription data into your app. But when should you use Ordhook versus the Ordinals API? We thought you’d never ask.
When to Use the Ordinals API
The Ordinals API delivers reliable data payloads to web applications and can handle high volumes of traffic. Leveraging an API is great for devs who value performance and low latency. In turn, you hand off data maintenance and indexing to a 3rd party, such as Hiro, to deliver that at scale for you.
View our Ordinals API docs here.
When to Use Ordhook
If you’re a fairly advanced developer, Ordhook gives you more power to customize how you pull and work with blockchain data. You might want to create your own index for a specific metaprotocol (e.g. BRC-20 or Bitmap).
An indexer is helpful if you want custom or finely tailored slices of blockchain data to work with (such as a unique subset of inscriptions). It’s also great if you want to be fully sovereign and not rely on any 3rd party for some hosted service. However, using an indexer yourself also has challenges: it won’t be easy to deliver data to a lot of users through a web app or to maintain constant uptime under high traffic scenarios.
View Ordhook docs here.
Now that you’ve learned some of the basics of building with Ordhook, dive into its full potential in our docs.