Getting started
The FML API gives JSON access to what you find on fmylife.com: published stories, their comments, member profiles and badges. With a member's account, it also lets you vote, comment and post a story.
Get a key
Every request needs an API key, which identifies your application. Sign in with your FML account in My keys and create one: it works right away. If the API is called from a browser, restrict the key to your domain so that nobody can reuse it elsewhere.
Make a request
The API is served at https://www.fmylife.com/api/v2. Send your key in the X-VDM-Api-Key header:
curl -g "https://www.fmylife.com/api/v2/article/list?page[number]=1&page[bypage]=10" \
-H "X-VDM-Api-Key: $API_KEY"Or from JavaScript:
const response = await fetch("https://www.fmylife.com/api/v2/article/123456", {
headers: { "X-VDM-Api-Key": process.env.API_KEY },
});
const { data: story } = await response.json();Response format
Responses are JSON (UTF-8). The result is in data, and meta may hold extra information. badge and badge_display list the badges the member just earned with this request (usually empty):
{
"data": [ … ],
"meta": {},
"badge": [],
"badge_display": []
}Dates use ISO 8601. Lists are paginated with page[number] (starting at 1) and page[bypage]. Filters that take several values use brackets, like status[]=4&status[]=12: with curl, add -g so that it leaves them alone.
Headers
| Header | Purpose |
|---|---|
X-VDM-Api-Key | Your API key. Required on every request, and sent back in the response. |
X-VDM-Api-Token | A signed-in member's token, to act on their behalf (see Signing a member in). |
X-VDM-Uniqid | Without a signed-in member: a stable device id, obtained once from GET /user/uniqid and kept. Required to vote on or report a story: each device only counts once. |
Good practices
- Cache lists for a few minutes instead of fetching them on every view: stories are published a few times a day.
- When you display a story, credit FML and link to the story on fmylife.com.
- Never store a member's password: keep their token only.
