By the end of this lesson, you should be able to:
API stands for Application Programming Interface. It is a system that allows two different software applications to communicate and exchange information.
Imagine visiting a restaurant in Lagos. You sit at a table and tell the waiter what you want to eat. The waiter takes your order to the kitchen and returns with your food.
In this example:
Modern applications need information from different sources. APIs make it possible to collect, send, update and retrieve information without manually transferring data between systems.
For example, consider a Nigerian online shopping platform.
Most web APIs work through a request-and-response process.
An API endpoint is a specific URL where an application can access a particular resource or service.
Example:
This endpoint could be designed to return student records from a school management system.
Another example:
This endpoint could return a list of available courses. These are illustrative URLs, not live services.
| Method | Purpose | Example |
|---|---|---|
| GET | Retrieve information | View student records |
| POST | Create or submit information | Register a student |
| PUT | Replace existing information | Update a student profile |
| PATCH | Update part of a record | Change a phone number |
| DELETE | Remove information | Delete a student record |
APIs commonly return data in JSON format. JSON means JavaScript Object Notation. It is a simple format used to exchange information between applications.
Example of a JSON response:
{
"student_id": 101,
"name": "Adebayo",
"course": "Data Analytics",
"country": "Nigeria",
"status": "Active"
}
In this example, the API returns information about a student. The receiving application can read the information and display it on a dashboard.
Platforms can integrate payment APIs such as Paystack to receive payments from customers.
School management systems can use APIs to exchange student information, examination results and attendance records.
Banking applications can use APIs to communicate with other financial services and authorised payment systems.
Online stores can use APIs to manage orders, check product availability and arrange deliveries.
JavaScript provides the Fetch API, which allows a web page to request information from an API.
Example:
fetch('https://jsonplaceholder.typicode.com/users/1')
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.log('Error:', error);
});
This example retrieves sample user information from a public testing API and displays the response in the browser console.
APIs often handle sensitive information. Therefore, developers must protect them against unauthorised access and misuse.
Objective: Learn how to retrieve data from a public API.
Instructions:
Question 1: What does API stand for?
A. Application Programming Interface
B. Advanced Processing Information
C. Application Personal Integration
D. Automated Programming Internet
Question 2: Which HTTP method is commonly used to retrieve data?
A. DELETE
B. GET
C. POST
D. PATCH
Question 3: What is JSON commonly used for?
A. Designing websites
B. Editing videos
C. Exchanging structured data
D. Creating computer hardware
Question 4: What does an API endpoint represent?
A. A computer keyboard
B. A specific URL for accessing an API resource
C. A database password
D. A programming language
Question 5: Which practice helps secure an API?
A. Sharing API keys publicly
B. Disabling authentication
C. Using HTTPS and protecting API keys
D. Allowing unlimited requests
1. A
2. B
3. C
4. B
5. C
APIs allow different software applications to communicate and exchange data. They are essential to modern technology, including banking, education, e-commerce, healthcare and digital services.
Understanding API endpoints, HTTP methods, JSON responses and API security provides a strong foundation for working with data-driven applications.