How to Aggregate Crypto-Currency Data with TokenCaps

Apr 20, 2024 | Programming

In the world of cryptocurrencies, having access to clean, normalized data from numerous exchanges is crucial for making informed decisions. TokenCaps is an ExpressNode-based framework designed to help you effortlessly aggregate crypto-currency data from the web, providing you with simple, easy-to-digest endpoints.

Getting Started with TokenCaps

To dive into the world of TokenCaps, you first need to install it. The installation process is straightforward and can be completed in just a few steps:

  • Open your terminal.
  • Run the command: npm install
  • Start your application with: npm start

Creating Tables and Running Cron Jobs

Once you’ve installed TokenCaps, you can create all necessary tables by sending a GET request to the following endpoint:

GET /create-all-tables

To start a cron job that queries coin ticker data, use this endpoint:

GET /cron/query-coin-list-table

If you’re interested in server-side graph rendering, you need to install chartjs-node along with canvas.js and cairo on your system. After installation, start the cron job for querying 24-hour data and server-side rendering with:

GET /cron/query-daily-history-table

You are now successfully running an API load balancer that serves crypto-currency data!

High Availability (HA) Deployment

For those looking to deploy TokenCaps in a fault-tolerant manner, it’s recommended to use a High Availability (HA) data cluster and run your API server behind a load balancer. As Node.js operates in a single-threaded environment, it’s essential to run the cron process in a separate node container to ensure that normal requests do not become jammed due to blocked aggregation queries. A popular choice for your database needs is YugaByte, which offers a polyglot database solution.

Interacting with the User Interface

Access the user interface endpoint at https://tokenplex.io. You can explore different views such as:

  • Exchange View: A snapshot view of public APIs from 79 exchanges.
  • Token View: Lists and details of 2000 coins, refreshed every 10 seconds.
  • Portfolio View: A management screen for your portfolio, supporting aggregate exchanges.

API Endpoint and Documentation

The TokenCaps API is hosted and can be accessed at https://api.tokenplex.io. It currently runs on an RF-1 YugaByte node. For detailed documentation on using the API, check out the docs here.

For production applications, it is advisable to run your own hosted solution for greater control and security.

How TokenCaps Works

The operation of TokenCaps is fascinating. Think of it as a library. Instead of having books scattered throughout city blocks, you centralize them in one large facility. In this analogy:

  • **Ticker data** acts like the books, stored in a Redis cache, updated every 3 seconds for fresh information.
  • **History Data** is comparable to archives that have a limited time to allow visitors to view them (e.g., minutely data with a TTL of 30 seconds).
  • **Real-time metrics** are like a coffee shop that serves updated data with varying wait times, based on how popular the information is.
  • When you need a graph printed (server-side rendering), it’s akin to an on-demand printing service that uses specific tools (cairo, canvas.js) for customization.

Troubleshooting Common Issues

If you encounter issues during installation or while running the application, here are some troubleshooting tips:

  • Ensure you have Node.js and npm properly installed and updated.
  • Verify your network connection if the API endpoints are not responding.
  • Check the logs for any warning or error messages that might indicate what went wrong.
  • If you experience performance issues, consider running the cron jobs in a separate node container as outlined earlier.

For further insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

TokenCaps offers a powerful solution for aggregating cryptocurrency data, with robust endpoints and a user-friendly interface. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox