Documentation
Caching
How long answers are kept, how to ask for a fresher one, and how to tell them apart.
Answers are kept for a while, and the same request within that time is free. The cache is shared, so a profile anyone read a minute ago is free for you too.
Lifetimes
Each answer is kept as long as what it holds stays current.
| Answer | Kept For |
|---|---|
| Live streams | 1 minute |
| Searches | 2 minutes |
| Comments | 5 minutes |
| Posts and lists | 10 minutes |
| Profiles | 15 minutes |
| Transcripts | 30 days |
Instagram's searches are kept 5 minutes, and trending lists from 2 minutes to an hour, by how fast each one moves.
Ask for a Fresher Answer
Every endpoint takes maxAge, the oldest answer you accept, in seconds. A cached answer older than that is read again from the platform and charged, and maxAge=0 always reads it again. It can only shorten a lifetime, never extend it.
import { SocialAPI } from "@socialapihq/sdk";
const client = new SocialAPI({ apiKey: process.env.SOCIALAPI_API_KEY });
const { data } = await client.tiktok.profile({ handle: "nike", maxAge: 60 });Cached or Fresh
Every answer says in its headers whether it came from the cache.
| Header | Cached | Fresh |
|---|---|---|
X-Cache | HIT | MISS |
X-Cache-Age | Its age | Not sent |
X-Credits-Charged | 0 | The cost |