polymarket-api
Version:
Node.js SDK for querying Polymarket prediction market data. Get new prediction markets, resolved predictions, position tokens, and trading data from Polymarket using Bitquery APIs.
128 lines (125 loc) • 2.25 kB
JavaScript
const allTradesQuery = (count) => `
{
EVM(dataset: realtime, network: matic) {
DEXTradeByTokens(
orderBy: { descending: Block_Time }
limit: { count: ${count} }
where: {
TransactionStatus: { Success: true }
Trade: {
Side: {
Currency: {
SmartContract: {
is: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"
}
}
}
Dex: { ProtocolName: { is: "polymarket" } }
}
}
) {
Block {
Time
Number
Hash
}
Transaction {
Hash
From
To
}
Trade {
Dex {
OwnerAddress
ProtocolFamily
ProtocolName
}
AmountInUSD
Amount
PriceInUSD
Side {
Type
Amount
AmountInUSD
Currency {
Symbol
SmartContract
Name
}
Ids
OrderId
}
Currency {
Symbol
SmartContract
Name
}
Ids
OrderId
}
}
}
}
`;
const allTradesStream = `
subscription {
EVM(network: matic) {
DEXTradeByTokens(
where: {
TransactionStatus: { Success: true }
Trade: {
Side: {
Currency: {
SmartContract: {
is: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"
}
}
}
Dex: { ProtocolName: { is: "polymarket" } }
}
}
) {
Block {
Time
Number
Hash
}
Transaction {
Hash
From
To
}
Trade {
Dex {
OwnerAddress
ProtocolFamily
ProtocolName
}
AmountInUSD
Amount
PriceInUSD
Side {
Type
Amount
AmountInUSD
Currency {
Symbol
SmartContract
Name
}
Ids
OrderId
}
Currency {
Symbol
SmartContract
Name
}
Ids
OrderId
}
}
}
}
`;
export { allTradesQuery, allTradesStream };