|
AI & Apps

Using APIs without a developer: a practical guide

An API is not magic. It is an address that takes a message and sends back an answer. You can connect one with a form, a key and twenty minutes of patience.

Using APIs without a developer: a practical guide

The first API I connected by myself was a payment gateway, and I broke it twice in one night. The first time, I pasted the live key instead of the test key and charged a friend 100 naira for nothing. The second time, I put the key in a public page and got an email from the company at 2am.

I tell that story because people treat APIs like a developer secret. They are not. An API is an address that accepts a message and sends back an answer. If you can fill a form, you can use one.

What an API is, in plain words

Think of a restaurant. You do not walk into the kitchen. You tell the waiter what you want, the waiter takes it to the kitchen, and food comes back. The menu is the documentation. The waiter is the API.

That is the whole idea. You send a request with some details. The service sends back a response. The documentation tells you what details it wants and what it will return.

Every API you touch as a beginner works the same way. You need three things: the address, which is called the endpoint, your identity, which is the key, and the shape of the message, which is the format.

Read the docs in this order

Documentation pages are long and written for developers who already know what they are doing. Skip to four parts.

  1. The authentication section, to see how the key is sent.
  2. The first example request, usually a copy and paste block.
  3. The list of parameters, to know what is required and what is optional.
  4. The error codes, so you know what a 401 or a 429 means before you see one.

Ignore the SDKs, the framework guides and the changelog on your first pass. You do not need them to make one request work.

Once you have read those four parts, make one request outside your app. Hoppscotch, Postman or a simple curl command will do. Paste the key, paste the example body, hit send. If you get a 200 and some data, the hard part is done.

This step saves hours. When something fails inside your app, you already know the key and the endpoint work, so the problem is in how you connected them. Without this step you are guessing at three things at once.

Use test keys wherever the service offers them. Paystack and Flutterwave both have a test mode that lets you run fake payments. Fake money is the best money to lose while learning.

Connect it without writing much code

Two routes. The no-code route uses Make, Zapier or n8n. You add a trigger (a form response, a new row, a WhatsApp message), add an HTTP module, paste the endpoint and the key, and map the fields. It is fiddly but visual, and you can see the request fail in front of you.

The small script route uses ten lines of Python or JavaScript. For OpenAI, the official examples are short enough to read in a minute. Ten lines is not an exaggeration. You import the library, set the key, send the messages, print the answer.

I prefer the script for anything I will run more than a hundred times. No-code tools charge by the task on their paid plans, and the cost adds up faster than an API bill. For a first test, no-code is faster and less scary.

The errors you will see

  • 401 means the key is wrong, missing or expired. Check for a space at the end of the key, because that is the usual culprit.
  • 400 usually means a required field is missing or the JSON is malformed. Print the exact body you sent.
  • 429 means you are sending too many requests. Add a delay or check your plan limits.
  • 500 means the service is broken, not you. Retry once after a minute, then check their status page.

Learn to log the request and the response, without the key. Half of debugging is seeing what you sent, not what you think you sent.

Guard the key and the bill

A key in a front-end page is a key given away. Anyone can open the browser tools and read it. If your app runs in the browser, put the key on a server, or use a service that proxies the request for you.

Set a spending limit on the provider's dashboard before you test. OpenAI, Google and most others let you cap monthly spend. Set it at 10 dollars. When you hit the cap the app stops, which is annoying, and much better than a 400 dollar surprise on a card you share with your family.

I learned that one from a friend who left a loop running overnight. The loop kept calling the model with the same prompt, the model kept answering, and the bill kept growing. Nobody was awake to stop it. The app was not even useful. It was a test he forgot to close.

Pick one thing

Pick one API with a free tier. Make one successful request outside your app. Then connect it to a form and send yourself the answer. That is the whole skill, repeated with different menus.

If you have not built the container yet, read how to build your first AI app with no coding background. When it is time to put it online, the cheapest way to host an AI app will keep the bill small. The Software development with AI course has a lesson on connecting Paystack and OpenAI without exposing either key.

Dave Partner

Dave teaches digital skills at Braintem and has helped thousands of Nigerians move from watching tutorials to charging for real work. He writes about the parts nobody puts in the course trailer.