Graph Node Requests
Last updated
Last updated
For this section, you will need:
A user's Theta Network wallet address, see the previous page on how to obtain this
A HTTP request library installed, such as
The smart contract address(es) of your event
We have a for you to send requests directly before integrating this into your platform.
To start, try sending the following request using the playground:
The above request searches all of our ticket tokens where the owner address is 0x059377c014cfc12dd2612ebfe9cfd1a6fc1a8883
and the ticket smart contract address is either 0x0478578c5e906afeb1bdbbf358929affbf1575c8
or 0xaa7fc9c591eab1f80e7e29a1f88ee144c6a3694f
.
Let's try something more advanced now, and try to find all of the past transactions of a ticket. Try sending the following request to the playground:
This searches the database for all transfers that had taken place for the ticket with smart contract address 0x0478578c5e906afeb1bdbbf358929affbf1575c8
and token ID 65
. It returns the address from which it was transferred, the address it was transferred to, as well as the current owner and token ID of the ticket.
Next, let's try the following query:
This query checks the daily data collated about the platform, and finds the first 10 entries corresponding to a date greater than a timestamp of 1635752657
, ordered by descending date. It returns the date of the entry, the number of daily transactions, the total and daily volume of TFUEL transacted, as well as the event count.
Now, with your query crafted, you can query the database programmatically using a HTTP POST request rather than doing it manually in the playground. This also allows you to set any variables within your query.
POST
https://graphql.tkets.io/subgraphs/name/tkets-core/graphql/
Submits a query to the GraphQL database with the specified variables, and returns a JSON response with the result objects
query*
String
Your query (as above), in a plaintext string
variables
JSON
(Optional) Variables within the query that can be defined
Make sure to use a POST method to submit the request. Mutations are not allowed because of restrictions on the graph node, and therefore the database is read only.
For protected endpoints that require only users who are authenticated (for example, an endpoint that allows users who hold NFTs to change their name on your platform or make a vote), you will need to check on both your frontend and backend if they are indeed holders of your NFT.
For example, you may use the following code to submit a request:
By now, you should have a basic understanding of how the query system works, and can construct your own queries to suit the information you need. You can refer to the Graph Node API guide for a full schema of the data indexed by the Graph node, or also read more in the for more information about the query system.
This can be done with the GraphQL queries on this page, as well as a signature verification on your backend. See for more details