WorkflowCredmark Logo

Credmark’s Token API is Extensible 🤯

Limitless Possibilities

Paul Murphy

2022/11/16

Resources to check-out:

  • Decentralizing Crypto Prices is necessary to advance web3
  • Read more about Credmark's solution for deriving prices off of DEXes
  • Here's how CeFi manipulate crypto prices and why DeFi prices are better

How often have you used a data API that gave you everything you needed? My answer to that question is NEVER.

Hitting a Brick Wall

This is what typically happens.

You are happily using “The Official Star Wars API” to retrieve the names and images of the actors who played Star Wars characters. You display them like trading cards in a sexy website using your favorite framework. You even make them searchable. Everyone loves it.

But one day your boss walks in and asks you to add the actors’ birth dates to their cards. “No problem,” you tell her, figuring there must be an endpoint for retrieving such basic information. Unfortunately, there isn’t. You contact Disney’s support team and you’re told: “It’s on our roadmap.”

Have you heard that one before?

Now you have to find another API or, worse, gather the data manually. You’re unhappy with both options.

Like the Star Wars series, the above example is pure fiction. Unfortunately, hitting the API brick wall isn’t. It happens all the time.

Going Right Through that Brick Wall

One of our customers, Picante, uses our Token API to retrieve current and historical token prices.

This is how you retrieve the latest price for the Aave token using the Token API, for example:

curl \
-H 'Authorization: Bearer <API KEY>' \
https://gateway.credmark.com/v1/tokens/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/price

Picante recently came to us and asked if we could price DEX LP tokens. Specifically they asked for Uniswap v2, Uniswap v3, and SushiSwap tokens. We solved their problem in a few hours.

So now, Picante users who provide liquidity to DEXes can see both their liquidity and the fees they’ve earned, right in their Picante dashboard.

Are we magicians? I’m afraid not. In a few hours we couldn’t possibly

  • implement a new endpoint in our Token API,
  • deploy it,
  • test it, and
  • write documentation.

That would be impossible. It also wouldn’t make much sense. We can’t keep adding endpoints to an otherwise generic API. 99% of our customers could care less about LP tokens!

So how did we do it?

Here’s something most people don’t know:

Under the hood of all our APIs (Token, Portfolio, and Protocol) sits the Credmark Platform. This platform allows developers to easily build and deploy financial models leveraging our base layer of crypto data. Every API endpoint calls a model deployed on the Credmark Platform.

But not every model has a corresponding API endpoint. Most are too esoteric. For every API endpoint we publish, approximately ten related models are deployed on the platform.

Any of those models can be called directly using our special API that we call the DeFi API, which has exactly one endpoint. That endpoint is the ultimate escape hatch.

This is how you retrieve the price of a Uniswap v3 token using the DeFi API for example:

curl \
-H 'Authorization: Bearer <API KEY>' \
-X 'POST' https://gateway.credmark.com/v1/model/run#uniswap-v3.lp \
-H 'Content-Type: application/json' \
-d '{
  "slug": "uniswap-v3.lp",
  "chainId": 1,
  "blockNumber": "latest",
  "input": {
    "lp": "0x297e12154bde98e96d475fc3a554797f7a6139d0"
  }
}'

No matter how strange or unique your request might be, we can (almost) always address it by building and deploying a custom model. Or you can build and deploy it using the open source Credmark Model Framework (CMF).

The Escape Hatch

Technically-speaking our Token API isn’t extensible, but practically-speaking, it is. In fact, all our APIs are both constrained and extensible. They are constrained by design and don’t try to accommodate every possible case. They address the most common ones, as simply as possible. This is how we think APIs should be designed.

Constraints are great, until they aren’t.

At some point everyone needs an escape hatch. At Credmark we’re proud to have designed one into the very core of our product suite.

About Credmark

Credmark runs a financial modeling platform powered by reliable on-chain data. We curate and manages DeFi data making it available via API and the Snowflake Marketplace around the globe and across industries.

Our community of quants, developers, and modelers actively build models for the DeFi community by leveraging our data API and tools. Join the growing community and together we will advance the next-generation financial system.

copy to clipboard

Sign up for our newsletter for the latest product updates, partnerships, and more.

Ready to get started?

Sign up for our free Token API

Get the latest news

Footer

Credmark logo
DiscordDiscord iconTwitterTelegramTelegram iconYoutubeYouTube iconGitHub

© 2023 Credmark Labs, Inc. All rights reserved.

Products

  • All Products
  • Token API
  • Portfolio API
  • DeFi API
  • Raw Data

Documentation

  • Token API Reference
  • Portfolio API Reference
  • DeFi API Reference
  • Transformation Reference
  • Framework Reference

Resources

  • FAQ
  • Blog
  • Reports
  • Media

About

  • Careers
  • About us
  • Community

Support

  • Status
  • Contact us