API Cheat Sheet


Cartoon illustration titled AI API Cheat Sheet showing a developer using Gemini and Kilo Code to generate curl commands and Rust code while keeping API keys secret.

Scenario

You have a specific API you want to use but are not sure about the endpoint, the parameters, or whether it is public (no API key required) or private (requires an API key). All you know is the provider, and maybe you have access to the API docs.

But as all of us know, reading the documents and finding the exact right API call might be hit-and-miss, leaving you experimenting until you find the right one.

What to do?

Open your favourite AI client; for me, it is mostly Gemini or even Kilo Code, and enter your prompt.

Start by describing how you will use it, as a REST API called via curl, for example or in some programming language, for example, Rust. Specify the provider and what data you want included in the return.

Here is an example of a prompt I gave Gemini:

Using the CoinGecko API, give me a curl command to get the BTC price in ZAR on the VALR exchange

And here is Gemini’s response:

  • If you are using the CoinGecko Free API Tier, run this command
curl -X 'GET' \
  'https://api.coingecko.com/api/v3/exchanges/valr/tickers?coin_ids=bitcoin' \
  -H 'accept: application/json'
  • If you are using a CoinGecko Pro API Key, use the pro domain and include your API key in the header:
curl -X 'GET' \
  'https://pro-api.coingecko.com/api/v3/exchanges/valr/tickers?coin_ids=bitcoin' \
  -H 'accept: application/json' \
  -H 'x-cg-pro-api-key: YOUR_API_KEY_HERE'

If you specify a programming language, your response will be much more detailed and will include what libraries or crates, if you use Rust, are dependencies and some skeleton code as a starting point for how to call the API in the language you specified.

I hardly ever read the docs anymore; my AI agents are my go-to at the moment. I only reference the docs when the result is not what I want, and the AI agent clearly went off the boil and cannot come up with the correct answer.

Security Note

If and when you use any secure items like API keys. Do not include it in the code that you share; use environment variables that are local and use the keys via the environment variables.

Leave a Response