I'm trying to get the price, the volume and the all time high of a token from it's Smart Contract address with bitQuery APIs.
The query I'm using right now is this one:
{
ethereum {
dexTrades(
smartContractAddress: {is: "0x3ce38BC4dF7112E3944d724572E42B0cB805ad2A"}
quoteCurrency: {is: "0xe9e7cea3dedca5984780bafc599bd69add087d56"}
) {
quotePrice
}
}
}
But the response I'm getting is the following:
{
"ethereum": {
"ethereum": {
"dexTrades": null
}
}
}
Is there something I'm doing wrong? I took a look at some working samples and they are using an address directly in quoteCurrency, but It does not work with the contract address. It would be helpful also if someone can explain the difference between those to me.
Thank you all in advance.
Related
Hi I started playing with BitQuery graphql to see if it would help me with querying blockchain data. I love the idea of single API for most of the blockchains.
I have a problem tho. The data that Im getting back is critically not accurate and I don't know why.
{
ethereum(network: bsc) {
dexTrades(
exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
baseCurrency: {is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"}
quoteCurrency: {is: "0x55d398326f99059ff775485246999027b3197955"}
) {
baseCurrency {
symbol
}
quoteCurrency {
symbol
}
quotePrice
}
}
}
Given this query I want to get the Price of Cake/USDT. Which it returns as
{
"ethereum": {
"dexTrades": [
{
"baseCurrency": {
"symbol": "Cake"
},
"quoteCurrency": {
"symbol": "USDT"
},
"quotePrice": 16.96659680611786
}
]
}
}
But When I check with the PancakeSwap Exchange directly or coinmarketcap the price is 40% lower that BitQuery result...
PancakeSwap Price = 10.70
Coingeko Price = 10.75
Am I doing something wrong? Or BitQUery is broken? Or what can be the case? Any Ideas?
We are doing the same. I am actually playing around also in bitquery coz I'm trying to build something and I also encountered this one.
And what I found out is that "quotePrice" is not the actual price of the coin or token. It is just the average quote price that you can use to get the actual price. You still need to compute for price using an intermediary either WETH, etc..
See more info here: https://bitquery.io/blog/dex-price-index
The data returned from Bitquery seems to be correct as I checked from https://pancakeswap.finance/info/tokens which comes out to be around $8.60.
Your GraphQL query returns a different value somehow. I have tried to change the GraphQL query you made which you can check from this link
https://graphql.bitquery.io/ide/httpsstackoverflowcomquestions70784272bitquery-wrong-data-not-real-time
The GraphQL query is as follows:-
{
ethereum(network: bsc) {
dexTrades(
exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
baseCurrency: {is: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82"}
quoteCurrency: {is: "0x55d398326f99059ff775485246999027b3197955"}
) {
baseCurrency {
symbol
}
quoteCurrency {
symbol
}
quotePrice(calculate: any)
}
}
}
Is there a way to determine the subcsription status of an app via the Shopify node client or in the GraphQL API?
Given a user has signed up to our public app, when they log in. then I should be able to check if their Shopify subscription to our app is still active.
I can see via the GraphQL API I can query
currentAppInstallation {
activeSubscriptions {
id
name
test
}
}
This seems to return an empty array, implying my test store I doesn't have any active subscriptions. This may be due to my app and shop being in test mode though.
Does anybody know if this is the case or is there another way to get the subscription status?
Also, it would be good to do via the Shopify client if that is possible?
This is how I did if I have the APP subscription ID, I got the GraphQL query from Shopify's Billing API documentation:
query {
node(id: "gid://shopify/AppSubscription/4019585080") {
...on AppSubscription {
billingInterval
createdAt
currentPeriodEnd
id
name
status
test
lineItems {
plan {
pricingDetails {
...on AppRecurringPricing {
interval
price {
amount
currencyCode
}
}
...on AppUsagePricing {
terms
cappedAmount {
amount
currencyCode
}
balanceUsed {
amount
currencyCode
}
}
}
}
}
}
}
}
Notice that status is defined at root, so you'll get it inside the node.
I'm trying to setup the allow list feature in Hasura, but the docs seem pretty sparse. This is one of the queries:
{
hasura_auth(args: {cleartext_password: "xxx", email: "email#mail.com"}) {
jwt_token
}
}
How would I integrate the dynamic parts in an allow list?
I tried this and lot's of variations with no luck:
{
hasura_auth(args: {cleartext_password: $pass, email: $email}) {
jwt_token
}
}
Thanks for your help!
What you have to know is to tell hasura the name of your query with full syntax.
like this...
Operation name is => get_user_by_pk
Operation is
query get_user_by_pk($id: uuid!) {
user_by_pk(id: $id) {
id
username
email
}
}
the main part is you have to use the exact operation in your code having the operation name.
now, in your project, you will send the variable (in this case id[uuid]) to the query handler and send this to your hasura server.
ask me if it is not clear for you.
I am trying to include insights in a single call to Facebook ads API using Ruby. I researched this and got the following call:
params = {
'time_range': {
'since': '2019-08-01',
'until': '2019-08-31',
}
}
ad_account.campaigns(
fields: [
'adsets{
id,
insights{spend, impressions, clicks, ctr, cpc},
adcreatives{id, object_story_spec, image_url, object_type}
}'
],
params: params
).to_json
My response:
[
{
"adsets"=>{
"data"=>[
{
"id"=>"xxxxxxxxx",
"adcreatives"=>{
"data"=>
[
{
"id"=>"xxxxxxxxxxxxxx",
"object_story_spec"=>{
...
},
"image_url"=> "https://scontent.xx.fbcdn.net/v/xxxxxx",
"object_type"=>"SHARE"
}
],
"paging"=>{
"cursors"=>{
"before"=>"xxxxxx",
"after"=>"xxxxxxx"
}
}
}
}
],
...
So by levels, I am able to get all the campaigns, then the adsets inside them, and the adcreatives inside the adsets, but not the insights.
Am I doing something wrong? Does anyone have any experience with this?
So, surprisingly, Facebook DOES return insights with my call. Sometimes. No explanation why, but I tried with two accounts and got on one account insights and the other not.
Maybe it has something to do with the insights returned with this call have a shorter lifespan, so you can't get insights for older ads. Not sure. Not going to read through the million of pages.
My solution, for whoever is interested.
I made a call to adaccount insights directly, and specified the level as 'ad' so ir will return insights for all the account ads. I also requested the 'ad_id'. Later I was able to match the results returned with this call to the previous call I mentioned by comparing the ad ID, and merge the results.
ad_account.insights(
fields: ['ad_id', 'spend', 'impressions', 'clicks', 'ctr', 'cpc'],
level: 'ad',
time_range: {
since: date_since,
until: date_until
}
).to_json
In our company, we are creating an application by implementing graphQL.
I want to test and automate this APIs for CI/CD.
I have tried REST-assured but since graphQL queries are different than Json,
REST-assured doesn't have proper support for graphQL queries as discussed here.
How can we send graphQL query using REST-assured?
Please suggest the best approach to test and automate graphQL APIs
And tools which can be used for testing and automation.
So I had the same issue and I was able to make it work on a very simple way.
So I've been strugling for a while trying to make this graphQL request with Restassured in order to validate the response (amazing how scarce is the info about this) and since yesterday I was able to make it work, thought sharing here might help someone else.
What was wrong? By purely copying and pasting my Graphql request (that is not json format) on the request was not working. I kept getting error "Unexpected token t in JSON at position". So I thought it was because graphql is not JSON or some validation of restassured. That said I tried to convert the request to JSON, imported library and lot of other things but none of them worked.
My grahql query request:
String reqString = "{ trade { orders { ticker } }}\n";
How did I fixed it? By using postman to format my request. Yes, I just pasted on the QUERY window of postman and then clicked on code button on the right side (fig. 1). That allowed my to see my request on a different formatt, a formatt that works on restassured (fig. 2). PS: Just remeber to configure postman, which I've pointed with red arrows.
My grahql query request FORMATTED:
String reqString = {"query":"{ trade { orders { ticker } }}\r\n","variables":{}}
Fig 1.
Fig 2.
Hope it helps you out, take care!
You can test it with apitest
{
vars: { #describe("share variables") #client("echo")
req: {
v1: 10,
}
},
test1: { #describe("test graphql")
req: {
url: "https://api.spacex.land/graphql/",
body: {
query: `\`query {
launchesPast(limit: ${vars.req.v1}) {
mission_name
launch_date_local
launch_site {
site_name_long
}
}
}\`` #eval
}
},
res: {
body: {
data: {
launchesPast: [ #partial
{
"mission_name": "", #type
"launch_date_local": "", #type
"launch_site": {
"site_name_long": "", #type
}
}
]
}
}
}
}
}
Apitest is declarative api testing tool with JSON-like DSL.
See https://github.com/sigoden/apitest