MySQL Counterparty DB

I know this is much to ask for - but is it possible to parse the entire Counterparty DB to MySQL?

Counterparty is indeed a database, right? And for every block it changes slightly (if any CP txs).

What I had in mind is web developers. If they can have a MySQL copy of the DB and it can easily be updated with new TXs through a public API (no need to run own CP server) … then it would be very convenient to develop for Counterparty.

what do you think @brighton36 ?

+1 . This gets my vote and was somewhat discussed previously on github.
However, there is the issue of complexity and time as the core code has to be rewritten.


for the development you could just use these public development servers:
counterpartyd can be easily queried from your favourite web environment.

Having a mysqldump for download or a public available mysql database connection might not be practicable.
At the moment I am working on a project where we are using the dev servers to fetch the cp transactions/orders initially, store them in a sqlitedb locally and then just fetch the info from the most recent block to stay up to date.

But I agree, it would be nice to have an officially supported open API for web developers (aka a public available counterpartyd). For now, you can probably just use the dev servers.

So Counterparty stores its data in a sqlite database by default, which is very easy to convert to mysql , or query directly. I believe that this is what blockscan does (query the database direct), and it probably wouldn’t be too hard to change the code to work directly off mysql.

As for updating this data directly - that wouldn’t work for many reasons. The value of Counterparty is the network effect, and changes made to this database outside of the blockchain would then render the database out of consensus with the network. Counterparty is primarily an index of bitcoin, and not a persistence store in any traditional sense.

The API is pretty straightforward though, you don’t actually have to use it through counterpartyd. I believe Joe Looney’s library does quite a bit without a counterparty server…

1 Like

Brighton, thanks for feedback.

More specific, what I would like

  1. More PHP examples for queries at Coindaddy.

  2. I don’t want to leech off Coindaddy server. Therefore wonder if maybe possible just to send one request for new transactions every ten minutes, then on my server I rebuild the CP database copy from the new txs.

  3. Sqlite is unknown to me and MySQL is the standard. Thus MySQL would be easier for (non-professional) developers. If Sqlite is very simple though, maybe no need, can learn from examples.

If you’re going to be reliant on someone else’s server parse each block anyway, why not just use the APIs at or ?

This may interest you.