{"record":{"id":"8321fbb6bb87c438","repo":"DIYgod/RSSHub","slug":"google-fonts-api-key-is-required","errorCode":null,"errorMessage":"Google Fonts API key is required.","messagePattern":"Google Fonts API key is required\\.","errorType":"validation","errorClass":"ConfigNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/routes/google/fonts.tsx","lineNumber":53,"sourceCode":"    name: 'Google Fonts',\n    maintainers: ['Fatpandac'],\n    handler,\n    description: `| Newest | Trending | Most popular |  Name | Number of styles |\n| :----: | :------: | :----------: | :---: | :--------------: |\n|  date  | trending |  popularity  | alpha |       style      |\n\n::: warning\nThis route requires API key, therefore it's only available when self-hosting, refer to the [Deploy Guide](https://docs.rsshub.app/deploy/config#route-specific-configurations) for route-specific configurations.\n:::`,\n};\n\nasync function handler(ctx) {\n    const sort = ctx.req.param('sort') ?? 'date';\n    const limit = ctx.req.param('limit') ?? 25;\n\n    const API_KEY = config.google.fontsApiKey;\n    if (!API_KEY) {\n        throw new ConfigNotFoundError('Google Fonts API key is required.');\n    }\n\n    const googleFontsAPI = `https://www.googleapis.com/webfonts/v1/webfonts?sort=${sort}&key=${API_KEY}`;\n\n    const response = await got.get(googleFontsAPI);\n    const data = response.data.items.slice(0, limit);\n\n    return {\n        title: `Google Fonts - ${titleMap[sort]}`,\n        link: 'https://fonts.google.com',\n        item:\n            data &&\n            data.map((item) => ({\n                title: item.family,\n                description: renderDescription(item),\n                link: `https://fonts.google.com/specimen/${item.family.replaceAll(/\\s/g, '+')}`,\n                pubDate: parseDate(item.lastModified, 'YYYY-MM-DD'),\n            })),","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/google/fonts.tsx#L35-L71","documentation":"The Google Fonts route calls the webfonts v1 API, which requires an API key. The handler reads `config.google.fontsApiKey` and throws ConfigNotFoundError if it is falsy. This route is explicitly self-host-only.","triggerScenarios":"Self-hosting without setting the Google Fonts API key env var; the key was cleared from config.","commonSituations":"Fresh deploy missing GOOGLE_FONTS_API_KEY (or the equivalent config path); using the public rsshub.app instance, which does not expose this route.","solutions":["Obtain a Google Fonts API key from Google Cloud Console and set config.google.fontsApiKey (env: GOOGLE_FONTS_API_KEY), then restart.","If you cannot supply a key, this route is unavailable — it is documented as self-host-only.","Confirm the env var name against the route-specific config section of the deploy guide."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { config } from '@/config';\nfunction googleFontsConfigured(): boolean {\n  return Boolean(config.google?.fontsApiKey);\n}","typeGuard":"function googleFontsConfigured(): boolean {\n  return Boolean(config.google?.fontsApiKey);\n}","tryCatchPattern":null,"preventionTips":["Mark the route self-host-only in docs and gate on key presence.","Rotate the API key via your secret manager, not by editing source."],"tags":["config","auth","api-key"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}