{"id":13825730,"url":"https://github.com/netlify/js-client","last_synced_at":"2025-07-08T22:32:09.056Z","repository":{"id":21746082,"uuid":"25067938","full_name":"netlify/js-client","owner":"netlify","description":"A Open-API derived JS + Node.js API client for Netlify","archived":true,"fork":false,"pushed_at":"2022-10-10T13:03:48.000Z","size":8005,"stargazers_count":215,"open_issues_count":24,"forks_count":43,"subscribers_count":23,"default_branch":"main","last_synced_at":"2024-11-07T14:47:22.787Z","etag":null,"topics":["api","api-client","api-rest","javascript","js-client","netlify","nodejs","openapi","rest","swagger"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/netlify","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netlify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2014-10-11T07:28:03.000Z","updated_at":"2024-10-08T08:16:52.000Z","dependencies_parsed_at":"2023-01-11T21:20:29.808Z","dependency_job_id":null,"html_url":"https://github.com/netlify/js-client","commit_stats":null,"previous_names":["netlify/node-client"],"tags_count":137,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fjs-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fjs-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fjs-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fjs-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netlify","download_url":"https://codeload.github.com/netlify/js-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224850064,"owners_count":17380129,"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","api-client","api-rest","javascript","js-client","netlify","nodejs","openapi","rest","swagger"],"created_at":"2024-08-04T09:01:25.922Z","updated_at":"2024-11-20T04:30:47.060Z","avatar_url":"https://github.com/netlify.png","language":"JavaScript","readme":"\u003e ## !important Notice\n\u003e\n\u003e This repository was moved into the mono repository of [github.com/netlify/build](https://github.com/netlify/build) The\n\u003e package name and the versions are preserved!\n\n![netlify/js-client](js-client.png)\n\n[![npm version][npm-img]][npm] [![build status][build-img]][build] [![coverage][coverage-img]][coverage]\n[![dependencies][david-img]][david] [![downloads][dl-img]][dl]\n\nA Netlify [OpenAPI](https://github.com/netlify/open-api) client that works in the browser and Node.js.\n\n## Usage\n\n```js\nimport { NetlifyAPI } from 'netlify'\n\nconst client = new NetlifyAPI('1234myAccessToken')\nconst sites = await client.listSites()\n```\n\n## Using OpenAPI operations\n\n```js\nimport { NetlifyAPI } from 'netlify'\n\nconst client = new NetlifyAPI('1234myAccessToken')\n\n// Fetch sites\nconst sites = await client.listSites()\n\n// Create a site. Notice `body` here for sending OpenAPI body\nconst site = await client.createSite({\n  body: {\n    name: `my-awesome-site`,\n    // ... https://open-api.netlify.com/#/default/createSite\n  },\n})\n\n// Delete site. Notice `site_id` is a path parameter https://open-api.netlify.com/#/default/deleteSite\nawait client.deleteSite({ site_id: siteId })\n```\n\n## API\n\n### `client = new NetlifyAPI([accessToken], [opts])`\n\nCreate a new instance of the Netlify API client with the provided `accessToken`.\n\n`accessToken` is optional. Without it, you can't make authorized requests.\n\n`opts` includes:\n\n```js\nconst opts = {\n  userAgent: 'netlify/js-client',\n  scheme: 'https',\n  host: 'api.netlify.com',\n  pathPrefix: '/api/v1',\n  accessToken: '1234myAccessToken',\n  agent: undefined, // e.g. HttpsProxyAgent\n  globalParams: {}, // parameters you want available for every request.\n  // Global params are only sent of the OpenAPI spec specifies the provided params.\n}\n```\n\n### `client.accessToken`\n\nA setter/getter that returns the `accessToken` that the client is configured to use. You can set this after the class is\ninstantiated, and all subsequent calls will use the newly set `accessToken`.\n\n### `client.basePath`\n\nA getter that returns the formatted base URL of the endpoint the client is configured to use.\n\n### OpenAPI Client methods\n\nThe client is dynamically generated from the [OpenAPI](https://github.com/netlify/open-api) definition file. Each method\nis is named after the `operationId` name of each operation. **To see a list of available operations, please see the\n[OpenAPI website](https://open-api.netlify.com/)**.\n\nEvery OpenAPI operation has the following signature:\n\n#### `response = await client.operationId([params], [opts])`\n\nPerforms a call to the given endpoint corresponding with the `operationId`. Returns a promise resolved with the body of\nthe response, or rejected with an error with the details about the request attached. Rejects if the `status` \u003e 400.\n\n- `params` is an object that includes any of the required or optional endpoint parameters.\n- `params.body` should be an object which gets serialized to JSON automatically. Any object can live here but refer to\n  the OpenAPI specification for allowed fields in a particular request body. It can also be a function returning an\n  object.\n- If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream or a function returning one (e.g.\n  `() =\u003e fs.createReadStream('./foo')`). Using a function is recommended.\n\n```js\n// example params\nconst params = {\n  any_param_needed: anyParamNeeded,\n  paramsCanAlsoBeCamelCase,\n  body: {\n    an: 'arbitrary js object',\n  },\n}\n```\n\nOptional `opts` can include any property you want passed to [`node-fetch`](https://github.com/bitinn/node-fetch). The\n`headers` property is merged with some `defaultHeaders`.\n\n```js\n// example opts\nconst opts = {\n  headers: {\n    // Default headers\n    'User-agent': 'netlify-js-client',\n    accept: 'application/json',\n  },\n  // any other properties for node-fetch\n}\n```\n\nAll operations are conveniently consumed with async/await:\n\n```js\ntry {\n  const siteDeploy = await client.getSiteDeploy({\n    siteId: '1234abcd',\n    deploy_id: '4567',\n  })\n  // Calls may fail!\n} catch {\n  // handle error\n}\n```\n\nIf the response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text`\nof the response is returned.\n\n### API Flow Methods\n\nSome methods have been added in addition to the open API operations that make certain actions simpler to perform.\n\n#### `accessToken = await client.getAccessToken(ticket, [opts])`\n\nPass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the\nresponse from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken`\nand returns `accessToken` for the consumer to save for later.\n\nOptional `opts` include:\n\n```js\nconst opts = {\n  poll: 1000, // number of ms to wait between polling\n  timeout: 3.6e6, // number of ms to wait before timing out\n}\n```\n\nSee the [authenticating](https://www.netlify.com/docs/api/#authenticating) docs for more context.\n\n```js\nimport open from 'open'\n\nconst ticket = await client.createTicket({ clientId: CLIENT_ID })\n// Open browser for authentication\nawait open(`https://app.netlify.com/authorize?response_type=ticket\u0026ticket=${ticket.id}`)\n\n// API is also set up to use the returned access token as a side effect\n// Save this for later so you can quickly set up an authenticated client\nconst accessToken = await client.getAccessToken(ticket)\n```\n\n## Proxy support\n\n**Node.js only**: If this client is used behind a corporate proxy, you can pass an `HttpsProxyAgent` or any other\n`http.Agent` that can handle your situation as `agent` option:\n\n```js\nimport HttpsProxyAgent from 'https-proxy-agent'\n\nconst proxyUri = 'http(s)://[user:password@]proxyhost:port'\nconst agent = new HttpsProxyAgent(proxyUri)\nconst client = new NetlifyAPI('1234myAccessToken', { agent })\n```\n\n## Site deployment\n\nSupport for site deployment has been removed from this package in version 7.0.0. You should consider using the\n[`deploy` command](https://cli.netlify.com/commands/deploy/) of Netlify CLI.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for more info on how to make contributions to this project.\n\n## License\n\nMIT. See [LICENSE](LICENSE) for more details.\n\n[npm-img]: https://img.shields.io/npm/v/netlify.svg\n[npm]: https://npmjs.org/package/netlify\n[build-img]: https://github.com/netlify/js-client/workflows/Build/badge.svg\n[build]: https://github.com/netlify/js-client/actions\n[dl-img]: https://img.shields.io/npm/dm/netlify.svg\n[dl]: https://npmjs.org/package/netlify\n[coverage-img]: https://codecov.io/gh/netlify/js-client/branch/main/graph/badge.svg\n[coverage]: https://codecov.io/gh/netlify/js-client\n[david-img]: https://david-dm.org/netlify/js-client/status.svg\n[david]: https://david-dm.org/netlify/js-client\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fjs-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetlify%2Fjs-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fjs-client/lists"}