Simple Object Queries
info
You can fetch a single data entry using a simple object query. Any argument has to be an array (except booleans).
This is a simple query that retrieves information about a specific asset, filtered by its symbol "ETH".
The limit parameter is set to 1, meaning only one asset will be returned in the response.
- Query
- Response
{
assets(where: {symbols: ["ETH"]}, limit: 1) {
id
name
slug
description
symbol
}
}
{
"data": {
"assets": [
{
"id": "asset-id",
"name": "Ethereum",
"slug": "ethereum-2-0",
"description": "the worlds largest and most decentralised Layer1 blockchain. The network is used for building dApps, holding assets, transacting and communicating without being controlled by a central authority. The Ethereum vision is to build a digital future on a global scale, that is powerful enough to help all of humanity. The native token of the network is Ether ($ETH) which is used to pay for certain activities on the Ethereum network",
"symbol": "ETH"
}
]
}
}
The response contains a top-level "data" field, which has a nested "assets" field. This "assets" field is an array of asset objects, with each object having fields like "id", "name", "slug", etc.
To access the data in the array, you can use array methods like forEach or map:
response.data.assets.forEach((asset) => {
console.log(asset);
});
You can also use array destructuring to access the data:
const [asset] = response.data.assets;
console.log(asset.id);
console.log(asset.name);
console.log(asset.slug);
console.log(asset.description);
console.log(asset.symbol);