{"id":14595,"library":"gettyimages-api","title":"Getty Images Node.js SDK","description":"The `gettyimages-api` package provides an official Node.js SDK for interacting with the Getty Images API, simplifying common tasks such as searching for creative and editorial images, retrieving image and video metadata, and managing media downloads. It handles credential management, including access token refresh, and employs a fluent API style for constructing requests. The current stable version is 6.5.4, released recently on April 17, 2026. While there isn't a fixed release cadence, updates are regularly pushed, often addressing dependency vulnerabilities, minor bug fixes, or adding small feature enhancements. Key differentiators include its direct support and maintenance by Getty Images, streamlined authentication and token management, and a fluent API design that abstracts away raw HTTP requests and complex URL construction, making API interaction more developer-friendly compared to manual integration.","status":"active","version":"6.5.4","language":"javascript","source_language":"en","source_url":"git://github.com/gettyimages/gettyimages-api_nodejs","tags":["javascript","getty","images","api","sdk"],"install":[{"cmd":"npm install gettyimages-api","lang":"bash","label":"npm"},{"cmd":"yarn add gettyimages-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add gettyimages-api","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required runtime environment, specified in 'engines' field.","package":"node","optional":false}],"imports":[{"note":"The SDK strongly recommends ES Modules with `type: \"module\"` in package.json for async/await usage. CommonJS `require` may lead to issues or require specific file extensions (`.cjs`).","wrong":"const api = require('gettyimages-api');","symbol":"api","correct":"import api from 'gettyimages-api';"}],"quickstart":{"code":"import api from \"gettyimages-api\";\n\n// Ensure you set these environment variables before running:\n// process.env.GETTY_API_KEY and process.env.GETTY_API_SECRET\nconst creds = {\n    apiKey: process.env.GETTY_API_KEY ?? '',\n    apiSecret: process.env.GETTY_API_SECRET ?? ''\n};\n\nif (!creds.apiKey || !creds.apiSecret) {\n    console.error(\"Error: API Key and Secret must be provided via environment variables.\");\n    process.exit(1);\n}\n\nconst client = new api(creds);\n\nasync function searchImages() {\n    try {\n        console.log(\"Searching for creative images...\");\n        const response = await client.searchimagescreative()\n            .withPage(1)\n            .withPageSize(1)\n            .withPhrase('ocean')\n            .execute();\n        console.log(\"Found image:\", JSON.stringify(response.images, null, 2));\n    } catch (err) {\n        console.error(\"An error occurred while searching for images:\", err.message);\n        if (err.response && err.response.data) {\n            console.error(\"API Error details:\", JSON.stringify(err.response.data, null, 2));\n        }\n    }\n}\n\nsearchImages();\n","lang":"typescript","description":"Demonstrates initializing the Getty Images API client and performing a creative image search using environment variables for credentials."},"warnings":[{"fix":"Upgrade your Node.js installation to version 14.20.1 or newer.","message":"Node.js runtime environment 14.20.1 or higher is required. Older versions may not be supported or could lead to unexpected behavior.","severity":"breaking","affected_versions":"<14.20.1"},{"fix":"Add `\"type\": \"module\"` to your `package.json` file. If you are strictly using CommonJS, ensure your file extension is `.cjs` or `package.json` does NOT have `\"type\": \"module\"` and use `require` (though not recommended).","message":"The SDK strongly recommends setting `\"type\": \"module\"` in your `package.json` to enable ES Modules and `async/await` syntax. Without it, you might face issues with `import` statements and proper asynchronous execution.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Instantiate the client once at application startup. Always use `await` before `client.someMethod().execute();`.","message":"To correctly manage token lifetime and minimize API throttle quota usage, create the API client (`new api(creds)`) only once and reuse it across all API calls. Also, always `await` API calls to ensure the cached token is used.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review existing editorial search implementations and update any date-related parameters to `date_from` and `date_to`.","message":"In version 6.4.0, editorial searches were updated to consistently use `date_from` and `date_to` parameters to match documented API names. Older, undocumented parameter names might no longer function as expected.","severity":"breaking","affected_versions":">=6.4.0"},{"fix":"Upgrade to `gettyimages-api` version 6.2.1 or newer immediately to mitigate the CVE.","message":"A critical vulnerability (CVE-2023-45133) in a transitive dependency (`word-wrap`) was addressed in version 6.2.1. Older versions are susceptible to arbitrary code execution if untrusted content is passed to the vulnerable package.","severity":"breaking","affected_versions":"<6.2.1"},{"fix":"If manually managing or passing tokens, ensure you are on version 6.5.1 or newer to benefit from improved token expiration handling.","message":"Version 6.5.0 introduced the ability to pass in a pre-existing token, but version 6.5.1 fixed an issue with token expiration logic that might affect custom token management. If you pass tokens manually, ensure your logic aligns with 6.5.1's behavior.","severity":"gotcha","affected_versions":"6.5.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `\"type\": \"module\"` is set in your `package.json` and use `import api from 'gettyimages-api';`. If you must use CommonJS in a mixed environment, ensure your file extension is `.cjs`.","cause":"Attempting to use CommonJS `require()` syntax in an ES Module context without `type: \"module\"` in package.json, or using it incorrectly in a file intended for ESM.","error":"ReferenceError: require is not defined"},{"fix":"Double-check your `apiKey` and `apiSecret` credentials for correctness. Ensure they are active in your Getty Images developer account and have access to the specific API services you are trying to use.","cause":"The provided API key or secret is invalid, expired, or lacks the necessary permissions for the requested operation.","error":"Request failed with status code 401"},{"fix":"Ensure `const client = new api(creds);` is correctly instantiated and that all subsequent chained API calls (e.g., `client.searchimagescreative().withPage().execute()`) are `await`ed before trying to access results.","cause":"The `client` object or its methods are not correctly initialized or the fluent API calls are not chained properly, often due to not `await`ing the client's API call.","error":"TypeError: client.searchimagescreative(...).withPage is not a function"}],"ecosystem":"npm"}