{"id":16791927,"url":"https://github.com/metonym/fooddata-central","last_synced_at":"2025-03-17T02:14:02.741Z","repository":{"id":57239934,"uuid":"250875614","full_name":"metonym/fooddata-central","owner":"metonym","description":"Node.js client and API types for USDA FoodData Central","archived":false,"fork":false,"pushed_at":"2020-03-29T14:33:32.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T05:05:38.242Z","etag":null,"topics":["fooddata-central","usda"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metonym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-28T19:22:14.000Z","updated_at":"2024-05-23T10:29:14.000Z","dependencies_parsed_at":"2022-08-29T21:23:08.607Z","dependency_job_id":null,"html_url":"https://github.com/metonym/fooddata-central","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Ffooddata-central","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Ffooddata-central/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Ffooddata-central/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Ffooddata-central/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metonym","download_url":"https://codeload.github.com/metonym/fooddata-central/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960666,"owners_count":20375105,"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":["fooddata-central","usda"],"created_at":"2024-10-13T08:43:31.798Z","updated_at":"2025-03-17T02:14:02.724Z","avatar_url":"https://github.com/metonym.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fooddata-central\n\n[![NPM][npm]][npm-url]\n[![Build][build]][build-badge]\n\n\u003e Node.js client and API types for [USDA FoodData Central](https://fdc.nal.usda.gov/).\n\nFoodData Central is an API provided by the [U.S. Department of Agriculture](https://www.usda.gov/) that provides expanded nutrient profile data for foods.\n\n## Getting Started\n\n```bash\nyarn add fooddata-central\n```\n\n## Prerequisites\n\nAn [API key](https://fdc.nal.usda.gov/api-key-signup.html) is required to interact with the FoodData Central API.\n\n## Usage\n\n```js\nimport Client from \"fooddata-central\";\n\n(async () =\u003e {\n  // initialize a new client\n  const client = new Client({ api_key: \"API_KEY\" });\n\n  // search foods based on an input\n  const results = await client.search({ generalSearchInput: \"raw broccoli\" });\n\n  if (results.success) {\n    // get details for food item\n    const details = await client.details(results.data.foods[0].fdcId);\n\n    if (details.success) {\n      console.log(details.data);\n    }\n  }\n})();\n```\n\n### API\n\n#### Search foods\n\nSearch the food database using the `search` method.\n\n```ts\nclient.search({\n  generalSearchInput?: string;\n  includeDataTypeList?: string | string[];\n  ingredients?: string;\n  brandOwner?: string;\n  requireAllWords?: boolean;\n  pageNumber?: number;\n  sortField?: \"lowercaseDescription.keyword\" | \"dataType.keyword\" | \"publishedDate\" | \"fdcId\";\n  sortDirection?: \"asc\" | \"desc\";\n})\n```\n\n#### Retrieve food details\n\nEach food object returned from the `search` endpoint contains a unique `fdcId`.\n\nPass the `fdcId` value to the `details` method to retrieve the nutrient profile of the item.\n\n```ts\nclient.details(fdcId: number)\n```\n\n## License\n\n[MIT](LICENSE)\n\n[npm]: https://img.shields.io/npm/v/fooddata-central.svg?color=blue\n[npm-url]: https://npmjs.com/package/fooddata-central\n[build]: https://travis-ci.com/metonym/fooddata-central.svg?branch=master\n[build-badge]: https://travis-ci.com/metonym/fooddata-central\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Ffooddata-central","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetonym%2Ffooddata-central","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Ffooddata-central/lists"}