{"id":15365610,"url":"https://github.com/tunnckocore/randomorg-js","last_synced_at":"2025-04-15T09:52:42.977Z","repository":{"id":17791040,"uuid":"20668483","full_name":"tunnckoCore/randomorg-js","owner":"tunnckoCore","description":"Client for the JSON-RPC v1 API of Random.ORG - for Node.js and the browser, on just 70 lines. All API methods are implemented.","archived":false,"fork":false,"pushed_at":"2022-12-06T14:39:06.000Z","size":546,"stargazers_count":7,"open_issues_count":14,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-08T07:42:54.761Z","etag":null,"topics":["api","blobs","client","generate","integers","javascript","random","random-generation","random-string"],"latest_commit_sha":null,"homepage":"https://api.random.org/json-rpc/1","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/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-10T01:39:22.000Z","updated_at":"2023-03-11T16:54:36.000Z","dependencies_parsed_at":"2023-01-13T19:30:15.990Z","dependency_job_id":null,"html_url":"https://github.com/tunnckoCore/randomorg-js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Frandomorg-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Frandomorg-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Frandomorg-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Frandomorg-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/randomorg-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249048712,"owners_count":21204305,"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":["api","blobs","client","generate","integers","javascript","random","random-generation","random-string"],"created_at":"2024-10-01T13:15:16.135Z","updated_at":"2025-04-15T09:52:42.951Z","avatar_url":"https://github.com/tunnckoCore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# randomorg-js [![NPM version](https://img.shields.io/npm/v/randomorg-js.svg?style=flat)](https://www.npmjs.com/package/randomorg-js) [![NPM monthly downloads](https://img.shields.io/npm/dm/randomorg-js.svg?style=flat)](https://npmjs.org/package/randomorg-js) [![npm total downloads][downloads-img]][downloads-url]\n\n\u003e The official Random.org API client for Node.js and the browser\n\n[![codeclimate][codeclimate-img]][codeclimate-url] \n[![codestyle][standard-img]][standard-url] \n[![linux build][travis-img]][travis-url] \n[![windows build][appveyor-img]][appveyor-url] \n[![codecov][coverage-img]][coverage-url] \n[![dependency status][david-img]][david-url]\n\nYou might also be interested in [always-done](https://github.com/hybridables/always-done#readme).\n\n## Table of Contents\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [Related](#related)\n- [Contributing](#contributing)\n- [Building docs](#building-docs)\n- [Running tests](#running-tests)\n- [Author](#author)\n- [License](#license)\n\n_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_\n\n## Install\nInstall with [npm](https://www.npmjs.com/)\n\n```\n$ npm install randomorg-js --save\n```\n\nor install using [yarn](https://yarnpkg.com)\n\n```\n$ yarn add randomorg-js\n```\n\nOr in the browser directly using the [unpkg](https://unpkg.com) CDN:\n\n```html\n\u003cscript src=\"https://unpkg.com/randomorg-js/dist/randomorg.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  var randomorg = RandomOrg\n  console.log(randomorg)\n  console.log(randomorg.generateIntegers)\n\n  // see more below in that README\n\u003c/script\u003e\n```\n\n_Please don't use the `https://unpkg.com/randomorg-js` shortcut that Unpkg allows you, because it will give you the CommonJS / Nodejs (with `module.exports`) build, that you can't use in the browser._\n\n## Usage\n\u003e For more use-cases see the [tests](test.js)\n\nAll methods from the [API documentation](https://api.random.org/json-rpc/1/) - both [\"Basic Methods\"](https://api.random.org/json-rpc/1/basic) and [\"Digital Signing\"](https://api.random.org/json-rpc/1/signing) -  are exposed as named exports. In addition, it also has `request` method, which has signature `(methodName, params, callback)` and one `RandomOrg` function which has `(id)` signature and it returns an object with same methods.\n\n**ES6**\n\nEach method has `(id, params, callback)` signature, where `id` is optional.\n\n```js\nimport {\n  generateIntegers,\n  generateDecimalFractions,\n  generateGaussians,\n  generateStrings,\n  generateUUIDs,\n  generateBlobs,\n  getUsage,\n  generateSignedIntegers,\n  generateSignedDecimalFractions,\n  generateSignedGaussians,\n  generateSignedStrings,\n  generateSignedUUIDs,\n  generateSignedBlobs,\n  verifySignature,\n\n  // special\n  request,\n  RandomOrg\n} from 'randomorg-js'\n```\n\n**CommonJS / Node.JS**\n\nNotice that Node \u003e 4 is required for `destructing` feature.\n\n```js\nconst {\n  generateIntegers,\n  generateDecimalFractions,\n  generateGaussians,\n  generateStrings,\n  // ...\n  generateSignedBlobs,\n  verifySignature,\n\n  // special\n  request,\n  RandomOrg\n} = require('randomorg-js')\n```\n\nSo you simply can just use old way\n\n```js\nvar randomorg = require('randomorg-js')\n\nconsole.log(randomorg)\nconsole.log(randomorg.generateIntegers)\nconsole.log(randomorg.generateDecimalFractions)\nconsole.log(randomorg.verifySignature)\nconsole.log(randomorg.request)\nconsole.log(randomorg.RandomOrg)\n// and etc.\n```\n\n**Example**\n\n```js\nconst params = {\n  apiKey: 'your api key',\n  n: 6,\n  min: 1,\n  max: 6\n}\n\ngenerateIntegers(params, (err, response) =\u003e {\n  // there may have `err` or `response.error`\n  console.log(err || response.error)\n\n  // response is exactly what the API spec\n  // defines as response object\n  console.log(response)\n  console.log(response.id)\n  console.log(response.result)\n})\n```\n\nOr using the `request` method\n\n```js\nrequest('generateSignedStrings', {\n  n: 8,\n  length: 10,\n  characters: 'ab!~cdefg+_-hijk@lmn#$%opqr^stuvwxyz',\n}, (err, response) =\u003e {\n  console.log(err, response)\n})\n```\n\nBy default the package exports all methods with randomly generated `id`. To change that, the onoe way can be to add `id` as first argument to each method e.g. `generateStrings(id, params, callback)`; or the second variant is to call the `RandomOrg(id)` which returns the same methods and they will use the defined `id` from the constructor.\n\n```js\nconst { RandomOrg } = require('randomorg-js')\n\nconst random = RandomOrg(123555)\n\nrandom.generateSignedBlobs({\n apiKey: 'your api key here',\n and: 'other params for that method'\n}, (er, { id, result }) =\u003e {\n  // response always has the same ID what\n  // user has provided\n  console.log(id) // =\u003e 123555\n  console.log(result) // =\u003e random Signed Blobs\n})\n\n// but you still can provide\n// different `id` to same method\nrandom.generateSignedBlobs(4444, params, (e, { id }) =\u003e {\n  console.log(id) // =\u003e 4444\n})\n\n// or to some other method\nrandom.generateIntegers(2938742, params, (e, { id }) =\u003e {\n  console.log(id) // =\u003e 2938742\n})\n```\n\n## API\n\nTODO\n\n## Related\n- [always-done](https://www.npmjs.com/package/always-done): Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement… [more](https://github.com/hybridables/always-done#readme) | [homepage](https://github.com/hybridables/always-done#readme \"Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement for [async-done][] - pass 100% of its tests plus more\")\n- [minibase](https://www.npmjs.com/package/minibase): Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing… [more](https://github.com/node-minibase/minibase#readme) | [homepage](https://github.com/node-minibase/minibase#readme \"Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing [base][] plugins.\")\n- [try-catch-core](https://www.npmjs.com/package/try-catch-core): Low-level package to handle completion and errors of sync or asynchronous functions, using [once][] and [dezalgo][] libs. Useful for and… [more](https://github.com/hybridables/try-catch-core#readme) | [homepage](https://github.com/hybridables/try-catch-core#readme \"Low-level package to handle completion and errors of sync or asynchronous functions, using [once][] and [dezalgo][] libs. Useful for and used in higher-level libs such as [always-done][] to handle completion of anything.\")\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/randomorg-js/issues/new).  \nPlease read the [contributing guidelines](CONTRIBUTING.md) for advice on opening issues, pull requests, and coding standards.  \nIf you need some help and can spent some cash, feel free to [contact me at CodeMentor.io](https://www.codementor.io/tunnckocore?utm_source=github\u0026utm_medium=button\u0026utm_term=tunnckocore\u0026utm_campaign=github) too.\n\n**In short:** If you want to contribute to that project, please follow these things\n\n1. Please DO NOT edit [README.md](README.md), [CHANGELOG.md](CHANGELOG.md) and [.verb.md](.verb.md) files. See [\"Building docs\"](#building-docs) section.\n2. Ensure anything is okey by installing the dependencies and run the tests. See [\"Running tests\"](#running-tests) section.\n3. Always use `npm run commit` to commit changes instead of `git commit`, because it is interactive and user-friendly. It uses [commitizen][] behind the scenes, which follows Conventional Changelog idealogy.\n4. Do NOT bump the version in package.json. For that we use `npm run release`, which is [standard-version][] and follows Conventional Changelog idealogy.\n\nThanks a lot! :)\n\n## Building docs\nDocumentation and that readme is generated using [verb-generate-readme][], which is a [verb][] generator, so you need to install both of them and then run `verb` command like that\n\n```\n$ npm install verbose/verb#dev verb-generate-readme --global \u0026\u0026 verb\n```\n\n_Please don't edit the README directly. Any changes to the readme must be made in [.verb.md](.verb.md)._\n\n## Running tests\nClone repository and run the following in that cloned directory\n\n```\n$ npm install \u0026\u0026 npm test\n```\n\n## Author\n**Charlike Mike Reagent**\n\n+ [github/tunnckoCore](https://github.com/tunnckoCore)\n+ [twitter/tunnckoCore](https://twitter.com/tunnckoCore)\n+ [codementor/tunnckoCore](https://codementor.io/tunnckoCore)\n\n## License\nCopyright © 2014, 2017, [Charlike Mike Reagent](https://i.am.charlike.online). Released under the [MIT license](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.1, on February 12, 2017._  \n_Project scaffolded using [charlike][] cli._\n\n[always-done]: https://github.com/hybridables/always-done\n[async-done]: https://github.com/gulpjs/async-done\n[base]: https://github.com/node-base/base\n[charlike]: https://github.com/tunnckocore/charlike\n[commitizen]: https://github.com/commitizen/cz-cli\n[dezalgo]: https://github.com/npm/dezalgo\n[once]: https://github.com/isaacs/once\n[standard-version]: https://github.com/conventional-changelog/standard-version\n[verb-generate-readme]: https://github.com/verbose/verb-generate-readme\n[verb]: https://github.com/verbose/verb\n\n[always-done]: https://github.com/hybridables/always-done\n[async-done]: https://github.com/gulpjs/async-done\n[base]: https://github.com/node-base/base\n[charlike]: https://github.com/tunnckocore/charlike\n[commitizen]: https://github.com/commitizen/cz-cli\n[dezalgo]: https://github.com/npm/dezalgo\n[once]: https://github.com/isaacs/once\n[standard-version]: https://github.com/conventional-changelog/standard-version\n[verb-generate-readme]: https://github.com/verbose/verb-generate-readme\n[verb]: https://github.com/verbose/verb\n\n[downloads-url]: https://www.npmjs.com/package/randomorg-js\n[downloads-img]: https://img.shields.io/npm/dt/randomorg-js.svg\n\n[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/randomorg-js\n[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/randomorg-js.svg\n\n[travis-url]: https://travis-ci.org/tunnckoCore/randomorg-js\n[travis-img]: https://img.shields.io/travis/tunnckoCore/randomorg-js/master.svg?label=linux\n\n[appveyor-url]: https://ci.appveyor.com/project/tunnckoCore/randomorg-js\n[appveyor-img]: https://img.shields.io/appveyor/ci/tunnckoCore/randomorg-js/master.svg?label=windows\n\n[coverage-url]: https://codecov.io/gh/tunnckoCore/randomorg-js\n[coverage-img]: https://img.shields.io/codecov/c/github/tunnckoCore/randomorg-js/master.svg\n\n[david-url]: https://david-dm.org/tunnckoCore/randomorg-js\n[david-img]: https://img.shields.io/david/tunnckoCore/randomorg-js.svg\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Frandomorg-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftunnckocore%2Frandomorg-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Frandomorg-js/lists"}