{"id":16971591,"url":"https://github.com/thomastjdev/nim_nordnet_api","last_synced_at":"2026-04-15T16:31:36.468Z","repository":{"id":87657467,"uuid":"248808229","full_name":"ThomasTJdev/nim_nordnet_api","owner":"ThomasTJdev","description":"Scraping API for www.nordnet.dk ready to integrate with Home Assistant (Hassio)","archived":false,"fork":false,"pushed_at":"2020-04-21T18:21:58.000Z","size":29,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-11T01:57:44.630Z","etag":null,"topics":["aktier","hassio","home-assistant","nordnet","stocks","stocks-api"],"latest_commit_sha":null,"homepage":"","language":"Nim","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/ThomasTJdev.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":"2020-03-20T16:57:04.000Z","updated_at":"2025-08-08T11:14:53.000Z","dependencies_parsed_at":"2023-03-13T03:02:17.844Z","dependency_job_id":null,"html_url":"https://github.com/ThomasTJdev/nim_nordnet_api","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ThomasTJdev/nim_nordnet_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_nordnet_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_nordnet_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_nordnet_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_nordnet_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasTJdev","download_url":"https://codeload.github.com/ThomasTJdev/nim_nordnet_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_nordnet_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31849703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: 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":["aktier","hassio","home-assistant","nordnet","stocks","stocks-api"],"created_at":"2024-10-14T00:52:50.155Z","updated_at":"2026-04-15T16:31:36.437Z","avatar_url":"https://github.com/ThomasTJdev.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nim_nordnet_api\n\nOkay, not really an API. Actually not even close to an API. Nordnet wasn't gonna\nplay with me, so this ended up as an oldschool scraper.\n\nThe originale purpose to develop a sensor for [https://www.home-assistant.io/](https://www.home-assistant.io/)\n\n\n## What is Nordnet\nNordnet is an online stockbroker with customers in Denmark, Norway, Sweden, and Finland. It serves stock from around the world. Checkout their website www.nordnet.dk and start trading with a low fee and an excellent UI.\n\n## What is this?\nWell, this is a simple scraper. You provide the URL to the stock, and this little Nim program provide you with the latest data on the stock.\n\nYou can use this library in 3 ways:\n1. Normal library, either by cloning the repo or installing with Nimble\n2. CLI tool which outputs the data to the console\n3. Home Assistant \"plugin\" to serve data to your dashboard with automatic adding of sensors\n\n## What not to do\nYou should absolutely not set the scraping interval too low (!!). This is **not** an API provided by Nordnet, so please use it with care for Nordnets servers.\n\n## What's next?\nNothing. Nordnet properly changes their div-structure on monday, and then the scraping is failing.\n\n_Currently been working for a month..._\n\n# How to use it\n\nFor all the 3 methods, you have to provide the URL to stock page. Navigate to the site, e.g. for Novo:\n```url\nhttps://www.nordnet.dk/markedet/aktiekurser/16256554-novo-nordisk-b\n```\n\nNow grab the last part of the url, which is what you need:\n```url\n16256554-novo-nordisk-b\n```\n\nYou can provide multiple URLs, so repeat the above until satisfied.\n\n\n# Normal library\n\n```nim\nimport nordnet\nlet nnObject = nordnetData(\"Novo\", \"16256554-novo-nordisk-b\")\necho nnObject.priceLatest # The price\necho nordnetJson(nnObject) # JsonNode\n```\n\n\n# CLI tool\nJust find the url path and run:\n```bash\n$ nim c -d:ssl -d:release nordnet.nim\n$ ./nordnet 16256554-novo-nordisk-b\n```\n\n# Home Assistant\nThe following is for implementing the data in [https://www.home-assistant.io/](https://www.home-assistant.io/).\n\n## Compile\nFirst compile the file:\n```nim\nnim c -d:ssl -d:release nordnet.nim\n```\n\n## Config file\nThen edit the config file, `config.json`, to your needs.\n\nIf you need to place your config file elsewhere, just edit the `\"config\"` path. Otherwise leave blank.\n```nim\nnano config/config.json\n```\n\n## Auto run\nNow adjust the service file and deploy for autorun:\n```nim\nnano nordnet.service\nsudo cp nordnet.service /etc/systemd/system/nordnet.service\nsudo systemctl enable nordnet\nsudo systemctl start nordnet\nsudo systemctl status nordnet\n```\n\n## Add as sensor to Home Assistant\n\nAs default the stocks will automatic be added as sensors named `sensor.stock_{stockname}`. So just run it, and you can directly after add the sensors to your lovelace frontpage.\n\nA birth message is also supported - if Hass restarts, the config needs to be resend, otherwise the sensor will be inactive. You can setup a birth topic and birth payload inside Hass, which will be send on each boot - we are using that payload to resend the sensors configuration.\n\nIf you **dont** want the sensors added automatic, then set the `autodiscover: false` in the `config.json` - but then you have to add them manually, see the example with Node red below.\n\n### Node red\n\nWe are making 3 nodes:\n\n* MQTT-in node - convert to JSON object\n* Switch node - prepared for more stocks\n* HA entity node - make the sensor\n\n\u003cdetails\u003e\u003csummary\u003eNode red JSON code\u003c/summary\u003e\n[\n    {\n        \"id\": \"99ad52.619902b\",\n        \"type\": \"mqtt in\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"\",\n        \"topic\": \"nordnet/#\",\n        \"qos\": \"2\",\n        \"datatype\": \"json\",\n        \"broker\": \"6e85e811.77a988\",\n        \"x\": 160,\n        \"y\": 460,\n        \"wires\": [\n            [\n                \"a55a5b7e.c1b6f8\"\n            ]\n        ]\n    },\n    {\n        \"id\": \"a55a5b7e.c1b6f8\",\n        \"type\": \"switch\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"Determine stock\",\n        \"property\": \"topic\",\n        \"propertyType\": \"msg\",\n        \"rules\": [\n            {\n                \"t\": \"eq\",\n                \"v\": \"nordnet/Novo\",\n                \"vt\": \"str\"\n            },\n            {\n                \"t\": \"eq\",\n                \"v\": \"nordnet/Alibaba\",\n                \"vt\": \"str\"\n            }\n        ],\n        \"checkall\": \"false\",\n        \"repair\": false,\n        \"outputs\": 2,\n        \"x\": 360,\n        \"y\": 460,\n        \"wires\": [\n            [\n                \"7ec6bbab.c507a4\"\n            ],\n            [\n                \"447985cf.024a3c\"\n            ]\n        ]\n    },\n    {\n        \"id\": \"7ec6bbab.c507a4\",\n        \"type\": \"ha-entity\",\n        \"z\": \"f9f7e30c.acb0a\",\n        \"name\": \"Stock Novo\",\n        \"server\": \"b95e3a52.453dc8\",\n        \"version\": 1,\n        \"debugenabled\": true,\n        \"outputs\": 1,\n        \"entityType\": \"sensor\",\n        \"config\": [\n            {\n                \"property\": \"name\",\n                \"value\": \"nordnet_novo\"\n            },\n            {\n                \"property\": \"device_class\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"icon\",\n                \"value\": \"\"\n            },\n            {\n                \"property\": \"unit_of_measurement\",\n                \"value\": \"DKK\"\n            }\n        ],\n        \"state\": \"payload.Novo.priceLatest\",\n        \"stateType\": \"msg\",\n        \"attributes\": [\n            {\n                \"property\": \"percentToday\",\n                \"value\": \"payload.Novo.percentToday\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"plusminusToday\",\n                \"value\": \"payload.Novo.plusminusToday\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"priceBuy\",\n                \"value\": \"payload.Novo.priceBuy\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"priceSell\",\n                \"value\": \"payload.Novo.priceSell\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"priceHighest\",\n                \"value\": \"payload.Novo.priceHighest\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"priceLowest\",\n                \"value\": \"payload.Novo.priceLowest\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"tradeTotal\",\n                \"value\": \"payload.Novo.tradeTotal\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"orderdepthBuy\",\n                \"value\": \"payload.Novo.orderdepthBuy\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"orderdepthSell\",\n                \"value\": \"payload.Novo.orderdepthSell\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"epochtime\",\n                \"value\": \"payload.Novo.epochtime\",\n                \"valueType\": \"msg\"\n            },\n            {\n                \"property\": \"success\",\n                \"value\": \"payload.Novo.success\",\n                \"valueType\": \"msg\"\n            }\n        ],\n        \"resend\": true,\n        \"outputLocation\": \"\",\n        \"outputLocationType\": \"none\",\n        \"inputOverride\": \"allow\",\n        \"x\": 590,\n        \"y\": 420,\n        \"wires\": [\n            []\n        ]\n    },\n    {\n        \"id\": \"6a83e811.77a988\",\n        \"type\": \"mqtt-broker\",\n        \"z\": \"\",\n        \"name\": \"Main MQTT\",\n        \"broker\": \"127.0.0.1\",\n        \"port\": \"1883\",\n        \"clientid\": \"noderedmqtt\",\n        \"usetls\": false,\n        \"compatmode\": false,\n        \"keepalive\": \"60\",\n        \"cleansession\": true,\n        \"birthTopic\": \"\",\n        \"birthQos\": \"0\",\n        \"birthPayload\": \"\",\n        \"closeTopic\": \"\",\n        \"closeQos\": \"0\",\n        \"closePayload\": \"\",\n        \"willTopic\": \"\",\n        \"willQos\": \"0\",\n        \"willPayload\": \"\"\n    },\n    {\n        \"id\": \"b93f3a12.453dc8\",\n        \"type\": \"server\",\n        \"z\": \"\",\n        \"name\": \"Home Assistant\",\n        \"legacy\": false,\n        \"addon\": true,\n        \"rejectUnauthorizedCerts\": true,\n        \"ha_boolean\": \"y|yes|true|on|home|open\",\n        \"connectionDelay\": true,\n        \"cacheJson\": true\n    }\n]\n\u003c/details\u003e\n\n### Graph\nNow just create a sensor-graph with the sensor `sensor.nordnet_novo`, or use the\n[mini-graph](https://github.com/kalkih/mini-graph-card) with the following code:\n```yaml\ntype: 'custom:mini-graph-card'\nname: 'Stock: Novo'\nicon: 'mdi:chart-bell-curve'\nentities:\n  - entity: sensor.nordnet_novo\n    name: Latest price\nhours_to_show: 168\npoints_per_hour: 30\n\n```\n\n\n# Types\n\n## MqttInfo* = object\n\n\n```nim\n  MqttInfo* = object\n    host*: string\n    port*: int\n    username*: string\n    password*: string\n    topic*: string\n    ssl*: bool\n    clientname*: string\n```\n\n____\n\n\n\n## Nordnetapi* = object\n\n\n```nim\n  Nordnetapi* = object\n    urls*: seq[string]\n    wait*: int\n    refresh*: int\n```\n\n____\n\n\n\n## Nordnet* = object\n\n\n```nim\n  Nordnet* = object\n    success*: bool\n    name*: string\n    epochtime*: int\n    priceLatest*: float\n    priceBuy*: float\n    priceSell*: float\n    priceHighest*: float\n    priceLowest*: float\n    percentToday*: float\n    plusminusToday*: float\n    tradeTotal*: int\n    orderdepthSell*: int\n    orderdepthBuy*: int\n```\n\n____\n\n\n\n# Procs\n\n## nordnetConfig*\n\n```nim\nproc nordnetConfig*(configPath = \"config/config.json\") =\n```\n\nLoad the config\n\n\n____\n\n## nordnetData*\n\n```nim\nproc nordnetData*(name, url: string): Nordnet =\n```\n\nScrape the data and return the Nordnet object\n\n```nim\n(success: true, name: \"Novo\", epochtime: 1584771256, priceLatest: 359.35, priceBuy: 359.35, priceSell: 359.35, priceHighest: 381.5, priceLowest: 355.75, percentToday: -1.55, plusminusToday: -5.65, tradeTotal: 6914045, orderdepthSell: 0, orderdepthBuy: 0)\n```\n\n\n____\n\n## nordnetJson*\n\n```nim\nproc nordnetJson*(nn: Nordnet): JsonNode =\n```\n\nTransform the Nordnet object to a JsonNode\n\n```json\n{\n    \"Novo\": {\n        \"priceLatest\": 359.35,\n        \"percentToday\": -1.55,\n        \"plusminusToday\": -5.65,\n        \"priceBuy\": 359.35,\n        \"priceSell\": 359.35,\n        \"priceHighest\": 381.5,\n        \"priceLowest\": 355.75,\n        \"tradeTotal\": 6914045,\n        \"orderdepthBuy\": 0,\n        \"orderdepthSell\": 0,\n        \"epochtime\": 1584771256,\n        \"success\": true\n    }\n}\n```\n\n\n____\n\n## apiRun*\n\n```nim\nproc apiRun*() {.async.} =\n```\n\nRun the async scraping. This will first load the config into\nmemory, then connect to the mqtt broker, and then do the\nfirst scraping. After the first scraping the loading time\nwill start.\n\n\n____\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomastjdev%2Fnim_nordnet_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomastjdev%2Fnim_nordnet_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomastjdev%2Fnim_nordnet_api/lists"}