{"id":41535107,"url":"https://github.com/devicehive/devicehive-go","last_synced_at":"2026-01-23T23:54:34.513Z","repository":{"id":77433309,"uuid":"127413749","full_name":"devicehive/devicehive-go","owner":"devicehive","description":"Golang client library for DeviceHive","archived":false,"fork":false,"pushed_at":"2018-07-27T11:29:16.000Z","size":479,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-12T22:39:25.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devicehive.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-30T10:10:13.000Z","updated_at":"2019-12-08T21:54:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"4daeb68d-66ab-4e02-ad95-671bfd06b5d7","html_url":"https://github.com/devicehive/devicehive-go","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devicehive/devicehive-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devicehive%2Fdevicehive-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devicehive%2Fdevicehive-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devicehive%2Fdevicehive-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devicehive%2Fdevicehive-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devicehive","download_url":"https://codeload.github.com/devicehive/devicehive-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devicehive%2Fdevicehive-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28703280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T23:51:44.727Z","status":"ssl_error","status_checked_at":"2026-01-23T23:51:36.079Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-23T23:54:28.725Z","updated_at":"2026-01-23T23:54:34.508Z","avatar_url":"https://github.com/devicehive.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeviceHive SDK for GO\n\nGenerally Golang SDK for DeviceHive consists of 2 APIs, feel free to choose yours:\n- client (a.k.a. high-level client) — provides synchronous API and ORM-like access to DeviceHive models\n- WS client (a.k.a. WS low-level client) — provides asynchronous API: just sends the request and returns an error only in case of request error,\nall raw response data and response errors are written to appropriate channels which are created after WS connection is established\n(for more details see [documentation](#documentation))\n\n## Installation\n\n    go get -u github.com/devicehive/devicehive-go\n\n## Documentation\nVisit https://godoc.org/github.com/devicehive/devicehive-go for full API reference.\n\n## Usage\n### Connection\n\n    import (\n        \"github.com/devicehive/devicehive-go\"\n        \"fmt\"\n    )\n\n    func main() {\n        client, err := devicehive_go.ConnectWithCreds(\"ws://devicehive-address.com/api/websocket\", \"login\", \"password\")\n        // OR\n        client, err := devicehive_go.ConnectWithToken(\"ws://devicehive-address.com/api/websocket\", \"jwt.Access.Token\", \"jwt.Refresh.Token\")\n        if err != nil {\n            fmt.Println(err)\n            return\n        }\n    }\n\n### Device creation\n\n    import (\n    \t\"github.com/devicehive/devicehive-go\"\n    \t\"fmt\"\n    )\n\n    func main() {\n    \tclient, err := devicehive_go.ConnectWithCreds(\"ws://devicehive-address.com/api/websocket\", \"login\", \"password\")\n    \tif err != nil {\n    \t\tfmt.Println(err)\n    \t\treturn\n    \t}\n\n    \tdevice, err := client.PutDevice(\"my-device1\", \"\", nil, 0, 0, false)\n    \tif err != nil {\n    \t\tfmt.Println(err)\n    \t\treturn\n    \t}\n\n    \tfmt.Println(device)\n    }\n\n### Command insert subscription\n\n    import (\n        \"github.com/devicehive/devicehive-go\"\n        \"fmt\"\n        \"time\"\n    )\n\n    func main() {\n        client, err := devicehive_go.ConnectWithCreds(\"ws://devicehive-address.com/api/websocket\", \"login\", \"password\")\n        if err != nil {\n            fmt.Println(err)\n            return\n        }\n\n        device, err := client.GetDevice(\"my-device\")\n        if err != nil {\n            fmt.Println(err)\n            return\n        }\n\n        subscription, err := device.SubscribeInsertCommands(nil, time.Time{})\n        if err != nil {\n            fmt.Println(err)\n            return\n        }\n\n        for command := range subscription.CommandsChan {\n            fmt.Println(command)\n        }\n    }\n\n## Running tests\nIntegration tests of high-level DH client:\n\n    go test github.com/devicehive/devicehive-go/integrationtest/dh -serverAddress ws://devicehive-api.com/ -accessToken your.accessToken -refreshToken your.accessToken -userId 123\n\nIntegration tests of low-level DH WS client (only ws:// URL is acceptable for this tests as server address):\n\n    go test github.com/devicehive/devicehive-go/integrationtest/dh_wsclient -serverAddress ws://devicehive-api.com/ -accessToken your.accessToken -refreshToken your.accessToken -userId 123\n\nUnit tests:\n\n    go test github.com/devicehive/devicehive-go/test/...\n\n## Technical description\n### Overview\nThere are three layers under the hood of DeviceHive Go SDK: Client layer, Transport adapter layer and Transport layer.\n![Overall architecture of DeviceHive Go SDK](go_sdk_structure.jpg)\n\u003cbr\u003e\n**Client** layer is responsible for all high level business logic (request parameters, models etc.). It knows nothing about protocol in use. \u003cbr\u003e\n**Transport adapter** layer orchestrates a few components:\n- *Transport* (Transporter interface on diagram): low level component\n- *AuthManager*: responsible for token creation; holds credentials, used for tracking last token refresh and authentication\n- *Requester*: responsible for composing request data, URLs for HTTP and actions for WS, handles responses using *responsehandler* package\n- *responsehandler*: parses responses and returns payload in common format\n\nTransport adapter has two implementations so far: WSAdapter and HTTPAdapter. \u003cbr\u003e\n**Transport** layer is responsible for doing basic requests and subscriptions. Has two implementations: WS and HTTP.\n### Resolving request resources\nSince DeviceHive Go SDK supports HTTP and WS through single interface there is the mapping between custom resource names and URL pattern (for HTTP) or action (for WS). Similar mapping is present for response parsing.\n### Subscriptions\nEach layer (Client, Transport adapter and Transport) handles subscriptions in some way so there is a pipeline constructed from 3 go routines, one on each level.\nThe generic functionality for subscriptions is implemented on Transport layer.\nIn case of WS connection Transport just sends subscription request and then sends each message with subscription ID to corresponding subscription channel. In case of HTTP it creates go routine with polling for each subscription. \u003cbr\u003e\nOn Transport adapter layer there is another go routine for each subscription to parse and transform subscription data, identify errors. Finally on Client layer there is go routine for each subscription to populate models with raw JSON data and send that object to client-facing channel.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevicehive%2Fdevicehive-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevicehive%2Fdevicehive-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevicehive%2Fdevicehive-go/lists"}