API Fundamentals → Applied

Understanding APIs
& the Hostinger VPS API

From "what is an API" to actually managing a server's lifecycle, snapshots, and configuration through code — no dashboard clicking required.

Who this is for
Anyone comfortable with basic tech concepts who wants to automate VPS management
What you'll build toward
Confidently reading & calling the Hostinger VPS API for lifecycle + snapshot tasks
Format
9 slides · analogies · a quiz at the end
01 · Foundation
Foundation

What is an API, really?

An API (Application Programming Interface) is a defined way for two pieces of software to exchange requests and data — without either one needing to know how the other works internally.

The restaurant analogy: you (the client) tell the waiter (the API) what you want. The waiter carries your order to the kitchen (the server), and brings back your food (the response). You never enter the kitchen, and the kitchen never needs to know who exactly asked — just what was ordered.
The 4-step cycle
1
Request — client sends a request to a specific address
2
Process — server receives and handles it
3
Response — server replies with data or a status
4
Display — client shows or uses the result
Real example
A checkout page uses Stripe's API: your site sends the payment details, Stripe processes the charge, and sends back "success" or "declined" — all in under a second, with no custom payment system built from scratch.
02 · Foundation
Foundation

Does a website "have" an API — or just use one?

These are two different things, and mixing them up causes confusion. Most websites consume APIs. Far fewer expose one of their own.

Consuming an API (most sites)
The site calls out to someone else's API in the background — Stripe for payments, Mailchimp for email signups. Invisible to visitors. Nothing external can call into this site's backend.
Exposing an API (fewer sites)
The site has its own public endpoints — usually on a subdomain like api.example.com — that other applications can call. It has its own docs, auth tokens, and versioning.
Quick tells that a site exposes its own API
A dedicated api. subdomain · a public "API Documentation" or "Developers" page · a way to generate personal access tokens · versioned paths like /v1/. Hostinger, for instance, exposes its own API at developers.hostinger.com for exactly this reason.
03 · Core Concept
Core Concept

API vs. cron job — different jobs entirely

These get confused because both are often used for "automation." But one is about who's asking, the other is about when it runs.

Doorbell vs. mail carrier: an API is a doorbell — something happens only when a client actively rings it, right now, expecting an answer. A cron job is the mail carrier — it shows up on a fixed schedule (say, every day at 2am) whether or not anyone asked, and doesn't wait for a reply.
DimensionAPICron Job
TriggerAn external request, on demandThe clock, on a fixed schedule
Needs a caller?Yes — no request, no actionNo — runs regardless
Typical use"Create a snapshot right now""Create a snapshot every night at 2am"
Response expected?Usually yes, immediatelyNo caller waiting on a reply
They usually team up
In practice, a cron job is often the thing that calls an API on a schedule — e.g. a script scheduled for 2am that calls the Hostinger VPS API's snapshot endpoint automatically before nightly maintenance. The cron job decides when; the API is what gets called.
04 · Core Concept
Core Concept

The four verbs behind every API call

Every API action boils down to one of these methods. Here's what each one looks like when it's your VPS on the other end.

MethodPurposeChanges data?VPS API example
GETRetrieve informationNoList your VPS instances, check server status
POSTCreate something newYesCreate a new snapshot, provision a new VPS
PUTUpdate existing dataYesSet a new hostname, update firewall rule
DELETERemove dataYesDelete an existing snapshot
Rule of thumb: GET is safe to repeat as many times as you like — it never changes anything. POST, PUT, and DELETE all modify server state, so they deserve a second look before you fire them, especially DELETE.
05 · Applied
Applied

Meet the Hostinger VPS API

This is a REST API — regular HTTPS URLs, JSON responses — that lets you control your VPS the same way hPanel does, but from a script.

Getting a token
1
Log in to hPanel → account icon → Account information
2
Open API in the sidebar → New token
3
Name it, set an expiration, click Generate
4
Send it as a Bearer token in every request's Authorization header
Server lifecycle endpoints
List, get, start, stop, restart, recreate, set hostname, reset root password — all as simple HTTP calls against developers.hostinger.com. No SSH session needed just to reboot a server.
Beyond the basics
The same API also manages firewall rules, SSH keys, Docker containers, and reverse DNS — meaning most things you'd otherwise click through in hPanel can be scripted end to end.
06 · Applied
Applied

Snapshots: your "undo" button, via API

The snapshot endpoints let you capture your VPS's exact state before you risk breaking it — then roll back with a single call if needed.

Think of it as a savepoint in a video game: you save right before the boss fight (a risky update). If it goes badly, you reload the savepoint instead of starting the whole level over.
FeatureManual Snapshot (API)Automated Backup
TriggerOn-demand, via API/hPanelScheduled — weekly (daily optional)
Storage slotsOnly 1 at a time — creating a new one overwrites the oldUp to 4 retained
LifespanExpires after 1 day; also deleted on OS reinstall or restoreRolling retention
Best forA quick checkpoint right before a risky changeOngoing, long-term protection
Restoring is irreversible
Restoring from a snapshot completely overwrites the current server and locks it until the process finishes. Download anything you need to keep first — there's no undo on the undo button.
07 · Practice
Putting it together

A real automation pattern — and a safety checklist

Here's how the pieces from this deck combine into something you'd actually run, plus the habits worth locking in before you touch DELETE.

Example: pre-maintenance snapshot workflow
A cron job fires every night at 2am → it calls the VPS API's POST snapshot endpoint → then runs your maintenance script → if something breaks, you call restore snapshot to roll back. The cron job decides the timing; the API does the actual work.
Check off before you automate
Store the API token securely — never hardcode it in a script you'll share
Set a token expiration date instead of a permanent, never-expiring key
Test with a GET request first before running any POST/PUT/DELETE call
Remember: only one snapshot slot exists — a new one silently replaces the old
Handle 401 (bad/missing token) and 429 (rate limit) responses gracefully in your script
0 / 5 checked
Quiz