Use
openOrders for active orders. Use orders for complete history.Books (paginate)
Copy
query Books($first: Int!, $skip: Int!) {
books(first: $first, skip: $skip, orderBy: id) {
id
base {
id
symbol
decimals
}
quote {
id
symbol
decimals
}
unitSize
makerPolicy {
fee
isFeeInQuote
}
takerPolicy {
fee
isFeeInQuote
}
}
}
Depth by price level
Copy
query Depth($book: ID!, $first: Int!) {
book(id: $book) {
id
depths(first: $first, orderBy: tick, orderDirection: desc) {
tick
unitAmount
baseAmount
quoteAmount
}
}
}
Active orders for a user
Copy
query MyOpenOrders($owner: Bytes!, $book: ID!) {
openOrders(
where: { owner: $owner, book: $book }
orderBy: tick
orderDirection: desc
) {
id
tick
unitAmount
pendingUnitAmount
claimableUnitAmount
cancelableUnitAmount
timestamp
}
}
Recent taker trades (takes) in a book
Copy
query RecentTakes($book: ID!, $first: Int!) {
takes(
where: { book: $book }
first: $first
orderBy: timestamp
orderDirection: desc
) {
id
timestamp
trader
inputToken {
id
symbol
}
outputToken {
id
symbol
}
inputAmount
outputAmount
amountUSD
transaction {
id
}
}
}
Order history with fills, claims, and cancels
Copy
query OrderHistory($orderId: ID!) {
order(id: $orderId) {
id
tick
price
unitAmount
pendingUnitAmount
fills(orderBy: timestamp, orderDirection: asc) {
id
timestamp
inputAmount
outputAmount
transaction {
id
}
}
claims(orderBy: timestamp, orderDirection: asc) {
id
timestamp
claimedUnitAmount
transaction {
id
}
}
cancels(orderBy: timestamp, orderDirection: asc) {
id
timestamp
canceledUnitAmount
transaction {
id
}
}
}
}
Maker fills for a user across all books
Copy
query MakerFillsByUser($maker: Bytes!, $first: Int!) {
makerFills(
where: { maker: $maker }
first: $first
orderBy: timestamp
orderDirection: desc
) {
id
timestamp
book {
id
base {
symbol
}
quote {
symbol
}
}
tick
price
inputAmount
outputAmount
amountUSD
orderIdString
}
}
All trades for a given user in a book
Copy
query UserTradesInBook($user: Bytes!, $book: ID!, $first: Int!) {
trades(
where: { trader: $user, book: $book }
first: $first
orderBy: timestamp
orderDirection: desc
) {
id
type
timestamp
trader
book {
id
}
inputToken {
id
symbol
}
outputToken {
id
symbol
}
inputAmount
outputAmount
amountUSD
logIndex
transaction {
id
}
}
}
Cancels for a specific order
Copy
query OrderCancels($orderId: ID!) {
order(id: $orderId) {
id
tick
price
cancels(orderBy: timestamp, orderDirection: asc) {
id
timestamp
canceller
owner
canceledUnitAmount
canceledBaseAmount
canceledQuoteAmount
canceledAmountUSD
remainingClaimableUnitAmount
remainingCancelableUnitAmount
transaction {
id
}
}
}
}
Claims by owner across all books
Copy
query ClaimsByOwner($owner: Bytes!, $first: Int!) {
claims(
where: { owner: $owner }
first: $first
orderBy: timestamp
orderDirection: desc
) {
id
timestamp
book {
id
base {
symbol
}
quote {
symbol
}
}
claimer
orderIdString
tick
price
claimedUnitAmount
claimedBaseAmount
claimedQuoteAmount
claimedAmountUSD
transaction {
id
}
}
}
Cancels by owner across all books
Copy
query CancelsByOwner($owner: Bytes!, $first: Int!) {
cancels(
where: { owner: $owner }
first: $first
orderBy: timestamp
orderDirection: desc
) {
id
timestamp
book {
id
base {
symbol
}
quote {
symbol
}
}
canceller
orderIdString
tick
price
canceledUnitAmount
canceledBaseAmount
canceledQuoteAmount
canceledAmountUSD
transaction {
id
}
}
}
All order movements (takes, claims, cancels) for a user
Using theOrderMovement interface to query all order movements:
Copy
query UserOrderMovements($trader: Bytes!, $book: ID!, $first: Int!) {
orderMovements(
where: { trader: $trader, book: $book }
first: $first
orderBy: timestamp
orderDirection: desc
) {
id
type
timestamp
trader
book {
id
}
logIndex
transaction {
id
}
... on Take {
inputToken {
symbol
}
outputToken {
symbol
}
inputAmount
outputAmount
}
... on Claim {
orderIdString
claimedUnitAmount
claimedQuoteAmount
}
... on Cancel {
orderIdString
canceledUnitAmount
canceledQuoteAmount
}
}
}