{"id":13825765,"url":"https://github.com/netlify/micro-api-client","last_synced_at":"2025-07-08T22:32:09.889Z","repository":{"id":47628634,"uuid":"71536973","full_name":"netlify/micro-api-client","owner":"netlify","description":"Small library for talking to micro REST APIs (not related to Netlify's main API)","archived":true,"fork":false,"pushed_at":"2021-08-20T19:19:45.000Z","size":349,"stargazers_count":28,"open_issues_count":17,"forks_count":7,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-25T18:47:56.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/micro-api-client","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":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-21T06:37:07.000Z","updated_at":"2023-01-28T06:41:41.000Z","dependencies_parsed_at":"2022-09-06T12:12:59.061Z","dependency_job_id":null,"html_url":"https://github.com/netlify/micro-api-client","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fmicro-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fmicro-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fmicro-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlify%2Fmicro-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netlify","download_url":"https://codeload.github.com/netlify/micro-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225470631,"owners_count":17479366,"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":[],"created_at":"2024-08-04T09:01:26.718Z","updated_at":"2024-11-20T04:30:49.973Z","avatar_url":"https://github.com/netlify.png","language":"JavaScript","readme":"# micro-api-client\n\n[![Build Status](https://travis-ci.org/netlify/micro-api-client.svg?branch=master)](https://travis-ci.org/netlify/micro-api-client)\n\nSmall library for talking to micro REST APIs (not related to Netlify's main API).\n\n## Installation\n\n```\nyarn add micro-api-client\n```\n\n## Usage\n\n```js\nimport API, { getPagination } from 'micro-api-client'\n\nconst api = new API(\"/some/api/endpoint\");\napi\n  .request(\"foo\")\n  .then(response =\u003e console.log(response))\n  .catch(err =\u003e console.error(err));\n```\n\n### API\n\n### `api = new API(apiURL, [opts])`\n\nCreate a new `micro-api-client` instance. `apiURL` can be a full or relative URL. Optional `opts` include:\n\n```js\n{\n  defaultHeaders: {\n  } // header values to include in every request.\n}\n```\n\n### `api.request(path, [opts])`\n\nMake a request to the `apiURL` at the given `path`. Optional `opts` are passed to the [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) API:\n\n```js\n// Default options\n{\n  headers: {} // Optional headers object.  Overrides defaultHeaders\n  credentials: \"same-origin\" // set fetch credentials option\n  \"Content-Type\": \"application/json\" // set Content-Type fetch option\n}\n```\n\nReturns a promise with the `response`. If the `contentType` is JSON, it will be checked for pagination and return either the parsed JSON object or a paginated JSON object:\n\n```js\n// See src/pagination.js\n{\n  pagination: {\n    last,\n    next,\n    prev,\n    first,\n    current,\n    total\n  },\n  items: json\n}\n```\n\nIf an error occurs during the request, the promise may be rejected with an `HTTPError`, `TextHTTPError`, or `JSONHTTPError`.\n\n### `class HTTPError extends Error`\n\nAdditional error properties from Error\n\n```js\n{\n  stack, // stack trace of error\n  status // status code of response\n}\n```\n\n### `class TextHTTPError extends HTTPError`\n\nAdditional error properties from HTTPError\n\n```js\n{\n  data // data of text response\n}\n```\n\n### `class JSONHTTPError extends HTTPError`\n\nAdditional error properties from HTTPError\n\n```js\n{\n  json // json of a JSON response\n}\n```\n\n### `pagination = getPagination(response)`\n\nReturns a pagination object that `micro-api-client` uses internally.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fmicro-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetlify%2Fmicro-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlify%2Fmicro-api-client/lists"}