{"id":18708639,"url":"https://github.com/imgix/imgix-management-js","last_synced_at":"2025-07-06T20:39:10.213Z","repository":{"id":38184220,"uuid":"255432330","full_name":"imgix/imgix-management-js","owner":"imgix","description":"A Javascript library that wraps the imgix management API","archived":false,"fork":false,"pushed_at":"2025-04-12T15:01:38.000Z","size":654,"stargazers_count":7,"open_issues_count":11,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-04T12:45:09.022Z","etag":null,"topics":["api","imgix","javascript","management","nodejs"],"latest_commit_sha":null,"homepage":"https://www.imgix.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imgix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-13T20:15:59.000Z","updated_at":"2022-05-15T06:08:39.000Z","dependencies_parsed_at":"2023-09-30T11:24:56.060Z","dependency_job_id":"3d9aa3aa-5679-4ae7-b307-7d52928a408e","html_url":"https://github.com/imgix/imgix-management-js","commit_stats":{"total_commits":265,"total_committers":9,"mean_commits":"29.444444444444443","dds":0.3886792452830189,"last_synced_commit":"31a98ea8d149725f5b53a946b11f518d1b4ffca2"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/imgix/imgix-management-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgix%2Fimgix-management-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgix%2Fimgix-management-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgix%2Fimgix-management-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgix%2Fimgix-management-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imgix","download_url":"https://codeload.github.com/imgix/imgix-management-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgix%2Fimgix-management-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259927011,"owners_count":22933135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","imgix","javascript","management","nodejs"],"created_at":"2024-11-07T12:24:22.334Z","updated_at":"2025-07-06T20:39:10.194Z","avatar_url":"https://github.com/imgix.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"⚠️ **This library is currently marked as experimental. We plan to eventually integrate it as its own module in [`@imgix/js-core`](https://github.com/imgix/js-core).**\n\n\u003c!-- ix-docs-ignore --\u003e\n\n![imgix logo](https://assets.imgix.net/sdk-imgix-logo.svg)\n\n`imgix-management-js` is a JavaScript client library for making requests against the [imgix](https://www.imgix.com/) Management API.\n\n[![NPM Version](https://img.shields.io/npm/v/imgix-management-js.svg)](https://www.npmjs.com/package/imgix-management-js)\n[![Build Status](https://circleci.com/gh/imgix/imgix-management-js.svg?style=shield)](https://circleci.com/gh/imgix/imgix-management-js)\n[![Monthly Downloads](https://img.shields.io/npm/dm/imgix-management-js.svg)](https://www.npmjs.com/package/imgix-management-js)\n[![Minified Size](https://img.shields.io/bundlephobia/min/imgix-management-js)](https://bundlephobia.com/result?p=imgix-management-js)\n[![License](https://img.shields.io/github/license/imgix/imgix-management-js)](https://github.com/imgix/imgix-management-js/blob/main/LICENSE.md)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimgix%2Fimgix-management-js.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-management-js?ref=badge_shield)\n\n---\n\n\u003c!-- /ix-docs-ignore --\u003e\n\n- [Installation](#installation)\n    * [CommonJS](#commonjs)\n- [Configuration](#configuration)\n- [API](#api)\n    * [`ImgixAPI.request(path, options)`](#imgixapirequestpath-options)\n- [Usage Examples](#usage-examples)\n    * [Retrieve a list of images](#retrieve-a-list-of-images)\n    * [Retrieve all details for a single image](#retrieve-all-details-for-a-single-image)\n    * [Retrieve custom fields for a single image](#retrieve-custom-fields-for-a-single-image)\n    * [Update custom fields for a single image](#update-custom-fields-for-a-single-image)\n    * [Upload an image](#upload-an-image)\n    * [Retrieve all sources](#retrieve-all-sources)\n    * [Specify the fields returned](#specify-the-fields-returned)\n    * [Paging by page number and size](#paging-by-page-number-and-size)\n    * [Sorting lists of objects](#sorting-lists-of-objects)\n    * [Filtering lists of objects](#filtering-lists-of-objects)\n    * [Create an object](#create-an-object)\n- [License](#license)\n\n## Installation\n\n`npm install imgix-management-js`\n\n`imgix-management-js` exposes a class `ImgixAPI`:\n\n### CommonJS\n\n```js\nconst ImgixAPI = require(\"imgix-management-js\");\n\nconst imgix = new ImgixAPI({\n    apiKey: `${yourApiKey}`\n});\n```\n\n## Configuration\n\nThe following options can be used when creating an instance of `ImgixAPI`:\n\n- `apiKey`: String, required. The token used to authenticate API requests.\n- `version`: Integer. The version of the API that will be requested against. Defaults to `1`.\n\n## API\n\n### `ImgixAPI.request(path, options)`\n\n- `path`: String, required. A partial path representing the relative URL endpoint to request. This will typically require a `sourceId`.\n- `options`: Object. Any custom HTTP(S) settings to be applied to a request.\n    * `method`: String, required. The request [method](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods), defaults to 'GET'.\n    * `headers`: Object. Additional [information](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) included with a request.\n    * `body`: Object, String, or Buffer. A resource, such as binary data or a file, included with the request.\n\nMakes a request against the specified imgix Management API endpoint.\n\n**Returns**: `Promise\u003c[Response]\u003e`\n\nThe supplied `path` should be a relative URL, such as `assets/{sourceId}`. Using this path, the full API URL will be constructed at the time that the request is made, saving users the need to provide the full URL themselves each time.\n\n`ImgixAPI` will intelligently populate any necessary headers prior to completing the request. This includes fields such as `Content-Type` and `Authorization`. Outside of that, the `options` argument can be used to override certain defaults, such as the HTTP request method, or provide a file for uploading.\n\n## Usage Examples\n\nThe following sections demonstrate how to use this library to make API requests for common use cases. For a full list of endpoints and operations, see the [management API docs](https://docs.imgix.com/apis/management).\n\n### Retrieve a list of images\n\n```js\nimgix.request(`assets/${sourceId}`)\n.then(response =\u003e console.log(JSON.stringify(response, null, 2)));\n```\n\n### Retrieve all details for a single image\n\n```js\nimgix.request(`assets/${sourceId}/${originPath}`)\n.then(response =\u003e console.log(JSON.stringify(response, null, 2)));\n```\n\n### Retrieve custom fields for a single image\n\n```js\nvar customFields;\n\nimgix.request(`assets/${sourceId}/uploads/pecanpie.jpg`)\n.then(response =\u003e {\n    customFields = response.data.attributes.customFields;\n    console.log(customFields);\n});\n```\n\n### Update custom fields for a single image\n\n```js\nvar document = {\n    'data': {\n        'id': `${sourceId}/pecanpie.jpg`,\n        'type': 'assets',\n        'attributes': {}\n    }\n};\n\nimgix.request(`sources/${sourceId}/assets/pecanpie.jpg`)\n.then(response =\u003e {\n    /*\n    ** Populate `document` with all pre-existing fields\n    ** so as to not overwrite them when sending a PATCH request\n    */\n    document.data.attributes.custom_fields = response.data.attributes.custom_fields;\n    document.data.attributes.custom_fields.type = 'dessert';\n\n    // PATCH request to write in new custom field\n    imgix.request(`sources/${sourceId}/assets/pecanpie.jpg`, {\n        method: 'PATCH',\n        body: document\n    })\n    .then(response =\u003e console.log(response.data.attributes))\n})\n```\n\n### Upload an image\n\n```js\nconst data = fs.readFileSync('./src/monstera.jpg');\n\nimgix.request(`sources/upload/${sourceId}/monstera.jpg`, {\n    method: 'POST',\n    body: data\n})\n.then(response =\u003e console.log(JSON.stringify(response, null, 2)));\n```\n\n### Retrieve all sources\n\n```js\nimgix.request(`sources`)\n.then(response =\u003e console.log(JSON.stringify(response, null, 2)));\n```\n\n### Specify the fields returned\n\n```js\n// To request a deeply-nested field, use dot notation\n\nimgix.request(`sources/${sourceId}?fields[sources]=name,deployment_status,deployment.default_params`)\n.then(resp =\u003e console.log(resp));\n```\n\n### Paging by page number and size\n\n```js\nimgix.request(`assets/${sourceId}?page[number]=0\u0026page[size]=1`)\n.then(resp =\u003e console.log(resp))\n```\n\n### Sorting lists of objects\n\n```js\n// To sort a field in descending order, prepend a dash “-” to the field name.\n\nimgix.request('sources?sort=name\u0026fields[sources]=name')\n.then(resp =\u003e console.log(resp))\n```\n\n### Filtering lists of objects\n\n```js\nimgix.request('sources?filter[name]=staging\u0026filter[deployment.type]=s3')\n.then(resp =\u003e console.log(resp))\n```\n\n### Create an object\n\n```js\nvar data = {\n  \"data\": {\n    \"attributes\": {\n      \"name\": \"New Web Folder Source\",\n      \"deployment\": {\n        \"type\": \"webfolder\",\n        \"webfolder_base_url\": \"https://my-domain.com/images/\",\n        \"imgix_subdomains\": [\n          \"my-unique-imgix-subdomain\"\n        ]\n      }\n    },\n    \"type\": \"sources\"\n  },\n  \"jsonapi\": {\n    \"version\": \"1.0\"\n  }\n}\n\nimgix.request(`sources`, {\n    method: 'POST',\n    body: data\n})\n.then(response =\u003e console.log(JSON.stringify(response, null, 2)));\n```\n\n## License\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fimgix%2Fimgix-management-js.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-management-js?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimgix%2Fimgix-management-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimgix%2Fimgix-management-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimgix%2Fimgix-management-js/lists"}