[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M792YF90NA7B7YFW2VDRESAA":3,"skill-same:01M792YF90NA7B7YFW2VDRESAA":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M792YF90NA7B7YFW2VDRESAA","lokalise-performance-tuning",null,"Optimize Lokalise API performance with caching, pagination, and bulk operations.\nUse when experiencing slow API responses, implementing caching strategies,\nor optimizing request throughput for Lokalise integrations.\nTrigger with phrases like \"lokalise performance\", \"optimize lokalise\",\n\"lokalise latency\", \"lokalise caching\", \"lokalise slow\", \"lokalise batch\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--lokalise-pack--lokalise-performance-tuning\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: lokalise-performance-tuning\ndescription: |\n  Optimize Lokalise API performance with caching, pagination, and bulk operations.\n  Use when experiencing slow API responses, implementing caching strategies,\n  or optimizing request throughput for Lokalise integrations.\n  Trigger with phrases like \"lokalise performance\", \"optimize lokalise\",\n  \"lokalise latency\", \"lokalise caching\", \"lokalise slow\", \"lokalise batch\".\nallowed-tools: Read, Write, Edit, Bash(npm:*), Bash(node:*), Bash(curl:*), Bash(jq:*), Grep\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code, codex, openclaw\ntags: [saas, lokalise, api, performance]\n---\n# Lokalise Performance Tuning\n\n## Overview\n\nOptimize Lokalise API throughput for translation pipelines by implementing cursor pagination, local caching, batch key operations (500\u002Frequest), request throttling under the 6 req\u002Fs rate limit, and selective language downloads.\n\n## Prerequisites\n\n- `@lokalise\u002Fnode-api` SDK v9+ (ESM) or REST API access\n- `LOKALISE_API_TOKEN` environment variable set\n- Understanding of project size (key count, language count) to calibrate batch sizes\n- Optional: Redis or LRU cache library for persistent caching\n\n## Instructions\n\n### Step 1: Use Cursor Pagination for Large Datasets\n\nCursor pagination is significantly faster than offset pagination for projects with 5K+ keys. Offset pagination degrades as page numbers increase because the server must skip rows; cursor pagination uses a pointer.\n\n```typescript\nimport { LokaliseApi } from '@lokalise\u002Fnode-api';\nconst lok = new LokaliseApi({ apiKey: process.env.LOKALISE_API_TOKEN! });\n\n\u002F\u002F Generator that yields all keys using cursor pagination\nasync function* getAllKeys(projectId: string) {\n  let cursor: string | undefined;\n  do {\n    const result = await lok.keys().list({\n      project_id: projectId,\n      limit: 500,              \u002F\u002F Maximum allowed per request\n      pagination: 'cursor',\n      cursor,\n    });\n    for (const key of result.items) yield key;\n    cursor = result.hasNextCursor() ? result.nextCursor : undefined;\n  } while (cursor);\n}\n\n\u002F\u002F Usage: 10,000 keys = 20 API calls (vs 100 with default limit=100)\nlet count = 0;\nfor await (const key of getAllKeys('PROJECT_ID')) {\n  count++;\n}\nconsole.log(`Fetched ${count} keys`);\n```\n\n**Offset pagination comparison (avoid for large projects):**\n\n| Keys | Offset (limit=100) | Cursor (limit=500) | Time saved |\n|------|--------------------|--------------------|-----------|\n| 1,000 | 10 requests | 2 requests | 80% |\n| 10,000 | 100 requests | 20 requests | 80% |\n| 50,000 | 500 requests (~84s) | 100 requests (~17s) | 80% |\n\n### Step 2: Cache Translation Downloads Locally\n\nTranslation file downloads are the most expensive Lokalise operation. Cache them locally and use project `last_activity` timestamps to invalidate.\n\n```typescript\nimport { LokaliseApi } from '@lokalise\u002Fnode-api';\nimport { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';\n\nconst lok = new LokaliseApi({ apiKey: process.env.LOKALISE_API_TOKEN! });\nconst CACHE_DIR = '.lokalise-cache';\n\ninterface CacheEntry {\n  url: string;\n  timestamp: string;\n  languages: string[];\n}\n\nfunction getCachePath(projectId: string, langIso: string): string {\n  return `${CACHE_DIR}\u002F${projectId}\u002F${langIso}.json`;\n}\n\nfunction getMetaPath(projectId: string): string {\n  return `${CACHE_DIR}\u002F${projectId}\u002Fmeta.json`;\n}\n\nasync function downloadWithCache(projectId: string, langIso: string, format = 'json') {\n  mkdirSync(`${CACHE_DIR}\u002F${projectId}`, { recursive: true });\n  const cachePath = getCachePath(projectId, langIso);\n  const metaPath = getMetaPath(projectId);\n\n  \u002F\u002F Check if project was modified since last cache\n  const project = await lok.projects().get(projectId);\n  const lastActivity = project.statistics?.last_activity ?? project.created_at;\n\n  if (existsSync(metaPath)) {\n    const meta: CacheEntry = JSON.parse(readFileSync(metaPath, 'utf8'));\n    if (meta.timestamp === lastActivity && existsSync(cachePath)) {\n      console.log(`Cache hit: ${langIso} (unchanged since ${lastActivity})`);\n      return JSON.parse(readFileSync(cachePath, 'utf8'));\n    }\n  }\n\n  \u002F\u002F Cache miss — download fresh\n  const bundle = await lok.files().download(projectId, {\n    format,\n    filter_langs: [langIso],\n    original_filenames: false,\n  });\n\n  \u002F\u002F bundle.bundle_url contains a temporary download URL\n  const response = await fetch(bundle.bundle_url);\n  const data = await response.arrayBuffer();\n\n  writeFileSync(cachePath, Buffer.from(data));\n  writeFileSync(metaPath, JSON.stringify({\n    url: bundle.bundle_url,\n    timestamp: lastActivity,\n    languages: [langIso],\n  }));\n\n  console.log(`Cache miss: downloaded ${langIso} (${data.byteLength} bytes)`);\n  return data;\n}\n```\n\n### Step 3: Batch Key Operations\n\nLokalise supports creating, updating, and deleting up to 500 keys per request. Always batch instead of making individual requests.\n\n```typescript\n\u002F\u002F Bulk create keys — 500 per batch with rate limit awareness\nasync function createKeysBatched(projectId: string, keys: any[]) {\n  const BATCH_SIZE = 500;\n  const results = [];\n\n  for (let i = 0; i \u003C keys.length; i += BATCH_SIZE) {\n    const batch = keys.slice(i, i + BATCH_SIZE);\n    const result = await lok.keys().create({\n      project_id: projectId,\n      keys: batch,\n    });\n    results.push(...result.items);\n    console.log(`Batch ${Math.floor(i \u002F BATCH_SIZE) + 1}: created ${result.items.length} keys`);\n    await new Promise(r => setTimeout(r, 200)); \u002F\u002F Stay under 6 req\u002Fs\n  }\n\n  return results;\n}\n\n\u002F\u002F Bulk update keys — same 500-key batch limit\nasync function updateKeysBatched(projectId: string, updates: Array\u003C{key_id: number; [k: string]: any}>) {\n  const BATCH_SIZE = 500;\n  for (let i = 0; i \u003C updates.length; i += BATCH_SIZE) {\n    const batch = updates.slice(i, i + BATCH_SIZE);\n    await lok.keys().bulk_update({\n      project_id: projectId,\n      keys: batch,\n    });\n    await new Promise(r => setTimeout(r, 200));\n  }\n}\n\n\u002F\u002F Bulk delete — up to 500 key IDs per request\nasync function deleteKeysBatched(projectId: string, keyIds: number[]) {\n  const BATCH_SIZE = 500;\n  for (let i = 0; i \u003C keyIds.length; i += BATCH_SIZE) {\n    const batch = keyIds.slice(i, i + BATCH_SIZE);\n    await lok.keys().bulk_delete({\n      project_id: projectId,\n      keys: batch,\n    });\n    await new Promise(r => setTimeout(r, 200));\n  }\n}\n\n\u002F\u002F 2,000 keys: 4 batched requests instead of 2,000 individual ones\n```\n\n### Step 4: Implement Request Throttling\n\nA proper request queue prevents `429 Too Many Requests` errors and makes your integration resilient under load.\n\n```typescript\nimport PQueue from 'p-queue';\n\n\u002F\u002F Lokalise rate limit: 6 requests\u002Fsecond\n\u002F\u002F Use 5 concurrent with 1s interval for safety margin\nconst queue = new PQueue({\n  concurrency: 5,\n  interval: 1000,\n  intervalCap: 5,\n});\n\nasync function throttledRequest\u003CT>(fn: () => Promise\u003CT>): Promise\u003CT> {\n  return queue.add(fn) as Promise\u003CT>;\n}\n\n\u002F\u002F All API calls go through the queue automatically\nconst project = await throttledRequest(() => lok.projects().get(projectId));\nconst keys = await throttledRequest(() => lok.keys().list({\n  project_id: projectId,\n  limit: 500,\n  pagination: 'cursor',\n}));\n\n\u002F\u002F Works for parallel operations too — queue enforces the rate limit\nconst projectIds = ['PROJ_1', 'PROJ_2', 'PROJ_3', 'PROJ_4', 'PROJ_5'];\nconst allProjects = await Promise.all(\n  projectIds.map(id => throttledRequest(() => lok.projects().get(id)))\n);\n```\n\n### Step 5: Async File Operations with Webhooks\n\nFile uploads and downloads are processed asynchronously by Lokalise. Instead of polling the process status endpoint, use webhooks to get notified when processing completes.\n\n```bash\nset -euo pipefail\n# Set up a webhook for file operation events\ncurl -s -X POST \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects\u002F${PROJECT_ID}\u002Fwebhooks\" \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"url\": \"https:\u002F\u002Fhooks.company.com\u002Flokalise\",\n    \"events\": [\n      \"project.imported\",\n      \"project.exported\",\n      \"project.keys_added\"\n    ]\n  }' | jq '{webhook_id: .webhook.webhook_id, url: .webhook.url, events: .webhook.events}'\n```\n\n**If you must poll (no webhook endpoint available):**\n\n```typescript\nasync function waitForProcess(projectId: string, processId: string, timeoutMs = 120_000) {\n  const start = Date.now();\n  while (Date.now() - start \u003C timeoutMs) {\n    const proc = await throttledRequest(() =>\n      lok.queuedProcesses().get(projectId, processId)\n    );\n    if (proc.status === 'finished') return proc;\n    if (proc.status === 'cancelled' || proc.status === 'failed') {\n      throw new Error(`Process ${processId} ${proc.status}: ${proc.message}`);\n    }\n    await new Promise(r => setTimeout(r, 2000)); \u002F\u002F Poll every 2s\n  }\n  throw new Error(`Process ${processId} timed out after ${timeoutMs}ms`);\n}\n```\n\n### Step 6: Selective Language Downloads (Delta Exports)\n\nDownloading all languages when you only need one wastes bandwidth and API time. Always filter by language and, when possible, by modification timestamp.\n\n```typescript\n\u002F\u002F Download only changed translations since last sync\nasync function downloadDelta(projectId: string, langIso: string, sinceTimestamp: string) {\n  \u002F\u002F Filter keys modified after the given timestamp\n  const keys = await lok.keys().list({\n    project_id: projectId,\n    limit: 500,\n    pagination: 'cursor',\n    filter_translation_lang_ids: langIso,\n    \u002F\u002F Unfortunately, Lokalise doesn't support filter_modified_after on keys endpoint.\n    \u002F\u002F Workaround: download full file and diff locally, or use webhooks for real-time sync.\n  });\n\n  return keys.items;\n}\n\n\u002F\u002F Download a single language file instead of all languages\nasync function downloadSingleLanguage(projectId: string, langIso: string) {\n  const result = await lok.files().download(projectId, {\n    format: 'json',\n    filter_langs: [langIso],        \u002F\u002F Only this language\n    original_filenames: false,       \u002F\u002F Flat structure\n    bundle_structure: '%LANG_ISO%.%FORMAT%', \u002F\u002F e.g., fr.json\n    export_empty_as: 'base',         \u002F\u002F Fall back to base language for untranslated\n    include_tags: ['production'],    \u002F\u002F Only production-tagged keys\n  });\n  return result.bundle_url;\n}\n```\n\n### Step 7: Measure and Benchmark\n\n```bash\nset -euo pipefail\n# Benchmark API response times across endpoints\necho \"=== Lokalise API Benchmarks ===\"\n\necho -n \"Projects list: \"\ncurl -s -o \u002Fdev\u002Fnull -w \"%{time_total}s\" \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects?limit=10\"\necho \"\"\n\necho -n \"Keys list (limit=500): \"\ncurl -s -o \u002Fdev\u002Fnull -w \"%{time_total}s\" \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects\u002F${PROJECT_ID}\u002Fkeys?limit=500\"\necho \"\"\n\necho -n \"File download trigger: \"\ncurl -s -o \u002Fdev\u002Fnull -w \"%{time_total}s\" \\\n  -X POST -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects\u002F${PROJECT_ID}\u002Ffiles\u002Fdownload\" \\\n  -d '{\"format\":\"json\",\"filter_langs\":[\"en\"],\"original_filenames\":false}'\necho \"\"\n\necho -n \"Rate limit headers: \"\ncurl -s -D - -o \u002Fdev\u002Fnull \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects?limit=1\" \\\n  | grep -i x-ratelimit\n```\n\n## Output\n\n- Cursor pagination implemented for all list operations (80% fewer API calls)\n- Translation download cache with timestamp-based invalidation\n- Batch key operations (create\u002Fupdate\u002Fdelete) using 500-key batches\n- Request queue with PQueue throttling at 5 req\u002Fs (safety margin under 6 req\u002Fs limit)\n- Webhooks configured for async file operations (replacing polling)\n- Selective language downloads reducing bandwidth and processing time\n- Benchmark results for baseline performance measurement\n\n## Error Handling\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| `429 Too Many Requests` | Exceeded 6 req\u002Fs global rate limit | Use PQueue throttling (Step 4), retry with exponential backoff |\n| Slow file downloads | Large project with 50+ languages | Filter by `filter_langs` to download one language at a time |\n| Pagination timeout | Offset pagination on 50K+ key projects | Switch to cursor pagination (Step 1) |\n| Bulk create partial failure | Network timeout on large batch | Reduce batch size from 500 to 200 and add retry logic per batch |\n| Cache stale after team edits | `last_activity` not granular enough | Reduce cache TTL or use webhooks to invalidate on `project.translation_updated` |\n| `bundle_url` expired | Download URL only valid for ~30 minutes | Fetch the URL and download immediately; do not store URLs for later |\n\n## Examples\n\n### Quick Rate Limit Check\n\n```bash\nset -euo pipefail\n# See how much rate limit headroom you have right now\ncurl -s -D - -o \u002Fdev\u002Fnull \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fsystem\u002Flanguages?limit=1\" 2>\u002Fdev\u002Fnull \\\n  | grep -iE 'x-ratelimit' | while read -r line; do echo \"  $line\"; done\n```\n\n## Resources\n\n- [Lokalise Rate Limits](https:\u002F\u002Fdevelopers.lokalise.com\u002Fdocs\u002Fapi-rate-limits)\n- [Cursor Pagination Docs](https:\u002F\u002Fdevelopers.lokalise.com\u002Fdocs\u002Fcursor-pagination)\n- [File Download API](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fdownload-files)\n- [Bulk Key Operations](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fcreate-keys)\n- [Webhook Events](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fwebhook-events)\n- [p-queue (npm)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fp-queue)\n\n## Next Steps\n\n- For debugging performance issues, collect diagnostics with `lokalise-debug-bundle`.\n- For SDK upgrade to get latest pagination improvements, see `lokalise-upgrade-migration`.\n- For setting up CI pipelines with optimized API usage, see `lokalise-ci-integration`.\n","# Lokalise Performance Tuning\n\n## Overview\n\nOptimize Lokalise API throughput for translation pipelines by implementing cursor pagination, local caching, batch key operations (500\u002Frequest), request throttling under the 6 req\u002Fs rate limit, and selective language downloads.\n\n## Prerequisites\n\n- `@lokalise\u002Fnode-api` SDK v9+ (ESM) or REST API access\n- `LOKALISE_API_TOKEN` environment variable set\n- Understanding of project size (key count, language count) to calibrate batch sizes\n- Optional: Redis or LRU cache library for persistent caching\n\n## Instructions\n\n### Step 1: Use Cursor Pagination for Large Datasets\n\nCursor pagination is significantly faster than offset pagination for projects with 5K+ keys. Offset pagination degrades as page numbers increase because the server must skip rows; cursor pagination uses a pointer.\n\n```typescript\nimport { LokaliseApi } from '@lokalise\u002Fnode-api';\nconst lok = new LokaliseApi({ apiKey: process.env.LOKALISE_API_TOKEN! });\n\n\u002F\u002F Generator that yields all keys using cursor pagination\nasync function* getAllKeys(projectId: string) {\n  let cursor: string | undefined;\n  do {\n    const result = await lok.keys().list({\n      project_id: projectId,\n      limit: 500,              \u002F\u002F Maximum allowed per request\n      pagination: 'cursor',\n      cursor,\n    });\n    for (const key of result.items) yield key;\n    cursor = result.hasNextCursor() ? result.nextCursor : undefined;\n  } while (cursor);\n}\n\n\u002F\u002F Usage: 10,000 keys = 20 API calls (vs 100 with default limit=100)\nlet count = 0;\nfor await (const key of getAllKeys('PROJECT_ID')) {\n  count++;\n}\nconsole.log(`Fetched ${count} keys`);\n```\n\n**Offset pagination comparison (avoid for large projects):**\n\n| Keys | Offset (limit=100) | Cursor (limit=500) | Time saved |\n|------|--------------------|--------------------|-----------|\n| 1,000 | 10 requests | 2 requests | 80% |\n| 10,000 | 100 requests | 20 requests | 80% |\n| 50,000 | 500 requests (~84s) | 100 requests (~17s) | 80% |\n\n### Step 2: Cache Translation Downloads Locally\n\nTranslation file downloads are the most expensive Lokalise operation. Cache them locally and use project `last_activity` timestamps to invalidate.\n\n```typescript\nimport { LokaliseApi } from '@lokalise\u002Fnode-api';\nimport { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';\n\nconst lok = new LokaliseApi({ apiKey: process.env.LOKALISE_API_TOKEN! });\nconst CACHE_DIR = '.lokalise-cache';\n\ninterface CacheEntry {\n  url: string;\n  timestamp: string;\n  languages: string[];\n}\n\nfunction getCachePath(projectId: string, langIso: string): string {\n  return `${CACHE_DIR}\u002F${projectId}\u002F${langIso}.json`;\n}\n\nfunction getMetaPath(projectId: string): string {\n  return `${CACHE_DIR}\u002F${projectId}\u002Fmeta.json`;\n}\n\nasync function downloadWithCache(projectId: string, langIso: string, format = 'json') {\n  mkdirSync(`${CACHE_DIR}\u002F${projectId}`, { recursive: true });\n  const cachePath = getCachePath(projectId, langIso);\n  const metaPath = getMetaPath(projectId);\n\n  \u002F\u002F Check if project was modified since last cache\n  const project = await lok.projects().get(projectId);\n  const lastActivity = project.statistics?.last_activity ?? project.created_at;\n\n  if (existsSync(metaPath)) {\n    const meta: CacheEntry = JSON.parse(readFileSync(metaPath, 'utf8'));\n    if (meta.timestamp === lastActivity && existsSync(cachePath)) {\n      console.log(`Cache hit: ${langIso} (unchanged since ${lastActivity})`);\n      return JSON.parse(readFileSync(cachePath, 'utf8'));\n    }\n  }\n\n  \u002F\u002F Cache miss — download fresh\n  const bundle = await lok.files().download(projectId, {\n    format,\n    filter_langs: [langIso],\n    original_filenames: false,\n  });\n\n  \u002F\u002F bundle.bundle_url contains a temporary download URL\n  const response = await fetch(bundle.bundle_url);\n  const data = await response.arrayBuffer();\n\n  writeFileSync(cachePath, Buffer.from(data));\n  writeFileSync(metaPath, JSON.stringify({\n    url: bundle.bundle_url,\n    timestamp: lastActivity,\n    languages: [langIso],\n  }));\n\n  console.log(`Cache miss: downloaded ${langIso} (${data.byteLength} bytes)`);\n  return data;\n}\n```\n\n### Step 3: Batch Key Operations\n\nLokalise supports creating, updating, and deleting up to 500 keys per request. Always batch instead of making individual requests.\n\n```typescript\n\u002F\u002F Bulk create keys — 500 per batch with rate limit awareness\nasync function createKeysBatched(projectId: string, keys: any[]) {\n  const BATCH_SIZE = 500;\n  const results = [];\n\n  for (let i = 0; i \u003C keys.length; i += BATCH_SIZE) {\n    const batch = keys.slice(i, i + BATCH_SIZE);\n    const result = await lok.keys().create({\n      project_id: projectId,\n      keys: batch,\n    });\n    results.push(...result.items);\n    console.log(`Batch ${Math.floor(i \u002F BATCH_SIZE) + 1}: created ${result.items.length} keys`);\n    await new Promise(r => setTimeout(r, 200)); \u002F\u002F Stay under 6 req\u002Fs\n  }\n\n  return results;\n}\n\n\u002F\u002F Bulk update keys — same 500-key batch limit\nasync function updateKeysBatched(projectId: string, updates: Array\u003C{key_id: number; [k: string]: any}>) {\n  const BATCH_SIZE = 500;\n  for (let i = 0; i \u003C updates.length; i += BATCH_SIZE) {\n    const batch = updates.slice(i, i + BATCH_SIZE);\n    await lok.keys().bulk_update({\n      project_id: projectId,\n      keys: batch,\n    });\n    await new Promise(r => setTimeout(r, 200));\n  }\n}\n\n\u002F\u002F Bulk delete — up to 500 key IDs per request\nasync function deleteKeysBatched(projectId: string, keyIds: number[]) {\n  const BATCH_SIZE = 500;\n  for (let i = 0; i \u003C keyIds.length; i += BATCH_SIZE) {\n    const batch = keyIds.slice(i, i + BATCH_SIZE);\n    await lok.keys().bulk_delete({\n      project_id: projectId,\n      keys: batch,\n    });\n    await new Promise(r => setTimeout(r, 200));\n  }\n}\n\n\u002F\u002F 2,000 keys: 4 batched requests instead of 2,000 individual ones\n```\n\n### Step 4: Implement Request Throttling\n\nA proper request queue prevents `429 Too Many Requests` errors and makes your integration resilient under load.\n\n```typescript\nimport PQueue from 'p-queue';\n\n\u002F\u002F Lokalise rate limit: 6 requests\u002Fsecond\n\u002F\u002F Use 5 concurrent with 1s interval for safety margin\nconst queue = new PQueue({\n  concurrency: 5,\n  interval: 1000,\n  intervalCap: 5,\n});\n\nasync function throttledRequest\u003CT>(fn: () => Promise\u003CT>): Promise\u003CT> {\n  return queue.add(fn) as Promise\u003CT>;\n}\n\n\u002F\u002F All API calls go through the queue automatically\nconst project = await throttledRequest(() => lok.projects().get(projectId));\nconst keys = await throttledRequest(() => lok.keys().list({\n  project_id: projectId,\n  limit: 500,\n  pagination: 'cursor',\n}));\n\n\u002F\u002F Works for parallel operations too — queue enforces the rate limit\nconst projectIds = ['PROJ_1', 'PROJ_2', 'PROJ_3', 'PROJ_4', 'PROJ_5'];\nconst allProjects = await Promise.all(\n  projectIds.map(id => throttledRequest(() => lok.projects().get(id)))\n);\n```\n\n### Step 5: Async File Operations with Webhooks\n\nFile uploads and downloads are processed asynchronously by Lokalise. Instead of polling the process status endpoint, use webhooks to get notified when processing completes.\n\n```bash\nset -euo pipefail\n# Set up a webhook for file operation events\ncurl -s -X POST \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects\u002F${PROJECT_ID}\u002Fwebhooks\" \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"url\": \"https:\u002F\u002Fhooks.company.com\u002Flokalise\",\n    \"events\": [\n      \"project.imported\",\n      \"project.exported\",\n      \"project.keys_added\"\n    ]\n  }' | jq '{webhook_id: .webhook.webhook_id, url: .webhook.url, events: .webhook.events}'\n```\n\n**If you must poll (no webhook endpoint available):**\n\n```typescript\nasync function waitForProcess(projectId: string, processId: string, timeoutMs = 120_000) {\n  const start = Date.now();\n  while (Date.now() - start \u003C timeoutMs) {\n    const proc = await throttledRequest(() =>\n      lok.queuedProcesses().get(projectId, processId)\n    );\n    if (proc.status === 'finished') return proc;\n    if (proc.status === 'cancelled' || proc.status === 'failed') {\n      throw new Error(`Process ${processId} ${proc.status}: ${proc.message}`);\n    }\n    await new Promise(r => setTimeout(r, 2000)); \u002F\u002F Poll every 2s\n  }\n  throw new Error(`Process ${processId} timed out after ${timeoutMs}ms`);\n}\n```\n\n### Step 6: Selective Language Downloads (Delta Exports)\n\nDownloading all languages when you only need one wastes bandwidth and API time. Always filter by language and, when possible, by modification timestamp.\n\n```typescript\n\u002F\u002F Download only changed translations since last sync\nasync function downloadDelta(projectId: string, langIso: string, sinceTimestamp: string) {\n  \u002F\u002F Filter keys modified after the given timestamp\n  const keys = await lok.keys().list({\n    project_id: projectId,\n    limit: 500,\n    pagination: 'cursor',\n    filter_translation_lang_ids: langIso,\n    \u002F\u002F Unfortunately, Lokalise doesn't support filter_modified_after on keys endpoint.\n    \u002F\u002F Workaround: download full file and diff locally, or use webhooks for real-time sync.\n  });\n\n  return keys.items;\n}\n\n\u002F\u002F Download a single language file instead of all languages\nasync function downloadSingleLanguage(projectId: string, langIso: string) {\n  const result = await lok.files().download(projectId, {\n    format: 'json',\n    filter_langs: [langIso],        \u002F\u002F Only this language\n    original_filenames: false,       \u002F\u002F Flat structure\n    bundle_structure: '%LANG_ISO%.%FORMAT%', \u002F\u002F e.g., fr.json\n    export_empty_as: 'base',         \u002F\u002F Fall back to base language for untranslated\n    include_tags: ['production'],    \u002F\u002F Only production-tagged keys\n  });\n  return result.bundle_url;\n}\n```\n\n### Step 7: Measure and Benchmark\n\n```bash\nset -euo pipefail\n# Benchmark API response times across endpoints\necho \"=== Lokalise API Benchmarks ===\"\n\necho -n \"Projects list: \"\ncurl -s -o \u002Fdev\u002Fnull -w \"%{time_total}s\" \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects?limit=10\"\necho \"\"\n\necho -n \"Keys list (limit=500): \"\ncurl -s -o \u002Fdev\u002Fnull -w \"%{time_total}s\" \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects\u002F${PROJECT_ID}\u002Fkeys?limit=500\"\necho \"\"\n\necho -n \"File download trigger: \"\ncurl -s -o \u002Fdev\u002Fnull -w \"%{time_total}s\" \\\n  -X POST -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects\u002F${PROJECT_ID}\u002Ffiles\u002Fdownload\" \\\n  -d '{\"format\":\"json\",\"filter_langs\":[\"en\"],\"original_filenames\":false}'\necho \"\"\n\necho -n \"Rate limit headers: \"\ncurl -s -D - -o \u002Fdev\u002Fnull \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fprojects?limit=1\" \\\n  | grep -i x-ratelimit\n```\n\n## Output\n\n- Cursor pagination implemented for all list operations (80% fewer API calls)\n- Translation download cache with timestamp-based invalidation\n- Batch key operations (create\u002Fupdate\u002Fdelete) using 500-key batches\n- Request queue with PQueue throttling at 5 req\u002Fs (safety margin under 6 req\u002Fs limit)\n- Webhooks configured for async file operations (replacing polling)\n- Selective language downloads reducing bandwidth and processing time\n- Benchmark results for baseline performance measurement\n\n## Error Handling\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| `429 Too Many Requests` | Exceeded 6 req\u002Fs global rate limit | Use PQueue throttling (Step 4), retry with exponential backoff |\n| Slow file downloads | Large project with 50+ languages | Filter by `filter_langs` to download one language at a time |\n| Pagination timeout | Offset pagination on 50K+ key projects | Switch to cursor pagination (Step 1) |\n| Bulk create partial failure | Network timeout on large batch | Reduce batch size from 500 to 200 and add retry logic per batch |\n| Cache stale after team edits | `last_activity` not granular enough | Reduce cache TTL or use webhooks to invalidate on `project.translation_updated` |\n| `bundle_url` expired | Download URL only valid for ~30 minutes | Fetch the URL and download immediately; do not store URLs for later |\n\n## Examples\n\n### Quick Rate Limit Check\n\n```bash\nset -euo pipefail\n# See how much rate limit headroom you have right now\ncurl -s -D - -o \u002Fdev\u002Fnull \\\n  -H \"X-Api-Token: ${LOKALISE_API_TOKEN}\" \\\n  \"https:\u002F\u002Fapi.lokalise.com\u002Fapi2\u002Fsystem\u002Flanguages?limit=1\" 2>\u002Fdev\u002Fnull \\\n  | grep -iE 'x-ratelimit' | while read -r line; do echo \"  $line\"; done\n```\n\n## Resources\n\n- [Lokalise Rate Limits](https:\u002F\u002Fdevelopers.lokalise.com\u002Fdocs\u002Fapi-rate-limits)\n- [Cursor Pagination Docs](https:\u002F\u002Fdevelopers.lokalise.com\u002Fdocs\u002Fcursor-pagination)\n- [File Download API](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fdownload-files)\n- [Bulk Key Operations](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fcreate-keys)\n- [Webhook Events](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fwebhook-events)\n- [p-queue (npm)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fp-queue)\n\n## Next Steps\n\n- For debugging performance issues, collect diagnostics with `lokalise-debug-bundle`.\n- For SDK upgrade to get latest pagination improvements, see `lokalise-upgrade-migration`.\n- For setting up CI pipelines with optimized API usage, see `lokalise-ci-integration`.\n",{"name":5,"tags":24,"author":29,"license":15,"version":30,"description":31,"allowed-tools":32,"compatible-with":33},[25,26,27,28],"saas","lokalise","api","performance","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Optimize Lokalise API performance with caching, pagination, and bulk operations.\nUse when experiencing slow API responses, implementing caching strategies,\nor optimizing request throughput for Lokalise integrations.\nTrigger with phrases like \"lokalise performance\", \"optimize lokalise\",\n\"lokalise latency\", \"lokalise caching\", \"lokalise slow\", \"lokalise batch\".\n","Read, Write, Edit, Bash(npm:*), Bash(node:*), Bash(curl:*), Bash(jq:*), Grep","claude-code, codex, openclaw","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--lokalise-pack--lokalise-performance-tuning",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill lokalise-performance-tuning",{"tool":49,"command":50},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill lokalise-performance-tuning",{"tool":52,"command":53},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill lokalise-performance-tuning","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--lokalise-pack--lokalise-performance-tuning\u002FSKILL.md",true,[],[58,65,72,79,86,94],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]