API vs SDK vs Library: What's the Difference?
These three words get mixed up constantly. Here's the clear difference โ and when you'd use each.
An API is the raw HTTP interface a service exposes. An SDK (Software Development Kit), often just called a ‘client library’, is a package in your programming language that wraps that API in normal functions and objects. The SDK calls the API for you.
The same task, both ways
# Raw API
import requests
tok = requests.post('https://accounts.example.com/oauth/token',
data={'grant_type': 'client_credentials'},
auth=(ID, SECRET)).json()['access_token']
r = requests.get('https://api.example.com/v1/users/42',
headers={'Authorization': f'Bearer {tok}'})
user = r.json()
# SDK
from example import Client
user = Client(ID, SECRET).users.get(42)What a good SDK does for you
- Auth — token fetch, caching and refresh, request signing.
- Pagination — iterate all pages transparently.
- Retries — backoff on 429/5xx built in.
- Types — autocomplete, and errors caught at compile time (typed languages).
- Serialization — native objects in and out instead of hand-built JSON.
- Errors — typed exceptions (
RateLimitError,NotFoundError) instead of status-code checks.
When to use the SDK
- There is an official one, actively maintained, for your language.
- The API has fiddly auth (OAuth, HMAC signing) you’d rather not implement.
- You want to move fast and the extra dependency is acceptable.
When to call the API directly
- No SDK exists, or the only one is unofficial and stale (a common trap — check the last release date and open issues).
- You need a minimal dependency footprint (a serverless function, an edge worker, a security-sensitive service).
- You only use one or two endpoints — a 10-line wrapper beats a 5 MB dependency.
- You need control the SDK doesn’t give — custom retry logic, connection pooling, streaming, an endpoint the SDK hasn’t added yet.
- The SDK lags the API and you need a new feature now.
A middle path
Write your own thin client: one small module that holds the base URL, auth, retry policy and a handful of typed methods for the endpoints you actually use. You get most of the SDK’s ergonomics, none of its bloat, and full control — and swapping the underlying API later touches one file.
FAQ
Is an SDK the same as an API?
No. The API is the HTTP interface on the provider’s servers. An SDK is a library you install that makes calls to that API on your behalf, in your language’s idioms.
Should I use the official SDK or write my own client?
Use the official SDK if it is well maintained and you use many endpoints or complex auth. Write a thin client of your own if you need few endpoints, minimal dependencies, or control the SDK doesn’t offer.
Are unofficial/community SDKs safe to use?
Sometimes — check the last commit date, download count, open issues and whether it tracks recent API changes. A stale wrapper can be worse than calling the API directly.
Do SDKs handle rate limiting and retries?
Good ones do — automatic backoff on 429/5xx, and often transparent pagination and token refresh. Check the SDK’s docs; not all of them do.
Keep going
Try it on a real API
๐ Explore free public APIs
Hundreds of free APIs, searchable by category, with auth & CORS at a glance.
Browse the directory โ