Need to generate secure yet memorable passwords? This guide covers everything about passphrase generation via API, including why passphrases are more secure, word selection algorithms, and implementation examples in multiple programming languages.
What is a Passphrase?
A passphrase is a sequence of random words used as a password. Instead of complex strings like "K#9mP!2x", passphrases use memorable words like "correct-horse-battery-staple", which is both more secure and easier to remember.
Example: timber-falcon-garden-crystal (4 words, ~52 bits of entropy)
Why Use Passphrases?
Advantages of passphrases over traditional passwords:
Higher Entropy
A 4-word passphrase from a 7,776-word list has more entropy than most complex 8-character passwords.
Memorability
Humans remember words better than random character strings.
Typing Ease
Words are easier to type, especially on mobile devices.
Using the Passphrase Generator API
TinyFn provides a secure endpoint to generate passphrases:
GET https://api.tinyfn.io/v1/generate/passphrase?words=4
Headers: X-API-Key: your-api-key
{
"passphrase": "timber-falcon-garden-crystal",
"words": ["timber", "falcon", "garden", "crystal"],
"word_count": 4,
"separator": "-",
"entropy_bits": 51.7
}
Parameters
| Parameter | Type | Description |
|---|---|---|
words |
integer | Number of words (default: 4, min: 3, max: 10) |
separator |
string | Word separator (default: -) |
capitalize |
boolean | Capitalize first letter of each word (default: false) |
include_number |
boolean | Add a random number (default: false) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/generate/passphrase?words=5&separator=_',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const { passphrase } = await response.json();
console.log(passphrase); // timber_falcon_garden_crystal_ocean
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/generate/passphrase',
params={'words': 5, 'separator': '_'},
headers={'X-API-Key': 'your-api-key'}
)
passphrase = response.json()['passphrase']
print(passphrase) # timber_falcon_garden_crystal_ocean
cURL
curl "https://api.tinyfn.io/v1/generate/passphrase?words=5&separator=_" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Master Passwords: Generate strong master passwords for password managers
- Account Recovery: Create memorable recovery phrases
- WiFi Passwords: Generate easy-to-share network passwords
- API Keys: Create human-readable API keys
- Temporary Access: Generate one-time access codes
Best Practices
- Use 4+ words: Minimum 4 words for adequate security
- Don't modify: Don't substitute letters with numbers (weakens entropy)
- Keep random: Don't reject passphrases because they "look weird"
- Store securely: Use a password manager to store passphrases
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-generate": {
"url": "https://api.tinyfn.io/mcp/generate/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all generator tools available via MCP in our Generator MCP Tools for AI Agents guide.
Try the Passphrase Generator API
Get your free API key and start generating secure passphrases in seconds.
Get Free API Key