{"__v":1,"_id":"564d1afb4567342100ad96be","category":{"__v":1,"_id":"564d1af94567342100ad96ae","pages":["564d1afb4567342100ad96bb","564d1afb4567342100ad96bc","564d1afb4567342100ad96bd","564d1afb4567342100ad96be","564d1afb4567342100ad96bf"],"project":"551375e1d04af219007ddc52","version":"564d1af84567342100ad96aa","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-27T02:56:56.435Z","from_sync":false,"order":3,"slug":"data-retrieval","title":"Data Retrieval"},"project":"551375e1d04af219007ddc52","user":"5539912a0074c80d00621b14","version":{"__v":1,"_id":"564d1af84567342100ad96aa","project":"551375e1d04af219007ddc52","createdAt":"2015-11-19T00:42:32.705Z","releaseDate":"2015-11-19T00:42:32.705Z","categories":["564d1af94567342100ad96ab","564d1af94567342100ad96ac","564d1af94567342100ad96ad","564d1af94567342100ad96ae","564d1af94567342100ad96af","564d1af94567342100ad96b0","564d1af94567342100ad96b1","564d1af94567342100ad96b2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-01T01:21:53.314Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"You can make use of the `/sources` endpoint to view the type and synchronization status of the services that a user has connected. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"For information on keeping your database synchronized and up-to-date with Human API, please see the guide on [data sync best practices](doc:data-synchronization).\"\n}\n[/block]\nTo retrieve information on connected sources, query the /source endpoint:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"https://api.humanapi.co/v1/human/sources?access_token=demo\",\n      \"language\": \"text\",\n      \"name\": \"\"\n    }\n  ]\n}\n[/block]\nThe result payload is an array of the services and the synchronization properties related to each specific source:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[\\n  {\\n    \\\"id\\\": \\\"551ac6ef15eab1445e527c64\\\",\\n    \\\"source\\\": \\\"fitbit\\\",\\n    \\\"supportedDataTypes\\\": [\\n        \\\"activities\\\",\\n        \\\"bmi\\\",\\n        \\\"body_fat\\\",\\n        \\\"food\\\",\\n        \\\"sleeps\\\",\\n        \\\"height\\\",\\n        \\\"weight\\\"\\n    ],\\n    \\\"devices\\\": [\\n        \\\"Fitbit Charge HR\\\",\\n        \\\"Fitbit Aria\\\"\\n    ],\\n    \\\"connectedSince\\\": \\\"2015-03-31T16:10:23.382Z\\\",\\n    \\\"historySync\\\": {\\n        \\\"status\\\": \\\"completed\\\",\\n        \\\"oldestDate\\\": \\\"2015-03-21T00:00:00.000Z\\\"\\n    },\\n    \\\"syncStatus\\\": {\\n        \\\"status\\\": \\\"ok\\\",\\n        \\\"synchedAt\\\": \\\"2015-08-11T22:17:08.218Z\\\",\\n        \\\"newestDate\\\": \\\"2015-08-11T00:00:00.000Z\\\"\\n    }\\n  }\\n]\",\n      \"language\": \"json\",\n      \"name\": \"Wellness\"\n    },\n    {\n      \"code\": \"{\\n  \\\"id\\\": \\\"54cd4697a7b875300999ff44\\\",\\n  \\\"source\\\": \\\"emr-1-320\\\",\\n  \\\"connectedSince\\\": \\\"2015-01-31T21:18:15.672Z\\\",\\n  \\\"devices\\\": [\\n    \\\"emr-1-320\\\"\\n  ],\\n  \\\"historySync\\\": {\\n    \\\"status\\\": \\\"completed\\\"\\n  },\\n  \\\"sourceName\\\": \\\"Cleveland Clinic\\\",\\n  \\\"organization\\\": {\\n    \\\"id\\\": \\\"53c050ac51c69003200aa998\\\",\\n    \\\"name\\\": \\\"Cleveland Clinic\\\",\\n    \\\"href\\\": \\\"/medical/organizations/53c050ac51c69003200aa998\\\"\\n  }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Medical\"\n    }\n  ]\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`source`\",\n    \"1-0\": \"`supportedDataTypes`\",\n    \"2-0\": \"`devices`\",\n    \"3-0\": \"`connectedSince`\",\n    \"3-1\": \"`Date`\",\n    \"2-1\": \"`Array[String]`\",\n    \"1-1\": \"`Array[String]`\",\n    \"0-1\": \"`String`\",\n    \"0-2\": \"Name of the connected source (all lowercase, no spaces)\",\n    \"1-2\": \"List of data types supported by the source \\n(does not indicate data is available for each type)\",\n    \"2-2\": \"List of devices \\n(when available)\",\n    \"3-2\": \"Date source was connected to Human API\",\n    \"4-0\": \"`historySync`\",\n    \"4-1\": \"`Object`\",\n    \"5-0\": \"`syncStatus`\",\n    \"5-1\": \"`Object`\",\n    \"4-2\": \"See \\\"Historical Data Synchronization\\\" below\",\n    \"5-2\": \"See \\\"Current Synchronization Status\\\" below\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Device Information\",\n  \"body\": \"The `source` attribute will be available immediately once you receive tokens for a user. In contrast, the `devices` array is updated on the first sync with the source, and thus takes a few seconds before it is available. \\n\\nBest practice for updating your UI is to check `source` immediately upon receiving tokens and wait for a notification to sync `device` information when it is available.\"\n}\n[/block]\n#Historical Synchronization Status\nThe `historySync` information refers to the synchronization of historical data for the particular user. \n\n - `historySync.status` tells if the synchronization is complete or not.\n - `historySync.oldestDate` is the oldest date of the data retrieved from the service.\n    \nSome services can take time to synchronize all the data, so you can query this endpoint and look at historySync.status to determine if it is completed or not, and once it is complete you can use historySync.oldestDate to determine how much data is available for this user.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"For some services, `historySync.oldestDate` is just an indication of how far back the synchronization tasks attempted to retrieve data. It is not a guarantee that there is data available for this date.\"\n}\n[/block]\n\n\n\n#Current Synchronization Status\nThe `syncStatus` property contains data about the current data synchronization tasks and indicates if the services sync is working properly or not. \n\n- `syncStatus.synchedAt` shows the last time the synchronization task ran for this user\n- `syncStatus.newestDate` shows the timestamp for the last retrieved data.\n \nOne thing to keep in mind about these timestamps is that they do not indicate that the data was updated at this time. It just means that we attempted to retrieve data at this point in time.\n\n#Unsupported services\nSome services do not synchronize data continuously or do not support historical data synchronization. These services will show status `not_supported`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  source: \\\"23andme\\\",\\n  supportedDataTypes: [\\n    \\\"genetics\\\"\\n  ],\\n  connectedSince: \\\"2013-07-23T22:17:49.870Z\\\",\\n  historySync: {\\n    status: \\\"not_supported\\\"\\n  },\\n  syncStatus: {\\n     status: \\\"not_started\\\"\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"source-sync-status","type":"basic","title":"Source Sync Status"}

Source Sync Status


You can make use of the `/sources` endpoint to view the type and synchronization status of the services that a user has connected. [block:callout] { "type": "info", "body": "For information on keeping your database synchronized and up-to-date with Human API, please see the guide on [data sync best practices](doc:data-synchronization)." } [/block] To retrieve information on connected sources, query the /source endpoint: [block:code] { "codes": [ { "code": "https://api.humanapi.co/v1/human/sources?access_token=demo", "language": "text", "name": "" } ] } [/block] The result payload is an array of the services and the synchronization properties related to each specific source: [block:code] { "codes": [ { "code": "[\n {\n \"id\": \"551ac6ef15eab1445e527c64\",\n \"source\": \"fitbit\",\n \"supportedDataTypes\": [\n \"activities\",\n \"bmi\",\n \"body_fat\",\n \"food\",\n \"sleeps\",\n \"height\",\n \"weight\"\n ],\n \"devices\": [\n \"Fitbit Charge HR\",\n \"Fitbit Aria\"\n ],\n \"connectedSince\": \"2015-03-31T16:10:23.382Z\",\n \"historySync\": {\n \"status\": \"completed\",\n \"oldestDate\": \"2015-03-21T00:00:00.000Z\"\n },\n \"syncStatus\": {\n \"status\": \"ok\",\n \"synchedAt\": \"2015-08-11T22:17:08.218Z\",\n \"newestDate\": \"2015-08-11T00:00:00.000Z\"\n }\n }\n]", "language": "json", "name": "Wellness" }, { "code": "{\n \"id\": \"54cd4697a7b875300999ff44\",\n \"source\": \"emr-1-320\",\n \"connectedSince\": \"2015-01-31T21:18:15.672Z\",\n \"devices\": [\n \"emr-1-320\"\n ],\n \"historySync\": {\n \"status\": \"completed\"\n },\n \"sourceName\": \"Cleveland Clinic\",\n \"organization\": {\n \"id\": \"53c050ac51c69003200aa998\",\n \"name\": \"Cleveland Clinic\",\n \"href\": \"/medical/organizations/53c050ac51c69003200aa998\"\n }\n}", "language": "json", "name": "Medical" } ] } [/block] [block:parameters] { "data": { "h-0": "Property", "h-1": "Type", "h-2": "Description", "0-0": "`source`", "1-0": "`supportedDataTypes`", "2-0": "`devices`", "3-0": "`connectedSince`", "3-1": "`Date`", "2-1": "`Array[String]`", "1-1": "`Array[String]`", "0-1": "`String`", "0-2": "Name of the connected source (all lowercase, no spaces)", "1-2": "List of data types supported by the source \n(does not indicate data is available for each type)", "2-2": "List of devices \n(when available)", "3-2": "Date source was connected to Human API", "4-0": "`historySync`", "4-1": "`Object`", "5-0": "`syncStatus`", "5-1": "`Object`", "4-2": "See \"Historical Data Synchronization\" below", "5-2": "See \"Current Synchronization Status\" below" }, "cols": 3, "rows": 6 } [/block] [block:callout] { "type": "warning", "title": "Device Information", "body": "The `source` attribute will be available immediately once you receive tokens for a user. In contrast, the `devices` array is updated on the first sync with the source, and thus takes a few seconds before it is available. \n\nBest practice for updating your UI is to check `source` immediately upon receiving tokens and wait for a notification to sync `device` information when it is available." } [/block] #Historical Synchronization Status The `historySync` information refers to the synchronization of historical data for the particular user. - `historySync.status` tells if the synchronization is complete or not. - `historySync.oldestDate` is the oldest date of the data retrieved from the service. Some services can take time to synchronize all the data, so you can query this endpoint and look at historySync.status to determine if it is completed or not, and once it is complete you can use historySync.oldestDate to determine how much data is available for this user. [block:callout] { "type": "info", "body": "For some services, `historySync.oldestDate` is just an indication of how far back the synchronization tasks attempted to retrieve data. It is not a guarantee that there is data available for this date." } [/block] #Current Synchronization Status The `syncStatus` property contains data about the current data synchronization tasks and indicates if the services sync is working properly or not. - `syncStatus.synchedAt` shows the last time the synchronization task ran for this user - `syncStatus.newestDate` shows the timestamp for the last retrieved data. One thing to keep in mind about these timestamps is that they do not indicate that the data was updated at this time. It just means that we attempted to retrieve data at this point in time. #Unsupported services Some services do not synchronize data continuously or do not support historical data synchronization. These services will show status `not_supported`. [block:code] { "codes": [ { "code": "{\n source: \"23andme\",\n supportedDataTypes: [\n \"genetics\"\n ],\n connectedSince: \"2013-07-23T22:17:49.870Z\",\n historySync: {\n status: \"not_supported\"\n },\n syncStatus: {\n status: \"not_started\"\n }\n}", "language": "json" } ] } [/block]