{"id":20260370,"url":"https://github.com/influxdata/iot-api-js","last_synced_at":"2025-06-20T09:06:24.573Z","repository":{"id":74459750,"uuid":"495540391","full_name":"influxdata/iot-api-js","owner":"influxdata","description":"An example IoT app built with NextJS (NodeJS + React) and the InfluxDB API client library for Javascript.","archived":false,"fork":false,"pushed_at":"2025-01-14T21:00:34.000Z","size":78,"stargazers_count":9,"open_issues_count":2,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-11T01:40:46.019Z","etag":null,"topics":["api","example-project","influxdata","influxdb","nextjs","nodejs","react"],"latest_commit_sha":null,"homepage":"","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/influxdata.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-23T19:07:35.000Z","updated_at":"2025-01-14T21:00:38.000Z","dependencies_parsed_at":"2024-12-16T15:37:14.841Z","dependency_job_id":"a3072b7e-621b-4b03-b687-6cbc2705d9d2","html_url":"https://github.com/influxdata/iot-api-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/influxdata/iot-api-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fiot-api-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fiot-api-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fiot-api-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fiot-api-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/influxdata","download_url":"https://codeload.github.com/influxdata/iot-api-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fiot-api-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260915890,"owners_count":23082039,"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","example-project","influxdata","influxdb","nextjs","nodejs","react"],"created_at":"2024-11-14T11:19:19.153Z","updated_at":"2025-06-20T09:06:19.562Z","avatar_url":"https://github.com/influxdata.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iot-api-js\n\nThis example project provides a Node.js REST API server that interacts with the InfluxDB v2 HTTP API.\nThe project uses the [Next.js](https://nextjs.org/) framework and the [InfluxDB v2 API client library for JavaScript](https://docs.influxdata.com/influxdb/v2/api-guide/client-libraries/nodejs/) to demonstrate how to build an app that collects, stores, and queries IoT device data.\nAfter you have set up and run your `iot-api-js` API server, you can consume your API using the [iot-api-ui](https://github.com/influxdata/iot-api-ui) standalone React frontend.\n\n## Features\n\nThis application demonstrates how you can use InfluxDB client libraries to do the following:\n\n- Create and manage InfluxDB authorizations (API tokens and permissions).\n- Write and query device metadata in InfluxDB.\n- Write and query telemetry data in InfluxDB.\n- Generate data visualizations with the InfluxDB Giraffe library.\n\n## Tutorial and support\n\nTo learn how to build this app from scratch, follow the [InfluxDB v2 OSS tutorial](https://docs.influxdata.com/influxdb/v2/api-guide/tutorials/nodejs/) or [InfluxDB Cloud tutorial](https://docs.influxdata.com/influxdb/cloud/api-guide/tutorials/nodejs/).\nThe app is an adaptation of [InfluxData IoT Center](https://github.com/bonitoo-io/iot-center-v2), simplified to accompany the IoT Starter tutorial.\n\nFor help, refer to the tutorials and InfluxDB documentation or use the following resources:\n\n- [InfluxData Community](https://community.influxdata.com/)\n- [InfluxDB Community Slack](https://influxdata.com/slack)\n\nTo report a problem, submit an issue to this repo or to the [`influxdata/docs-v2` repo](https://github.com/influxdata/docs-v2/issues).\n\n## Get started\n\n### Set up InfluxDB prerequisites\n\nFollow the tutorial instructions to setup your InfluxDB organization, API token, and buckets:\n\n- [Set up InfluxDB OSS v2 prerequisites](https://docs.influxdata.com/influxdb/v2/api-guide/tutorials/nodejs/#set-up-influxdb)\n- [Set up InfluxDB Cloud v2 prerequisites](https://docs.influxdata.com/influxdb/cloud/api-guide/tutorials/nodejs/#set-up-influxdb)\n\nNext, [clone and run the API server](#clone-and-run-the-api-server).\n\n### Clone and run the API server\n\n1. Clone this repository to your machine.\n2. Change to the directory--for example, enter the following command in your terminal:\n\n   ```bash\n   cd ./iot-api-js\n   ```\n\n3. Add a `.env.local` file that contains the following configuration variables:\n\n   ```bash\n   # Local environment secrets\n\n   INFLUX_TOKEN=INFLUXDB_ALL_ACCESS_TOKEN\n   INFLUX_ORG=INFLUXDB_ORG_ID\n   ```\n\n   Replace the following:\n\n   - **`INFLUXDB_ALL_ACCESS_TOKEN`** with your InfluxDB **All Access** token.\n   - **`INFLUXDB_ORG_ID`** with your InfluxDB organization ID.\n\n4. If you need to adjust the default URL or bucket names to match your InfluxDB instance, edit the settings in `.env.development` or set them in `.env.local` (to override `.env.development`).\n5. If you haven't already, follow the [Node.js installation instructions](https://nodejs.org/) to install `node` for your operating system.\n6. To check the installed `node` version, enter the following command in your terminal:\n\n   ```bash\n   node --version\n   ```\n\n7. Follow the [Yarn installation instructions](https://yarnpkg.com/getting-started/install#nodejs-1610-1) to install the `yarn` package manager for your version of Node.js.\n8. To check the installed `yarn` version, enter the following command in your terminal:\n\n   ```bash\n   yarn --version\n   ```\n\n9. Run `yarn` to install the project dependencies:\n\n   ```bash\n   yarn\n   ```\n\n10. In your terminal, enter the following command to start the application in **development** mode:\n\n     ```bash\n     yarn dev -p 5200 \n     ```\n\n     The application server starts with the following output:\n\n     ```bash\n     \u003e dev\n     \u003e next dev\n     ready - started server on 0.0.0.0:5200, url: http://localhost:5200\n     ```\n\n11. In your browser, visit \u003chttp://localhost:5200/api/devices\u003e to view the API server output.\n\n12. _Optional_: Run the [iot-api-ui](https://github.com/influxdata/iot-api-ui) React frontend to interact with your IoT Starter API server.\n\n## Troubleshoot\n\n### Error: could not find bucket\n\n```json\n{\"error\":\"failed to load data: HttpError: failed to initialize execute state: could not find bucket \\\"iot_center_devices\\\"\"}\n```\n\nSolution: [create buckets](#set-up-influxdb-prerequisites) or adjust the defaults in `.env.development` to match your InfluxDB instance.\n\n## Learn More\n\n### InfluxDB\n\n- Develop with the InfluxDB API for [OSS v2](https://docs.influxdata.com/influxdb/v2/api-guide/) or [Cloud v2](https://docs.influxdata.com/influxdb/cloud/api-guide/).\n\n### Next.js\n\nTo learn more about Next.js, see following resources:\n\n- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.\n- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfluxdata%2Fiot-api-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfluxdata%2Fiot-api-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfluxdata%2Fiot-api-js/lists"}