Chainquery SQL API

Hi!
Can you give me example of chainquery api for slq should look?
Can I was reading documentation https://lbryio.github.io/chainquery/#!/QueryApi#sQL%20Query
and I still have errors like
{
“success”: false,
“error”: “Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘claim’ at line 1”,
“data”: null
}

http://api.XXXXX:6300/api/sql?query=claim&values=id;

Let me know what I did wrong :slight_smile:

1 Like

An example API call would be

http://<host:port>/api/sql?query=SELECT * FROM claim WHERE name ="awakeningshortfilm"

https://chainquery.lbry.io/api/sql?query=SELECT%20*%20FROM%20claim%20WHERE%20name%20="awakeningshortfilm"

We also have an exposed instance as well where you can leverage this api. It is limited, so if you want to make a lot of calls you would want to stand up your own instance.

Also if you want to know the schema to perform queries against use https://github.com/lbryio/chainquery/blob/master/db/chainquery_schema.sql

2 Likes

Thanks!
http://XXXXXXXX.XXX:6300/api/sql?query=SELECT%20*%20FROM%20claim%20WHERE%20content_type%20=“audio/mpeg”

Worked for me but what if I want selected data not full?
Like for example:
author
claim_id
content_type
title
:slight_smile:

then you select only the data you want.

SELECT author, claim_id, content_type, title FROM ............

find more here: https://www.w3schools.com/sql/sql_select.asp

1 Like

This article may help also: https://lbry.io/news/what-is-chainquery

We’ve noted that we need a better explainer resource on lbry.tech too!