JSPM

devcodes-meme-generator

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 428
  • Score
    100M100P100Q75974F
  • License MIT

Turn any image into a meme or generate from 200+ templates. Zero API key required.

Package Exports

  • devcodes-meme-generator
  • devcodes-meme-generator/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (devcodes-meme-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

devcodes-meme-generator

Generate memes from 200+ templates, add text to any image URL, or fetch real memes from Reddit — zero API keys required.

Built on top of devcodes-http-tool and powered by memegen.link + meme-api.com.

Install

npm install devcodes-meme-generator devcodes-http-tool

Usage

Quick start (default instance)

const { fromTemplate, fromImage, fromSubreddit } = require('devcodes-meme-generator');

// Generate from a named template with text
const meme = await fromTemplate('buzz', ['When you', 'write clean code']);
console.log(meme.url); // https://api.memegen.link/images/buzz/...

// Add text to any image URL
const custom = fromImage('https://example.com/cat.jpg', ['top text', 'bottom text']);
console.log(custom.url);

// Fetch a real meme from Reddit (no text needed)
const reddit = await fromSubreddit('panda');
console.log(reddit.title, reddit.url);

Custom instance

const { MemeClient } = require('devcodes-meme-generator');

const meme = new MemeClient({ timeout: 5000 });

// Search for templates
const results = await meme.searchTemplates('drake');
console.log(results[0].id); // "drake"

// Generate with top/bottom text
const { url } = await meme.fromTemplate('drake', ['Using Axios', 'Using devcodes-http-tool']);

// Custom image overlay
const { url: custom } = meme.fromImage('https://i.imgur.com/abc.jpg', ['top', 'bottom']);

// Reddit fetch — safe subreddits only
const post = await meme.fromSubreddit('dankmemes');
console.log(post.title, post.url, post.ups);

TypeScript

import { MemeClient, fromTemplate, fromSubreddit } from 'devcodes-meme-generator';
import type { MemeResult, SubredditMemeResult } from 'devcodes-meme-generator';

const result: MemeResult = await fromTemplate('panda', ['nobody:', 'me at 3am']);
const post: SubredditMemeResult = await fromSubreddit('programmerhumor');

API

fromTemplate(template, lines?)

Generates a meme image URL from a template name or ID.

  • template — template ID (e.g. "buzz") or search term (e.g. "panda")
  • lines — array of text strings, top to bottom. Omit for default template text.
  • Returns Promise<MemeResult>

fromImage(imageUrl, lines?)

Overlays meme text onto any image URL. Synchronous — returns immediately.

  • imageUrl — publicly accessible image URL
  • lines — array of text strings
  • Returns MemeResult

fromSubreddit(subreddit?)

Fetches a random meme post from a safe subreddit. Auto-retries if NSFW.

  • subreddit — one of memes, dankmemes, programmerhumor, me_irl, shitposting, panda. Defaults to memes.
  • Returns Promise<SubredditMemeResult>

MemeClient.searchTemplates(query)

Returns matching templates from memegen.link filtered by keyword.

  • Returns Promise<MemeTemplate[]>

Supported templates (examples)

ID Name
buzz Buzz Lightyear — Everywhere
drake Drake Approves
doge Doge
panda Panda
distracted Distracted Boyfriend
fine This Is Fine
gru Gru's Plan
success Success Kid

Browse all 200+ at api.memegen.link/templates.

Discord bot example

// d!meme panda              → Reddit fetch from r/panda
// d!meme buzz top | bottom  → Template with text
// d!meme https://i.imgur.com/abc.jpg top | bottom → Custom image

const { MemeClient } = require('devcodes-meme-generator');
const meme = new MemeClient();

client.on('messageCreate', async (message) => {
  if (!message.content.startsWith('d!meme')) return;

  const raw     = message.content.slice(6).trim();
  const spaceIdx = raw.indexOf(' ');
  const subject  = spaceIdx === -1 ? raw : raw.slice(0, spaceIdx);
  const lines    = spaceIdx === -1 ? [] : raw.slice(spaceIdx + 1).split('|').map(s => s.trim());

  if (/^https?:\/\//i.test(subject)) {
    const { url } = meme.fromImage(subject, lines);
    await message.reply(url);
  } else if (lines.length === 0) {
    const post = await meme.fromSubreddit(subject);
    await message.reply(post.url);
  } else {
    const { url } = await meme.fromTemplate(subject, lines);
    await message.reply(url);
  }
});

License

MIT © azaresw

Support

Join our Discord for help and updates: discord.gg/ESh2Dp2xX9