{"id":36539542,"url":"https://github.com/spin-fi/near-dex-core-js","last_synced_at":"2026-01-12T05:39:48.636Z","repository":{"id":65598781,"uuid":"486218037","full_name":"spin-fi/near-dex-core-js","owner":"spin-fi","description":"@spinfi/core","archived":false,"fork":false,"pushed_at":"2023-01-25T23:19:20.000Z","size":884,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T21:59:54.362Z","etag":null,"topics":["core","dex","near","spin"],"latest_commit_sha":null,"homepage":"https://spin-fi.github.io/near-dex-core-js/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spin-fi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-27T14:06:40.000Z","updated_at":"2023-06-03T13:36:28.000Z","dependencies_parsed_at":"2023-02-14T12:17:11.006Z","dependency_job_id":null,"html_url":"https://github.com/spin-fi/near-dex-core-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/spin-fi/near-dex-core-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spin-fi%2Fnear-dex-core-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spin-fi%2Fnear-dex-core-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spin-fi%2Fnear-dex-core-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spin-fi%2Fnear-dex-core-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spin-fi","download_url":"https://codeload.github.com/spin-fi/near-dex-core-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spin-fi%2Fnear-dex-core-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28335226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["core","dex","near","spin"],"created_at":"2026-01-12T05:39:47.529Z","updated_at":"2026-01-12T05:39:48.631Z","avatar_url":"https://github.com/spin-fi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Links\n\n- [**Contract api**](https://docs.api.spin.fi/#introduction)\n\n- [**JS api**](https://spin-fi.github.io/near-dex-core-js/)\n\n- [**@spinfi/core**](https://github.com/spin-fi/near-dex-core-js)\n\n- [**@spinfi/node**](https://github.com/spin-fi/near-dex-node-js)\n\n# @spinfi/node\n\nSpin node create spin api for node\n\n### How to install\n\n```bash\nyarn add @spinfi/node\n```\n\n### How to init\n\n```js\nconst {spin} = await createApi({\n  accountId: 'some account id value',\n  privateKey: 'some private key value',\n});\n```\n\n# @spinfi/core\n\nSpin core create spin api instace that work exactly in browser and node.js\n\n```js\nconst response = await spin.depositFt(request);\n```\n\n## Websocket\n\nWebsocket property provide functions to call `spin` off-chain methods by websocket\n\nWebsocket method divided in two types:\n\n- method (similar to async call with callback)\n- subscription\n\n### 1. Method\n\nMethod require some parameters in `json rpc` format and return some data with `onOk` callback.\nIf websocket return not expected data format - api will ignore it. If websocket return correct\nmessage without connection/js error, but with error field - data handled by `onError` callback\n\n### How to use\n\n```js\nconst unsubscribe = spin.ping({\n  onOk: (data) =\u003e console.log(data),\n  onError: (error) =\u003e console.error(error),\n});\n```\n\n### 2. Subscription\n\nSubscription its like method but more complex. It work like that:\n\n- subscription send method `sub` and create `channel` to server\n- if `sub` ok (channel created) then api create listners for websocket\n- if new websocket message its for `channel` then api call corresponding subscription callbacks\n\n```js\nconst unsubscribe = spin.listenOrders(request, {\n  onSubOk: (data) =\u003e console.log(data),\n  onSubError: (error) =\u003e console.error(error),\n});\n```\n\nChannel - its stream of websocket message that have same `subscription id` and have some format.\nMessages in channel maybe different. Some channel have first uniq message and some not.\nFirst uniq message in channel its `state` and other messages its `notification`\n\nWebsoket message match with channel by `json rpc` id created when subscription called and `subscription id`\ncreated by server\n\n```js\nconst unsubscribe = spin.listenOrders(request, {\n  onNotifyOk: (data) =\u003e console.log(data),\n  onNotifyError: (error) =\u003e console.error(error),\n  onStateOk: (data) =\u003e console.log(data),\n  onStateError: (error) =\u003e console.error(error),\n});\n```\n\nSome times its needed unsubscribe from subscription. It work like that:\n\n- subscription send method `unsub` and get response\n- if response is `true` then `channel` is closed\n- internal `rxjs` subscriptions its also unsubscribed\n- if response is `false` then `channel` not closed\n- `onUnsubError` handle `false` branch\n\n```js\nconst unsubscribe = spin.listenOrders(request, {\n  onSubError: (error) =\u003e console.error(error),\n  onUnsubError: (error) =\u003e console.error(error),\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspin-fi%2Fnear-dex-core-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspin-fi%2Fnear-dex-core-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspin-fi%2Fnear-dex-core-js/lists"}