{"id":20578122,"url":"https://github.com/timeplus-io/nodejs-sample","last_synced_at":"2025-06-27T00:07:39.351Z","repository":{"id":172112245,"uuid":"612446236","full_name":"timeplus-io/nodejs-sample","owner":"timeplus-io","description":"sample code of nodejs","archived":false,"fork":false,"pushed_at":"2024-12-11T13:40:57.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-06T11:39:39.748Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/timeplus-io.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":"2023-03-11T01:08:42.000Z","updated_at":"2024-12-11T13:41:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"262d85e6-5e6c-4275-a8f8-50cf158ae3aa","html_url":"https://github.com/timeplus-io/nodejs-sample","commit_stats":null,"previous_names":["timeplus-io/nodejs-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/timeplus-io/nodejs-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fnodejs-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fnodejs-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fnodejs-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fnodejs-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timeplus-io","download_url":"https://codeload.github.com/timeplus-io/nodejs-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timeplus-io%2Fnodejs-sample/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262164302,"owners_count":23268781,"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":[],"created_at":"2024-11-16T06:10:41.432Z","updated_at":"2025-06-27T00:07:39.330Z","avatar_url":"https://github.com/timeplus-io.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\nWelcome to Timeplus! This package contains some sample TypeScript code to demostorate how to access the REST API of Timeplus programmatically. Please check `src/app.ts` for the sample code.\n\nFor detailed documentation about the REST API, please visit https://docs.timeplus.com/rest.html.\n\nThis starter-kit is tested on nodejs **v19.7.0**.\n\n## Install\n\n```\nnpm install\n```\n\n## Config\n\nto run the demo code, you can use env variable to point to a Timeplus environment (either cloud or self-hosted)\n\n```\n# For Timeplus Enterprise Cloud\nexport TIMEPLUS_ISCLOUD=true\nexport TIMEPLUS_WORKSPACE=\u003cyour workspace name\u003e\nexport TIMEPLUS_APIKEY=\u003cyour api key\u003e\nexport TIMEPLUS_ADDRESS=https://us-west-2.timeplus.cloud\n\n# For Timeplus Enterprise (self-hosted)\nexport TIMEPLUS_USERNAME=proton\nexport TIMEPLUS_PASSWORD=proton@t+\nexport TIMEPLUS_ADDRESS=http://localhost:8000\n```\n\nyou can create the api key in your timeplus console UI from personal settings.\n\n## Run\n\n```\nnpm start\n```\n\n## What is the demo code\n\nin the demo code, it shows how to create a stream, and then ingest some data and the run a query to get those data in the stream.\n\n### create stream\n\nrefer to https://docs.timeplus.com/rest.html#tag/Streams-v1beta2/paths/~1v1beta2~1streams/post\n\nplease note, in the sample, a key-version streaming is created, in case you want to create an append-only stream, remove those two fields `mode` and `primary_key` from the `createStreamBody`\n\n### ingest\n\nrefer to https://docs.timeplus.com/rest.html#tag/Streams-v1beta2/paths/~1v1beta2~1streams~1%7Bname%7D~1ingest/post\n\n### query\n\nrefer to https://docs.timeplus.com/rest.html#tag/Queries-v1beta2/paths/~1v1beta2~1queries/post\n\n#### query metadata\n\nsome important query metadata are\n\n- `query.id` the unique id of the query\n- `query.status` the status of the query, `running`,`finished`,`failed`,`canceled`\n- `query.startTime`,`query.endTime`\n- `query.header` the column definition of the result table\n\n```\n┌─────────┬────────────┬────────────────────────┐\n│ (index) │ name       │ type                   │\n├─────────┼────────────┼────────────────────────┤\n│ 0       │ 'category' │ 'string'               │\n│ 1       │ 'value'    │ 'int64'                │\n│ 2       │ 'uuid'     │ 'string'               │\n│ 3       │ '\\_tp_time'│ \"datetime64(3, 'UTC')\" │\n└─────────┴────────────┴────────────────────────┘\n```\n\n#### query result\n\nthe query result have two different types of payloads, `data row` or `metrics`\n\nfor data row, it is an array of array:\n\n```\n[\n  [\n    'cat_1',\n    11,\n    'ebd9f9ab-4df4-4269-81af-262303c4b375',\n    '2023-03-11T00:44:47.034Z'\n  ],\n  [\n    'cat_2',\n    20,\n    '2dd8823d-2d7b-4fc4-940c-70d6f29619c0',\n    '2023-03-11T00:44:47.034Z'\n  ],\n  [\n    'cat_3',\n    30,\n    'b204922d-139b-4189-8f5d-95d82714114e',\n    '2023-03-11T00:44:47.034Z'\n  ]\n]\n```\n\nfor metrics , it is a json object:\n\n```\n{\n  count: 3,\n  eps: 3,\n  processing_time: 1,\n  last_event_time: 1678495492,\n  response_time: 0,\n  scanned_rows: 4,\n  scanned_bytes: 300\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimeplus-io%2Fnodejs-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimeplus-io%2Fnodejs-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimeplus-io%2Fnodejs-sample/lists"}