Dec 02, 2025
Aris S.
9min Read
A public API (application programming interface) is a mechanism that enables everyone on the internet to integrate external tools into their website or application. It works by providing endpoints that users can use to request specific services or data from the server
Developers use public APIs for their efficiency, simplicity, and large datasets, which enables them to enrich their applications without developing everything from scratch. Public APIs are free and available for everyone to use, unlike private or internal APIs
You can use a public API in five simple steps:
Let’s learn about public API, where to find one, and how to integrate it into your application in more detail
A public API (application programming interface) is a mechanism for accessing a third-party service, tool, or data.
For example, you can integrate the Hostinger API into your custom application to manage your Hostinger account, including purchasing and
setting up a virtual private server (VPS).
To understand how a public API works, let’s use a restaurant as an analogy
Think of a restaurant where anyone can walk in and get the food they want. This is similar to a public API, where developers can use it to access different data or services
Using a public API is like ordering at a restaurant; there’s a specific process to follow, with different parts working together to fulfill your request. Let’s break it down one by one.
Endpoints
In a restaurant, you order a particular food by selecting a menu item. It is a way to tell the chefs in the kitchen what you want to eat
In APIs, menu items are similar to endpoints – URLs specifying what services, tools, or data you want to access. They are specified at the end of the API’s base URL like so:
api-provider.com/service
HTTP methods
Your application uses HTTP methods to specify the request to interact with an API. This is similar to talking with the server in a restaurant when ordering
Here are the HTTP methods, their functions, and equivalent analogies:
| Method | Meaning | Analogy |
| GET | Retrieve data | Checking the order status or menu |
| POST | Create new data | Placing an order |
| PUT/PATCH | Update data | Changing the existing order |
| DELETE | Remove data | Cancelling order |
API response
API responses are the information the server returns upon receiving your requests, written in the JSON format. It might contain a list of data or the request’s status
In a restaurant, this is similar to a receipt you get after placing, changing, checking, or cancelling your order. It might look like this:
{
"order_id": 123,
"item": "Cheeseburger",
"status": "preparing"
}Rate limiting
The rate limiting is a system that sets the maximum number of requests an API can process. It is crucial to prevent the API from being overloaded, which can cause issues like unresponsiveness or downtime
This rate-limiting feature is similar to a restaurant policy that only allows a specific number of orders within a particular time frame
API keys
API keys are authorization tokens that the provider uses to verify the requests’ validity and legitimacy. This system improves security and is crucial for tasks like rate limiting because it allows the API provider to track each requester.
API keys are similar to restaurant reservation proof, which verifies who you are and when you’re allowed in.
Developers commonly use public APIs for various reasons, such as:
Public APIs power many of the features we use every day. From embedding maps to processing payments, here are some of the most common ways developers put them to work:
Aside from public, there are other types of API for different use cases. Here’s their comparison.
A private API is similar to the public one in that parties outside the provider can use it. However, the private API is limited only to eligible users, such as subscribers or partners
In contrast, a public API lets anyone use it for free as long as they have the endpoint and a valid authentication key
An internal API is only available for the developers or organizations that built it. It is designed specifically for their needs and is used to integrate different services, tools, and features within a project
For example, an application with a microservice architecture often uses an internal API to distinguish user requests and forward them to specific services, such as authentication or database operations.
The steps to use and integrate a public API might differ slightly depending on the provider. However, the general procedure is similar.
Let’s begin by finding a public API that fits your needs and preferences. There are several repositories where you can explore different public APIs, including the Public API list on GitHub

To choose the right public API, consider the following key factors:
Reading the API documentation is crucial to understanding how it works and how to integrate it into your application correctly.
This is because the documentation contains essential information about the public API, such as:
To obtain the endpoint and API key, we must create an account in the API provider’s platform. The process should be similar regardless of the provider, but the actual steps might slightly differ.
For demonstration, here’s how to create a Hostinger account and obtain an API key from it


The shorter your API token expiration date, the more frequently you must update it. However, it helps improve security because the authentication key will be less likely to be compromised.
Once you obtain the API key, store it in a safe location, as we will use it later. Note that API providers commonly block you from viewing the key again after closing the token generation page for security reasons
The easiest way to test the API is to use the cURL command, a utility that lets you use different HTTP methods to send a request to a server, which in this case is the API endpoint.
To test the API using cURL, simply open your computer’s terminal or command prompt and run the following syntax:
curl -X method "URL" -H "Authentication: API-key"
Replace method with the actual HTTP method and URL with the endpoint address. For example, your command may look like this:
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines" -H "Authentication: Bearer abcd123efgh456"

Note that your API specification may require you to include more information about the request in your command. Refer to your API’s documentation to learn more about its testing guidelines
Another popular method of testing an API is to use Postman. This software offers a graphical user interface and more comprehensive features than cURL, making it suitable for performing complex API testing with multiple endpoints. Here’s how to do it:
If the API call is successful, you will see the JSON response at the bottom of your Postman client

Integrating the public API into your project involves different steps depending on the API type, your project’s structure, and the programming language or technology you use
Typically, you integrate the API on the back end of your application and call it from the front end. Here are the components to achieve it:
For example, we have a simple Express.js + HTML website that integrates with the Hostinger API to fetch and display your Linux VPS hosting resource metrics

The API proxy code looks like the following:
app.get('/api/metrics', async (req, res) => {
const { vmId, date_from, date_to } = req.query;
if (!vmId || !date_from || !date_to) {
return res.status(400).json({ error: 'Missing parameters' });
}
const url = `${API_BASE_URL}/api/vps/v1/virtual-machines/${vmId}/metrics?date_from=${date_from}&date_to=${date_to}`;
try {
const response = await fetch(url, {
headers: {
'Authorization': `Bearer ${BEARER_TOKEN}`
}
});Meanwhile, the back-end callback function looks like this. It resides in our website’s index.html file:
const res = await fetch(`/api/metrics?vmId=${vmId}&date_from=${dateFrom}&date_to=${dateTo}`);
const data = await res.json();In the index.html, we also have the following code to read and format fetched JSON data into a simpler, more human-readable format:
results.innerHTML = `
<div class="metric">
<h3>CPU Usage</h3>
${data.cpu_usage.usage[ts]} ${data.cpu_usage.unit}
</div>
<div class="metric">
<h3>RAM Usage</h3>
${formatBytes(data.ram_usage.usage[ts])}
</div>
<div class="metric">
<h3>Disk Space</h3>
${formatBytes(data.disk_space.usage[ts])}
</div>
Several API providers may also have software development kits (SDKs) that offer pre-packaged tools and libraries for streamlining the integration process. For example, Hostinger API’s SDKs let you easily connect our hosting services with your PHP, Python, or TypeScript applications.
Various websites, repositories, and platforms offer a catalog of public APIs. Here are some of the most popular ones.
A public API is an excellent solution for easily integrating rich data sources or ready-to-use features into your application
Aside from improving development efficiency, a public API helps minimize fatal errors that can cause malfunctions or downtime because you don’t need to alter your application’s code significantly.
Before implementing an API in your application, test it first to better understand how it works. We recommend the Hostinger API for testing and learning because it is free, offers various endpoints, and has comprehensive documentation. You can also integrate the Hostinger API into applications that support Model Context Protocol (MCP) like Claude to enable AI-based hosting management. To learn more about the steps, check out our setting up an Hostinger API MCP server tutorial.