{"id":14384722,"url":"https://github.com/fvdm/nodejs-foscam","last_synced_at":"2025-07-17T09:34:40.446Z","repository":{"id":4067563,"uuid":"5171795","full_name":"fvdm/nodejs-foscam","owner":"fvdm","description":"Remote control, view and config a Foscam or compatible IP camera","archived":false,"fork":false,"pushed_at":"2017-12-17T00:38:01.000Z","size":70,"stargazers_count":125,"open_issues_count":2,"forks_count":31,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2025-04-01T19:48:45.600Z","etag":null,"topics":["api-client","camera","camera-settings","foscam","nodejs","tenvis","unlicense"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/foscam","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fvdm.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":"2012-07-24T21:59:25.000Z","updated_at":"2025-03-24T13:27:14.000Z","dependencies_parsed_at":"2022-09-11T07:21:53.463Z","dependency_job_id":null,"html_url":"https://github.com/fvdm/nodejs-foscam","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fvdm/nodejs-foscam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-foscam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-foscam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-foscam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-foscam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fvdm","download_url":"https://codeload.github.com/fvdm/nodejs-foscam/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-foscam/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265589280,"owners_count":23793499,"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-client","camera","camera-settings","foscam","nodejs","tenvis","unlicense"],"created_at":"2024-08-28T18:01:36.870Z","updated_at":"2025-07-17T09:34:40.430Z","avatar_url":"https://github.com/fvdm.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# foscam\r\n\r\nRemote control, view and config a Foscam/Tenvis IP camera.\r\n\r\nAll included methods are based on Foscam's (fragmented) API documentation.\r\nSome features may not be supported by non-pan/tilt, older cameras or old firmware.\r\nSo make sure you keep a backup of your camera settings, just in case.\r\n\r\n\r\n## Usage\r\n\r\n```js\r\nvar cam = require ('foscam');\r\n\r\ncam.setup ({\r\n  host: 'mycamera.lan',\r\n  port: 81,\r\n  user: 'admin',\r\n  pass: ''\r\n});\r\n\r\n// start rotating left\r\ncam.control.decoder ('left', function () {\r\n\r\n  // stop rotation\r\n  cam.control.decoder ('stop left', function () {\r\n\r\n    // take a picture and store it on your computer\r\n    cam.snapshot ('/path/to/save.jpg', console.log);\r\n\r\n  });\r\n});\r\n```\r\n\r\n\r\n## Installation\r\n\r\nStable: `npm install foscam`\r\n\r\nDevelop: `npm install fvdm/nodejs-foscam#develop`\r\n\r\n\r\n## Methods\r\n\r\nEvery method takes a `callback` function as last parameter. The callbacks are the only way to procedural scripting.\r\n\r\n**NOTE:** Some methods require a certain access-level, i.e. *admins* can do everything, but a *visitor* can only view.\r\n\r\n\r\n### Basic\r\n\r\n### setup\r\n#### ( properties, [callback] )\r\n\r\nIn order to connect to the camera you first need to provide its access details. You can either do this by setting the properties below directly in `cam.settings`, but better is to use `cam.setup()`. When the `callback` function is provided, `setup()` will attempt to connect to the camera and retrieve its status, returned as object to the callback. When it fails the callback gets **false**.\r\n\r\n\r\nname | type   | default       | description\r\n-----|--------|---------------|----------------------\r\nhost | string | 192.168.1.239 | Camera IP or hostname\r\nport | number | 81            | Camera port number\r\nuser | string | admin         | Username\r\npass | string |               | Password\r\n\r\n\r\n```js\r\ncam.setup (\r\n  {\r\n    host: 'mycamera.lan',\r\n    port: 81,\r\n    user: 'admin'\r\n    pass: ''\r\n  },\r\n  function (status) {\r\n    if (!status) {\r\n      console.error ('ERROR: can\\'t connect');    } else {\r\n      console.log (status);\r\n    }\r\n  }\r\n);\r\n```\r\n\r\n### status\r\n#### ( callback )\r\n\r\n**Permission: everyone**\r\n\r\nGet basic details from the camera.\r\n\r\n```js\r\ncam.status (console.log);\r\n```\r\n\r\n```js\r\n{ id: '001A11A00A0B',\r\n  sys_ver: '0.37.2.36',\r\n  app_ver: '3.2.2.18',\r\n  alias: 'Cam1',\r\n  now: '1343304558',\r\n  tz: '-3600',\r\n  alarm_status: '0',\r\n  ddns_status: '0',\r\n  ddns_host: '',\r\n  oray_type: '0',\r\n  upnp_status: '0',\r\n  p2p_status: '0',\r\n  p2p_local_port: '23505',\r\n  msn_status: '0',\r\n  alarm_status_str: 'no alarm',\r\n  ddns_status_str: 'No Action',\r\n  upnp_status_str: 'No Action' }\r\n```\r\n\r\n### camera_params\r\n#### ( callback )\r\n\r\n**Permission: visitor**\r\n\r\nGet camera sensor settings.\r\n\r\n```js\r\ncam.camera_params (console.log);\r\n```\r\n\r\n```js\r\n{ resolution: 32,\r\n  brightness: 96,\r\n  contrast: 4,\r\n  mode: 1,\r\n  flip: 0,\r\n  fps: 0 }\r\n```\r\n\r\n### Camera\r\n\r\n### snapshot\r\n#### ( [filename], callback )\r\n\r\nTake a snapshot. Either receive the **binary JPEG** in the `callback` or specify a `filename` to store it on your computer.\r\n\r\nWhen a `filename` is provided the callback will return either the *filename* on success or *false* on faillure.\r\n\r\n```js\r\n// custom processing\r\ncam.snapshot (function (jpeg) {\r\n  // add binary processing here\r\n});\r\n\r\n// store locally\r\ncam.snapshot ('./my_view.jpg', console.log);\r\n```\r\n\r\n\r\n### preset.set\r\n#### ( id, [cb] )\r\n\r\nSave current camera position in preset #`id`. You can set presets 1 to 16.\r\n\r\n```js\r\ncam.preset.set (3, console.log);\r\n```\r\n\r\n\r\n### preset.go\r\n#### ( id, [cb] )\r\n\r\nMove camera to the position as stored in preset #`id`. You can use presets 1 to 16.\r\n\r\n```js\r\ncam.preset.go (3, console.log);\r\n```\r\n\r\n\r\n### control.decoder\r\n#### ( command, [callback] )\r\n\r\nControl camera movement, like pan and tilt.\r\n\r\nThe `command` to execute can be a string or number.\r\n\r\n\r\ncommand                | description\r\n-----------------------|------------------\r\nup                     | start moving up\r\nstop up                | stop moving up\r\ndown                   | start moving down\r\nstop down              | stop moving down\r\nleft                   | start moving left\r\nstop left              | stop moving left\r\nright                  | start moving right\r\nstop right             | stop moving right\r\ncenter                 | move to center\r\nvertical patrol        | start moving y-axis\r\nstop vertical patrol   | stop moving y-axis\r\nhorizontal patrol      | start moving x-axis\r\nstop horizontal patrol | stop moving x-axis\r\nio output high         | iR on _(some cameras)_\r\nio output low          | iR off _(some camera)_\r\n\r\n\r\n```js\r\ncam.control.decoder ('horizontal patrol', function () {\r\n  console.log ('Camera moving left-right');\r\n});\r\n```\r\n\r\n\r\n### control.camera\r\n#### ( name, value, [callback] )\r\n\r\nChange a camera (sensor) setting.\r\n\r\n\r\nname       | value\r\n-----------|-----------------------------------\r\nresolution | `240` (320x240) or `480` (640x480)\r\nbrightness | `0` to `255`\r\ncontrast   | `0` to `6`\r\nmode       | `50` Hz, `60` Hz or `outdoor`\r\nflipmirror | `default`, `flip`, `mirror` or `flipmirror`\r\n\r\n\r\n```js\r\ncam.control.camera ('resolution', 640, function () {\r\n  console.log ('Resolution changed to 640x480');\r\n});\r\n```\r\n\r\n\r\n### System\r\n\r\n### reboot\r\n#### ( [callback ] )\r\n\r\nReboot the device\r\n\r\n```js\r\ncam.reboot (function () {\r\n  console.log ('Rebooting camera');\r\n});\r\n```\r\n\r\n\r\n### restore_factory\r\n#### ( [callback ] )\r\n\r\nReset all settings back to their factory values.\r\n\r\n```js\r\ncam.restore_factory (function () {\r\n  console.log ('Resetting camera settings to factory defaults');\r\n});\r\n```\r\n\r\n\r\n### talk\r\n#### ( propsObject )\r\n\r\nDirectly communicate with the device.\r\n\r\n\r\nproperty | type     | required | value\r\n---------|----------|----------|----------------------\r\npath     | string   | yes      | i.e. `get_params.cgi`\r\nfields   | object   | no       | i.e. `{ntp_enable: 1, ntp_svr: 'ntp.xs4all.nl'}`\r\nencoding | string   | no       | `binary` or `utf8` (default)\r\ncallback | function | yes      | i.e. `function (err, res)`\r\n\r\n\r\n```js\r\ncam.talk (\r\n  {\r\n    path: 'set_datetime.cgi',\r\n    fields: {\r\n      ntp_enable: 1,\r\n      ntp_svr: 'ntp.xs4all.nl',\r\n      tz: -3600\r\n    }\r\n  },\r\n  function (response) {\r\n    console.log (response);\r\n  }\r\n);\r\n```\r\n\r\n\r\n## Unlicense\r\n\r\nThis is free and unencumbered software released into the public domain.\r\n\r\nAnyone is free to copy, modify, publish, use, compile, sell, or\r\ndistribute this software, either in source code form or as a compiled\r\nbinary, for any purpose, commercial or non-commercial, and by any\r\nmeans.\r\n\r\nIn jurisdictions that recognize copyright laws, the author or authors\r\nof this software dedicate any and all copyright interest in the\r\nsoftware to the public domain. We make this dedication for the benefit\r\nof the public at large and to the detriment of our heirs and\r\nsuccessors. We intend this dedication to be an overt act of\r\nrelinquishment in perpetuity of all present and future rights to this\r\nsoftware under copyright law.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\r\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\r\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r\nOTHER DEALINGS IN THE SOFTWARE.\r\n\r\nFor more information, please refer to \u003chttp://unlicense.org/\u003e\r\n\r\n\r\n## Author\r\n\r\nFranklin van de Meent\r\n| [Website](https://frankl.in)\r\n| [Github](https://github.com/fvdm)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-foscam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffvdm%2Fnodejs-foscam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-foscam/lists"}