{"id":13775734,"url":"https://github.com/lukechilds/onionoo-node-client","last_synced_at":"2025-04-28T10:40:35.986Z","repository":{"id":57314752,"uuid":"66936764","full_name":"lukechilds/onionoo-node-client","owner":"lukechilds","description":"Node.js client library for the Tor Onionoo API","archived":false,"fork":false,"pushed_at":"2019-10-31T17:08:47.000Z","size":110,"stargazers_count":24,"open_issues_count":5,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-16T07:07:32.860Z","etag":null,"topics":["onionoo","tor","tor-network"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lukechilds.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}},"created_at":"2016-08-30T12:01:31.000Z","updated_at":"2025-02-22T07:49:11.000Z","dependencies_parsed_at":"2022-09-18T20:51:24.334Z","dependency_job_id":null,"html_url":"https://github.com/lukechilds/onionoo-node-client","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fonionoo-node-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fonionoo-node-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fonionoo-node-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fonionoo-node-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukechilds","download_url":"https://codeload.github.com/lukechilds/onionoo-node-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251296966,"owners_count":21566717,"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":["onionoo","tor","tor-network"],"created_at":"2024-08-03T17:01:47.599Z","updated_at":"2025-04-28T10:40:35.927Z","avatar_url":"https://github.com/lukechilds.png","language":"JavaScript","funding_links":[],"categories":["\u003ca id=\"6e80463404d46f0493cf6e84597e4b5c\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"e99ba5f3de02f68412b13ca718a0afb6\"\u003e\u003c/a\u003eTor\u0026\u0026\u0026Onion\u0026\u0026洋葱"],"readme":"# onionoo-node-client\n\n\u003e Node.js client library for the Tor Onionoo API\n\n[![Build Status](https://travis-ci.org/lukechilds/onionoo-node-client.svg?branch=master)](https://travis-ci.org/lukechilds/onionoo-node-client)\n[![Coverage Status](https://coveralls.io/repos/github/lukechilds/onionoo-node-client/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/onionoo-node-client?branch=master)\n[![npm](https://img.shields.io/npm/v/onionoo.svg)](https://www.npmjs.com/package/onionoo)\n\nPromise based client library for the Tor Onionoo API. Includes DB agnostic caching.\n\n## Install\n\n```shell\nnpm install --save onionoo\n```\n\n## Usage\n\n```js\nconst Onionoo = require('onionoo');\nconst onionoo = new Onionoo();\n\n// Get top 10 relays\nconst query = {\n  limit: 10,\n  running: true,\n  order: '-consensus_weight'\n};\n\nonionoo.summary(query).then(response =\u003e {\n    console.log(response.body)\n    // {\n    //   version:'3.1',\n    //   relays_published:'2016-12-23 09:00:00',\n    //   relays:[\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object],\n    //     [Object]\n    //   ],\n    //   bridges_published:'2016-12-23 07:41:03',\n    //   bridges:[]\n    // }\n});\n```\n\nYou can override the default options when instantiating a new `Onionoo` instance:\n\n```js\nconst Onionoo = require('onionoo');\nconst onionoo = new Onionoo({\n  baseUrl: 'https://onionoo.torproject.org',\n  endpoints: [\n    'summary',\n    'details',\n    'bandwidth',\n    'weights',\n    'clients',\n    'uptime'\n  ],\n  cache: false\n});\n```\n\n## Cache\n\nBy default no cache is used. You can easily cache in memory or to a more scalable store like Redis using [Keyv storage adapters](https://github.com/lukechilds/keyv#official-storage-adapters).\n\nCache in memory:\n\n```js\nconst Onionoo = require('onionoo');\n\nconst memory = new Map();\nconst onionoo = new Onionoo({ cache: memory });\n```\n\nUse persistent Redis cache:\n\n```js\nconst Onionoo = require('onionoo');\nconst KeyvRedis = require('@keyv/redis');\n\nconst redis = new KeyvRedis('redis://user:pass@localhost:6379');\nconst onionoo = new Onionoo({ cache: redis });\n```\n\n## API\n\n### new Onionoo([options])\n\nReturns a new `Onionoo` instance\n\n#### options\n\nType: `object`\n\n##### options.baseUrl\n\nType: `string`\u003cbr\u003e\nDefault: `'https://onionoo.torproject.org'`\n\nString to use as the base url for all API requests.\n\n##### options.endpoints\n\nType: `array`\u003cbr\u003e\nDefault: `['summary', 'details', 'bandwidth', 'weights', 'clients', 'uptime']`\n\nArray of endpoints to be returned as methods on the `Onionoo` instance.\n\n##### options.cache\n\nType: `object`\u003cbr\u003e\nDefault: `false`\n\n[Keyv](https://github.com/lukechilds/keyv) storage adapter instance for storing cached data.\n\n### onionoo.endpoint([query])\n\n*Where endpoint is an item from the endpoints array*\n\nReturns a Promise that will resolve once the Onionoo API has responded. The response object contains `statusCode`, `statusMessage`, `headers` and `body` properties.\n\n#### query\n\nType: `object`\n\nQuery object to be url encoded and appended to the `baseUrl`. You can read up on the vast amount of accepted parameters in the [Onionoo API docs](https://metrics.torproject.org/onionoo.html#parameters).\n\n\u003e Note: Colons are not url encoded to allow for Onionoo's `key:value` search filters.\n\n## Related\n\n- [`Onionite`](https://github.com/lukechilds/onionite) - Explore the Tor network\n\n## License\n\nMIT © Luke Childs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechilds%2Fonionoo-node-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukechilds%2Fonionoo-node-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechilds%2Fonionoo-node-client/lists"}