cardano-pricing-client
v1.0.4
Published
TypeScript client for XRAY/Graph Pricing API
Downloads
8
Readme
Cardano Pricing TypeScript Client
[!WARNING] XRAY/Graph Pricing API and client are in active development, stay tuned to https://twitter.com/xray_network for updates.
[!NOTE] Automatically generated Openapi-fetch (Axios) client for XRAY/Graph Pricing API based on schema.yaml OpenAPI schema. DEX price tracking for any Cardano token
Installation
To install the client with Yarn, run:
yarn install cardano-pricing-client
To install the client with NPM, run:
npm i cardano-pricing-client
Usage
import PricingClient from "cardano-pricing-client"
const client = PricingClient("https://graph.xray.app/output/pricing/mainnet/api/v1")
const app = async () => {
const orders = await client.GET("/orders")
if (orders.data) {
console.log(tip.data)
}
if (orders.error) {
console.error(tip.error)
}
}
app()
Advanced Usage
import PricingClient from "cardano-pricing-client"
const client = PricingClient("https://graph.xray.app/output/pricing/mainnet/api/v1")
const app = async () => {
const abortController = new AbortController()
setTimeout(() => {
abortController.abort() // cancel request
console.log('Aborted!')
}, 200)
const orders = await client.GET("/orders", {
signal: abortController.signl,
})
if (orders.data) {
console.log(tip.data?.[0]?.block_no)
}
if (orders.error) {
console.error(tip.error)
}
}
app()
Endpoints
- Check OpenAPI fetch documentations for available endpoint parameters: https://openapi-ts.pages.dev/openapi-fetch/
- The client uses OpenAPI definitions from the Pricing API configuration: schema.yaml
API URLs
Managed by XRAY/Network (XRAY/Graph, Cloudflare WAF & Load Balancer)
https://graph.xray.app/output/pricing/mainnet/api/v1
https://graph.xray.app/output/pricing/preprod/api/v1
https://graph.xray.app/output/pricing/preview/api/v1