{"id":16292492,"url":"https://github.com/exogen/foobot-graphql","last_synced_at":"2026-01-17T22:51:46.391Z","repository":{"id":57239916,"uuid":"67657752","full_name":"exogen/foobot-graphql","owner":"exogen","description":"GraphQL interface for Foobot device data","archived":false,"fork":false,"pushed_at":"2018-10-12T01:48:22.000Z","size":185,"stargazers_count":0,"open_issues_count":16,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T18:51:02.986Z","etag":null,"topics":["air-quality","air-quality-sensor","api","foobot","graphql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/exogen.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":"2016-09-08T01:39:52.000Z","updated_at":"2020-04-13T13:25:33.000Z","dependencies_parsed_at":"2022-08-29T22:22:43.022Z","dependency_job_id":null,"html_url":"https://github.com/exogen/foobot-graphql","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/exogen%2Ffoobot-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Ffoobot-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Ffoobot-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Ffoobot-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exogen","download_url":"https://codeload.github.com/exogen/foobot-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246828503,"owners_count":20840474,"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":["air-quality","air-quality-sensor","api","foobot","graphql"],"created_at":"2024-10-10T20:07:08.294Z","updated_at":"2026-01-17T22:51:46.365Z","avatar_url":"https://github.com/exogen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/exogen/foobot-graphql.svg)](https://travis-ci.org/exogen/foobot-graphql)\n[![Package Version](https://img.shields.io/npm/v/foobot-graphql.svg)](https://www.npmjs.com/package/foobot-graphql)\n\n# foobot-graphql\n\nAn [Express][] server and middleware for querying your [Foobot][] using\n[GraphQL][].\n\n```sh\nnpm install --save foobot-graphql\n```\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n## Contents\n\n- [Usage](#usage)\n  - [As a standalone server](#as-a-standalone-server)\n  - [As middleware](#as-middleware)\n  - [Environment Variables](#environment-variables)\n  - [Debugging](#debugging)\n- [Example Queries](#example-queries)\n- [Schema](#schema)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Usage\n\nThis package can be used both as a standalone GraphQL server and as Express\nmiddleware supplying a GraphQL endpoint.\n\n### As a standalone server\n\nRun the included `foobot-graphql` executable to start the server. The server\nis configured using [environment variables](#environment-variables).\n\n```sh\n$ foobot-graphql\nListening on port 3000.\n```\n\nDevelopment mode features like JSON pretty printing and the GraphiQL interface\nwill be enabled unless the server is run with `NODE_ENV=production`.\n\n### As middleware\n\nIf you have an existing Express server and want to add this GraphQL service as\nan endpoint, or you just want more customization, use the middleware.\n\n```js\nimport express from 'express';\nimport foobotGraphQL from 'foobot-graphql';\n\nconst app = express();\n\napp.use('/foobot', foobotGraphQL());\n// or, pass some options:\napp.use('/foobot', foobotGraphQL({ graphiql: false }));\n\napp.listen(3000);\n```\n\nThe `foobotGraphQL` middleware function accepts the following options:\n\n* **`client`**: A custom API client instance to use. See the\n  [client submodule](src/client.js) for help with creating a custom instance.\n* Any remaining options are passed along to the standard GraphQL middleware.\n  See the [express-graphql][] documentation for more information.\n\n### Environment Variables\n\n* **`FOOBOT_API_KEY`**: API key to authenticate with. [Request an API key][API]\n  at the Foobot site.\n* **`FOOBOT_USERNAME`**: Username of the account owner.\n* **`FOOBOT_DEFAULT_DEVICE`**: Device UUID to use as the default, so you\n  don’t have to look it up and specify it every time if you only have one\n  device.\n* **`PORT`**: Port number to use, if running the standalone server.\n\nWhen running the standalone server, [dotenv][] is used to load these variables\nfrom a `.env` file, if one exists in the current working directory. See the\n[dotenv][] package for more information.\n\n### Debugging\n\nThe `DEBUG` environment variable can be used to enable logging for all (or just\nsome) of this package’s submodules:\n\n```sh\n$ DEBUG=foobot-graphql:* foobot-graphql\n```\n\nSee the [debug][] package for more information.\n\n## Example Queries\n\nGet the latest sensor data from the default device:\n\n```graphql\n\n{\n  device {\n    name\n    sensors {\n      pm {\n        units\n        datapoints {\n          time\n          value\n        }\n      }\n      co2 {\n        units\n        datapoints {\n          time\n          value\n        }\n      }\n      voc {\n        units\n        datapoints {\n          time\n          value\n        }\n      }\n    }\n  }\n}\n\n```\n\nGet the 15-minute averaged pollution index for the last day from device\n`ABCDEF`:\n\n```graphql\n\n{\n  device(uuid: \"ABCDEF\") {\n    name\n    sensors(period: 86400, averageBy: 900) {\n      allpollu {\n        datapoints {\n          time\n          value\n        }\n      }\n    }\n  }\n}\n\n```\n\n## Schema\n\n```graphql\n\n# A single datapoint from a sensor.\ntype Datapoint {\n  # The timestamp of the reading.\n  time: Date\n\n  # The numeric value of the sensor reading.\n  value: Float\n}\n\nscalar Date\n\n# Information about a single device.\ntype Device {\n  # The UUID of the device.\n  uuid: String\n\n  # The friendly name of the device.\n  name: String\n\n  # The MAC of the device.\n  mac: String\n\n  # The ID of the user who owns the device.\n  userID: Int\n\n  # The set of sensors on a single device.\n  sensors(\n    # Number of seconds between start time of the period and now.\n    period: Int = 0\n\n    # Resolution of the returned datapoints in seconds. Use 0 or 300 for no\n    # averaging. For long range requests, it is recommended to use 3600 (hourly\n    # average) or a multiple.\n    averageBy: Int = 0\n  ): Sensors\n}\n\ntype Query {\n  device(\n    # The UUID of the device. If none is supplied, the default will be determined based on the server’s configuration.\n    uuid: String\n  ): Device\n}\n\n# Information from a single sensor.\ntype Sensor {\n  # The units for the value returned in each datapoint.\n  units: String\n\n  # The set of datapoints for the requested period.\n  datapoints: [Datapoint]\n}\n\ntype Sensors {\n  # The timestamp of the earliest returned datapoint.\n  start: Date\n\n  # The timestamp of the last returned datapoint.\n  end: Date\n\n  # The timestamp at which we expect a new datapoint from the device. Clients can\n  # use this to determine when their data is stale.\n  expires: Date\n\n  # Particulate matter.\n  pm: Sensor\n\n  # Temperature.\n  tmp: Sensor\n\n  # Humidity.\n  hum: Sensor\n\n  # Carbon dioxide.\n  co2: Sensor\n\n  # Volatile organic compounds.\n  voc: Sensor\n\n  # Overall pollution index.\n  allpollu: Sensor\n}\n\n```\n\n[Express]: http://expressjs.com/\n[Foobot]: http://foobot.io/\n[GraphQL]: http://graphql.org/\n[API]: https://api.foobot.io/apidoc/index.html\n[dotenv]: https://www.npmjs.com/package/dotenv\n[debug]: https://www.npmjs.com/package/debug\n[express-graphql]: https://www.npmjs.com/package/express-graphql\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexogen%2Ffoobot-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexogen%2Ffoobot-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexogen%2Ffoobot-graphql/lists"}