API Connections / What is an API?

What is an API? Beginner

An API is how programs talk to each other. Understanding it is the first step to having your bot work with real services like shipping carriers and online stores.

What you'll learn

  • What an API is
  • How a request and a response work
  • How a bot uses APIs

Before you start

1. The restaurant picture

Think of a restaurant. You (a program) don't walk into the kitchen (the service). You give your order to a waiter (the API), who brings back your food (the data). An API, short for application programming interface, is that waiter.

2. A request and a response

Every API call has two halves. The request is what you send. It has:

  1. A URL: the web address of the thing you want, like a tracking endpoint.
  2. A method: what you want to do. GET reads, POST creates, PUT/PATCH update, DELETE removes.
  3. Headers: extra labels, such as your key that proves who you are.
  4. Sometimes a body: the details, often in JSON.

The response comes back with a status code (200 means OK) and usually some JSON, a simple text format of names and values like {"status": "Delivered"}.

Screenshot: A simple diagram: bot sends a request, the service sends back a JSON response.

3. How a bot uses APIs

In Your First Bot you learn the loop: receive, think, respond. APIs plug into it. The bot receives "Where's order 1001?", thinks "I need the tracking API", sends a request, and responds with the answer in plain words.

4. APIs vs connectors

For many popular apps, Grok Bot has ready-made connectors, so you never touch an API. APIs matter when there's no connector, or you want your own code to do the job.

Ideas to try

  • Curious shopper.
    Explain what happens, step by step, when a website shows me a shipping estimate.
  • Learn by doing.
    Call a free public API that returns the current weather for Chicago and explain each part of the response.
  • Small shop.
    Which of my tools (Shopify, UPS, Gmail) have APIs, and which already have connectors?
  • Homework helper.
    Show me a GET request and a POST request side by side and explain the difference.

Tips

  • You don't need to code to understand APIs; reading one response with your bot is the best lesson.
  • Status codes in the 200s mean success; 400s mean something about your request; 500s mean the service had a problem.
  • Use the official docs for every service; they list the exact URLs.

Facts about the Grok Bot app come from Cursor's official Grok Bot documentation. See also MDN: An overview of HTTP. Menus and services change; if something looks different, check the official docs or ask your bot.