{"id":13584731,"url":"https://github.com/gboudreau/nest-api","last_synced_at":"2025-04-04T12:08:40.041Z","repository":{"id":4869349,"uuid":"6024283","full_name":"gboudreau/nest-api","owner":"gboudreau","description":"Unofficial Nest Learning Thermostat API","archived":false,"fork":false,"pushed_at":"2021-07-27T16:23:29.000Z","size":438,"stargazers_count":298,"open_issues_count":20,"forks_count":92,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-03-28T11:09:21.190Z","etag":null,"topics":["api","nest","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"sindresorhus/grunt-ftp","license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gboudreau.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":"2012-10-01T01:51:59.000Z","updated_at":"2025-01-27T09:30:01.000Z","dependencies_parsed_at":"2022-09-15T16:10:54.040Z","dependency_job_id":null,"html_url":"https://github.com/gboudreau/nest-api","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gboudreau%2Fnest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gboudreau%2Fnest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gboudreau%2Fnest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gboudreau%2Fnest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gboudreau","download_url":"https://codeload.github.com/gboudreau/nest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174423,"owners_count":20896078,"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","nest","php"],"created_at":"2024-08-01T15:04:29.018Z","updated_at":"2025-04-04T12:08:40.025Z","avatar_url":"https://github.com/gboudreau.png","language":"PHP","readme":"Unofficial Nest Learning Thermostat API\n=======================================\n\nThis is a PHP class that will allow you to monitor and control your [Nest Learning Thermostat](http://www.nest.com/), and Nest Protect.\n\n__Note that since I started this, Nest have started an official [Developer program](https://developer.nest.com/). You might be better served using the official APIs, versus this PHP class here in which you need to store your credentials in plain text, and which use the non-supported APIs used by the mobile \u0026 web apps.  \ni.e. if you're building a serious commercial application, go sign-up into Nest's Developer program. If you just want to build something for yourself, then you're probably fine with this PHP class here.__\n\nFeatures\n--------\n\n- Caching so that it doesn't re-login when it doesn't need to. i.e. faster operations.\n- Getters:\n    - Current \u0026 target temperatures, humidity\n    - Time to target temperature\n    - Target temperature mode, fan mode\n    - AC, heat, and fan status: on or off\n    - Manual and automatic away mode\n    - Location information\n    - Network information (local \u0026 WAN IPs, MAC address, online status)\n    - Currently active schedule (by day)\n    - Next scheduled event\n    - Last 10 days energy report\n    - Device name, devices list\n    - Battery level (voltage)\n    - Nest Protect device information\n- Setters:\n    - Target temperatures (single, or range)\n    - Target temperature mode: cool, heat, range\n    - Fan mode: auto, on, minutes per hour\n    - Fan: every day schedule (start \u0026 stop time)\n    - Fan: on with timer (stops after X minutes/hours)\n    - Eco (Away) mode: on, off, min/max temperatures, Auto-Away\n    - Dual fuel: breakpoint (use alt. fuel when outdoor temp is below X), always alt, always primary\n    - Safety temperatures (low \u0026 high temperatures)\n    - Humidity (on, off, %)\n    - Turn off HVAC\n\nUsage\n-----\n\nYou can just download nest.class.php and require/include it, or use composer: `require \"gboudreau/nest-api\": \"dev-master\"`.\n\nSee examples.php for details, but here's a Quick Start.\n\n```php\n\u003c?php\n\nrequire_once('nest.class.php');\n\n// Use a Nest account:\n$username = 'you@gmail.com';\n$pasword = 'Something other than 1234 right?';\n$nest = new Nest($username, $pasword);\n\n// Or use a Google account (see instructions below on how to find those values):\n$issue_token = 'https://accounts.google.com/o/oauth2/iframerpc?action=issueToken\u0026response_type=token%20id_token\u0026login_hint=UNIQUE_VALUE_HERE\u0026client_id=733249279899-44tchle2kaa9afr5v9ov7jbuojfr9lrq.apps.googleusercontent.com\u0026origin=https%3A%2F%2Fhome.nest.com\u0026scope=openid%20profile%20email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fnest-account\u0026ss_domain=https%3A%2F%2Fhome.nest.com';\n$cookies = '#YOUR_COOKIES_HERE#'; // All on one line; remove any new-line character you might have\n$nest = new Nest(NULL, NULL, $issue_token, $cookies);\n\n// Get the device information:\n$infos = $nest-\u003egetDeviceInfo();\nprint_r($infos);\n    \n// Print the current temperature\nprintf(\"Current temperature: %.02f degrees %s\\n\", $infos-\u003ecurrent_state-\u003etemperature, $infos-\u003escale);\n\n// Cool to 23\n$nest-\u003esetTargetTemperatureMode(TARGET_TEMP_MODE_COOL, 23.0);\n    \n// Set Away mode\n$nest-\u003esetAway(TRUE);\n\n// Turn off Away mode\n$nest-\u003esetAway(FALSE);\n```\n\nExample output for `getDeviceInfo()`:\n\n```json\n{\n  \"current_state\": {\n    \"mode\": \"range\",\n    \"temperature\": 24.09999,\n    \"humidity\": 42,\n    \"ac\": false,\n    \"heat\": false,\n    \"fan\": true,\n    \"auto_away\": 0,\n    \"manual_away\": false,\n    \"leaf\": false,\n    \"battery_level\": 3.948\n  },\n  \"target\": {\n    \"mode\": \"range\",\n    \"temperature\": [\n      23,\n      26\n    ],\n    \"time_to_target\": 0\n  },\n  \"serial_number\": \"01AB02BA117210S5\",\n  \"scale\": \"C\",\n  \"location\": \"1061f350-a2f1-111e-b9eb-123e8b139117\",\n  \"network\": {\n    \"online\": true,\n    \"last_connection\": \"2012-09-30 21:26:25\",\n    \"wan_ip\": \"173.246.19.71\",\n    \"local_ip\": \"192.168.1.201\",\n    \"mac_address\": \"18b430046194\"\n  }\n}\n```\n\nUse try...catch to catch exceptions that could occur:\n```php\ntry {\n    $nest = new Nest(NULL, NULL, $issue_token, $cookies);\n    // Execute all Nest-related code here\n} catch (UnexpectedValueException $ex) {\n    // Happens when the issue_token or cookie is not working, for whatever reason\n    $error_message = $ex-\u003egetMessage();\n    mail(...);\n} catch (RuntimeException $ex) {\n    // Probably a temporary server-error\n} catch (Exception $ex) {\n    // Other errors; should not happen if it worked in the past\n}\n\n// Continue your code here, for example to save the result in a database\n```\n\nUsing a Google Account\n----------------------\nThe values of `$issue_token`, and `$cookies` are specific to your Google Account. To get them, follow these steps (only needs to be done once, as long as you stay logged into your Google Account).\n\n- Open a Chrome browser tab in Incognito Mode (or clear your cache).\n- Open Developer Tools (View/Developer/Developer Tools).\n- Click on `Network` tab. Make sure `Preserve Log` is checked.\n- In the `Filter` box, enter `issueToken`\n- Go to https://home.nest.com, and click `Sign in with Google`. Log into your account.\n- One network call (beginning with `iframerpc`) will appear in the Dev Tools window. Click on it.\n- In the `Headers` tab, under `General`, copy the entire `Request URL` (beginning with `https://accounts.google.com`, ending with `nest.com`). This is your `$issue_token`.\n- In the `Filter` box, enter `oauth2/iframe`\n- Several network calls will appear in the Dev Tools window. Click on the last iframe call.\n- In the `Headers` tab, under `Request Headers`, copy the entire cookie value (include the whole string which is several lines long and has many field/value pairs - do not include the `Cookie:` prefix). This is your `$cookies`; make sure all of it is on a single line.\n\nTroubleshooting\n---------------\nIf you have any issues, try adding this at the top of your PHP script, to ask PHP to echo all errors and warnings.\n\n```php\nerror_reporting(E_ALL);\n```\n\nAcknowledgements\n----------------\n\n- Jacob McSwain, https://github.com/USA-RedDragon\n    for https://github.com/USA-RedDragon/badnest\n- Chris J. Shull, https://github.com/chrisjshull\n    for https://github.com/chrisjshull/homebridge-nest/\n- Andy Blyler, http://andyblyler.com/\n    for https://github.com/ablyler/nest-php-api\n- Scott M Baker, http://www.smbaker.com/\n    for https://github.com/smbaker/pynest\n- Chris Burris, http://www.chilitechno.com/\n    for https://github.com/chilitechno/SiriProxy-NestLearningThermostat\n- Chad Corbin\n    for http://code.google.com/p/jnest/\n- Aaron Cornelius\n    for http://www.wiredprairie.us/blog/index.php/archives/1442\n\nDeveloped mainly using a free open-source license of PHPStorm kindly provided by [JetBrains](http://www.jetbrains.com/). Thanks guys!\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgboudreau%2Fnest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgboudreau%2Fnest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgboudreau%2Fnest-api/lists"}