Buy

Buying cryptocurrency with the API

To buy, you will first need to get an active price and then proceed to use this price to place an order. The getPrices query allows you to do this. You can also pass an optional cryptocurrency argument to view singular cryptocurrency prices.

query{
getPrices{
id
cryptocurrency
buyPricePerCoin
minBuy
maxBuy
expiresAt
}
}

The price call will return notable fields:

  • id: this is Global Object ID that you will need to pass to the buy mutation. You can also use it to retrieve a BuycoinsPrice node.

  • cryptocurrency: This is the cryptocurrency of the prices returned

  • buyPricePerCoin: This is the buy cost per coin in Naira

  • minBuy: This is the minimum amount of that cryptocurrency that can be bought

  • maxBuy: This is the maximum amount of that cryptocurrency that can be bought

  • expiresAt: This timestamp is when that price will expire.

To place a buy order, you will need the id of an active price.

mutation{
buy(price: "QnV5Y29pbnNQcmljZS0zOGIwYTg1Yi1jNjA1LTRhZjAtOWQ1My01ODk1MGVkMjUyYmQ=", coin_amount: 0.002, cryptocurrency: bitcoin) {
id
cryptocurrency
status
totalCoinAmount
side
}
}

Buy orders usually get filled in a minute but not more than 5 minutes. To check the status of your order, you can do a node lookup on Order using the id returned in your buy order mutation.

‚Äč