Quickstart
Quick introduction into the Artion GraphQL API usage.
You can use Artion GraphQL API to watch activity on yours tokens, to browse any tokens you are interested in or to get any other information from Artion.
This quickstart will guide you through first queries to the Artion GraphQL API. In the first example you will obtain status of auction running on given token, in the second example you will browse list of tokens, filtered and sorted by given fields.
Until you want to run you own Artion based marketplace, you don't need to worry about the API server setup - you can use our public API points:
https://artion-api-a.fantom.network/graphql
https://artion-api-b.fantom.network/graphql
Example 1: Auction Status
To check status of auction running on token 2937
(0xb79
in hexa) from collection 0x5dbc2a8b01b7e37dfd7850237a3330c9939d6457
, you can just send following GraphQL API query:
{
token(contract:"0x5dbc2a8b01b7e37dfd7850237a3330c9939d6457", tokenId:"0xb79") {
name # name of the token
auction {
created # when was the auction created
payToken # ERC-20 token used as the auction currency
reservePrice # the reserve price of the auction in WEI
lastBid # the amount of the last bid in WEI
lastBidder # the user who have placed the last bid
}
}
}
You will get result in format defined by the query:
{
"data": {
"token": {
"name": "Ancestral Uman 2937",
"auction": {
"created": "2021-10-09T10:16:02+02:00",
"payToken": "0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83",
"reservePrice": "0x61615021",
"lastBid": null,
"lastBidder": null
}
}
}
}
Example 2: Token Listing
To browse list of tokens you can use tokens()
function, which allows to filter, sort and paginate list of all tokens known to Artion.
Following query filters only tokens more expensive than 1 USD, in ascending order, while sorting by creation time and limiting amount of results to five. In other words, it will find 5 oldest tokens above 1 USD.
{
tokens(
filter: { priceMin: 1000000 }, # price above 1 USD (in 6 decimals fixed point)
sortBy: CREATED, sortDir: ASC, # sort oldest first
first: 5, # limit to only 5 results
) {
edges {
node {
name
contract
tokenId
created
}
}
pageInfo {
startCursor # cursor for obtaining the previous page
endCursor # cursor for obtaining the next page
hasPreviousPage
hasNextPage
}
}
}
This will produce output similar to:
{
"data": {
"tokens": {
"edges": [
{
"node": {
"name": "Bit Uman #34",
"contract": "0x8c2fcd5d857ee9aa19d1a27ae81ab1129385e3ac",
"tokenId": "0x22",
"created": "2021-05-23T16:34:15+02:00"
}
},
{
"node": {
"name": "Bit Uman #40",
"contract": "0x8c2fcd5d857ee9aa19d1a27ae81ab1129385e3ac",
"tokenId": "0x28",
"created": "2021-05-23T16:44:06+02:00"
}
},
{
"node": {
"name": "Bit Uman #50",
"contract": "0x8c2fcd5d857ee9aa19d1a27ae81ab1129385e3ac",
"tokenId": "0x32",
"created": "2021-05-23T16:59:37+02:00"
}
},
{
"node": {
"name": "Bit Uman #52",
"contract": "0x8c2fcd5d857ee9aa19d1a27ae81ab1129385e3ac",
"tokenId": "0x34",
"created": "2021-05-23T17:01:06+02:00"
}
},
{
"node": {
"name": "Bit Uman #54",
"contract": "0x8c2fcd5d857ee9aa19d1a27ae81ab1129385e3ac",
"tokenId": "0x36",
"created": "2021-05-23T17:06:09+02:00"
}
}
],
"pageInfo": {
"startCursor": "JQAAABJpbmRleAAvMA0LBwAAAAljcmVhdGVkAFjepZl5AQAAAA==",
"endCursor": "JQAAABJpbmRleAAM0LULBwAAAAljcmVhdGVkAOgSw5l5AQAAAA==",
"hasPreviousPage": false,
"hasNextPage": true
}
}
}
}
For more information about pagination - like how to get following five results - check GraphQL Schema Basics.
Sending the GraphQL request
To send a GraphQL request you can use specialized library like Apollo Client for JavaScript, or Graphene for Python.
However, you can also send the request manually. Check following example to load data from the API using plain JavaScript:
fetch('https://artion-api-a.fantom.network/graphql', {
method: 'POST',
body: JSON.stringify({
query:`
{
token(contract:"0x5dbc2a8b01b7e37dfd7850237a3330c9939d6457", tokenId:"0xb79") {
name
auction {
created
payToken
reservePrice
lastBid
lastBidder
}
}
}
`
})
})
.then(response => response.json())
.then(json => {
console.log(json); // print the result into the console
});
In the json
variable you will get a result object identical with the output from previous example.
Last updated