Lesson 1. What Is an API and Why Your Agent Needs It#
Goal: understand what an API is and how it helps your agent communicate with other services.
What Is an API in Plain Terms#
API (Application Programming Interface) is an "interface for programs"—a way for one program to talk to another.
For non-technical users, an API is like:
- a restaurant menu for programs: you don't go into the kitchen, you just pick a dish from the menu → the chef cooks → the waiter brings it
- a power outlet for programs: you don't mess with the electrical grid, you just plug in → you get power
An API lets your agent:
- read data from another service (e.g., get a list of clients from a CRM)
- write data to another service (e.g., create an order in a store)
- perform actions (e.g., send an email, create a calendar event)
How It Works#
Example: an agent sends an email via the Gmail API.
- The agent builds a request: "Send an email to ivan@example.com with subject 'Hello' and body 'How are you?'"
- The request is sent to the Gmail API (over the internet)
- Gmail API checks authorization (whether the agent has permission to send email on your behalf)
- Gmail API performs the action (sends the email)
- Gmail API returns a response: "Email sent successfully" (or an error if something went wrong)
Flow:
Agent → Request (JSON) → Gmail API → Gmail sends email → Response (JSON) → Agent
Why Your Agent Needs an API#
Without an API, the agent would be isolated—it could only talk to the user.
With an API, the agent can:
- read data from CRM, Google Sheets, knowledge bases
- send notifications to Telegram, email, SMS
- create tasks in Notion, Trello, Asana
- accept payments via Stripe, YooKassa
- make calls via Twilio
- generate content via OpenAI, Midjourney
APIs turn your agent into a full automation tool.
Types of APIs#
1. REST API (most common)
- works over HTTP (like a regular website)
- requests and responses in JSON format
- uses methods: GET (read), POST (create), PUT (update), DELETE (delete)
2. GraphQL API
- more flexible than REST
- you can request only the fields you need
- used in modern services (Shopify, GitHub)
3. Webhook (callback)
- the service sends data to your agent when an event happens
- example: new order → store sends data to agent → agent processes the order
For most tasks, REST API is enough.
Examples of Popular APIs#
| Service | API for what | Documentation |
|---|---|---|
| Google Sheets | Read / write data in spreadsheets | developers.google.com/sheets/api |
| Gmail | Send / read email | developers.google.com/gmail/api |
| Telegram | Send messages to bots | core.telegram.org/bots/api |
| Stripe | Accept payments | stripe.com/docs/api |
| OpenAI | Generate text (ChatGPT) | platform.openai.com/docs/api-reference |
| Twilio | Send SMS, make calls | twilio.com/docs/usage/api |
| Notion | Read / write data in the database | developers.notion.com |