Meme API in Python
The Green Screen Memes API is a meme API built for video: over 2,000 reaction meme clips (a shocked cat, a slow-clapping dog, a side-eyeing kid), each on a flat green, blue or red background, most with the meme's own sound, searchable by what happens in them. Not image templates: real clips that play over your own picture or video. This Python script searches it, downloads a clip and renders a vertical meme video over your own picture, with the clip's sound.
The script
Python 3 with requests, and FFmpeg on the machine. It was run against the live API before it went on this page.
# meme.py: make a meme video with the Green Screen Memes API.
# Usage: python meme.py "side eye" background.jpg
import os
import subprocess
import sys
import requests
API = "https://api.greenscreenmemes.app/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['GSM_API_KEY']}"}
KEY_COLORS = {"green": "0x00ff00", "blue": "0x0000ff", "red": "0xff0000"}
def search(query, limit=5):
r = requests.get(f"{API}/memes", params={"q": query, "limit": limit}, headers=HEADERS, timeout=30)
r.raise_for_status()
return r.json()["data"]
def trending(limit=10):
r = requests.get(f"{API}/trending", params={"limit": limit}, headers=HEADERS, timeout=30)
r.raise_for_status()
return r.json()["data"]
def download(clip, path="greenscreen.mp4"):
# The link is signed and expires after about 6 hours: keep the file, not the link.
with requests.get(clip["videoUrl"], stream=True, timeout=60) as r:
r.raise_for_status()
with open(path, "wb") as f:
for chunk in r.iter_content(1 << 16):
f.write(chunk)
return path
def render(clip, clip_path, background, out="meme.mp4"):
# Key the clip's background out and stand it at the bottom of a 1080x1920 frame, keeping its sound.
key = KEY_COLORS.get(clip["chromaKeyColor"])
fg = f"[1:v]chromakey={key}:0.2:0.05,scale=1080:-2[fg]" if key else "[1:v]scale=1080:-2[fg]"
graph = (
"[0:v]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,setsar=1[bg];"
f"{fg};[bg][fg]overlay=(W-w)/2:H-h:shortest=1,format=yuv420p[v]"
)
subprocess.run(
["ffmpeg", "-y", "-loglevel", "error", "-loop", "1", "-i", background, "-i", clip_path,
"-filter_complex", graph, "-map", "[v]", "-map", "1:a?",
"-c:v", "libx264", "-crf", "20", "-c:a", "aac", out],
check=True,
)
return out
if __name__ == "__main__":
query, background = sys.argv[1], sys.argv[2]
clips = search(query)
if not clips:
sys.exit(f'Nothing matched "{query}": try a feeling or an action ("shocked", "happy dance").')
clip = clips[0]
print(f'{clip["name"]}: {clip["durationSeconds"]}s, {clip["chromaKeyColor"]} screen')
print(render(clip, download(clip), background))Run it
pip install requests # and FFmpeg: brew install ffmpeg / apt install ffmpeg
export GSM_API_KEY=gsm_live_... # free key from https://api.greenscreenmemes.app/dashboard
python meme.py "side eye" background.jpgAngry Little Girl Side Eye: 12s, green screen
meme.mp4meme.mp4 is 1080×1920, as long as the clip, with its sound: ready for Shorts, Reels and TikTok. background.jpg can be any photo; for a video background, swap in the FFmpeg guide's video command.
What it does
search()callsGET /v1/memes?q=. Each result has anid,name,description,tags,chromaKeyColor,durationSecondsand signedthumbnailUrlandvideoUrl. Search by feeling or action ("shocked", "slow clap"), not topic.download()saves the MP4. A video link counts as one download the first time it's fetched; playing or seeking the same link again doesn't count again. Thumbnails never count. Links expire after about 6 hours.render()keys out the clip's background color with FFmpeg'schromakeyand stands the clip on the bottom edge of the frame.trending()callsGET /v1/trending: what people use most in the Green Screen Memes app right now, with arank.
>>> import meme
>>> [(c["rank"], c["name"]) for c in meme.trending(3)]
[(1, 'Baboon smirking'), (2, 'Black cat chopping'), (3, 'Cat rolls eyes')]For a caption, add a drawtext filter after format=yuv420p; the FFmpeg guide has one ready.
Errors and limits
Errors come back as JSON with a code and a message you can show:
{ "error": { "code": "quota_exceeded", "message": "This key has used its 50 free video downloads. …" } }401 means a missing or wrong key, 404 an unknown clip, and 429 a plan limit: searching keeps working when downloads run out. These are internet memes: Green Screen Memes makes the green screen versions, but the original footage isn't ours and isn't licensed with the clips, so how you use one is up to you. On Starter and up you can publish videos with them, for yourself or clients. Don't put clips of identifiable people in paid ads, sponsored posts or endorsements; animals, objects and cartoons are fine there. The terms have the details.
Questions
Is there a free meme API key?
Yes. The Sandbox key is free: 50 video downloads to try (one time, not monthly) and 30,000 calls a month for searching and browsing. Paid plans start at $49 a month.
Is this an image meme generator?
No. It's a library of meme video clips with sound. For captioned image templates, an image meme API (Imgflip, memegen) is the better fit; the comparison has the differences.
Which memes are in it?
About 2,000 reaction memes, with new ones every day: GET /v1/trending ranks what people use most in the Green Screen Memes app right now, and GET /v1/tags shows what the library covers.
Can an AI agent use it instead of Python?
Yes: the same key works with the MCP server, so Claude Code, Cursor or Codex can search clips and run the FFmpeg command themselves.
Get a free key
Sandbox: 50 free video downloads and 30,000 calls a month, for building and testing.