{"id":15789778,"url":"https://github.com/danielgtaylor/userbadges-node","last_synced_at":"2025-03-31T18:27:12.287Z","repository":{"id":7015044,"uuid":"8284777","full_name":"danielgtaylor/userbadges-node","owner":"danielgtaylor","description":"UserBadges.com Javascript API client for Node.js","archived":false,"fork":false,"pushed_at":"2013-03-01T03:37:41.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T23:38:22.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/danielgtaylor.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-02-19T06:37:39.000Z","updated_at":"2013-09-30T21:59:40.000Z","dependencies_parsed_at":"2022-09-11T23:51:43.651Z","dependency_job_id":null,"html_url":"https://github.com/danielgtaylor/userbadges-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fuserbadges-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fuserbadges-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fuserbadges-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fuserbadges-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgtaylor","download_url":"https://codeload.github.com/danielgtaylor/userbadges-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246516881,"owners_count":20790311,"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-10-04T22:03:28.369Z","updated_at":"2025-03-31T18:27:12.264Z","avatar_url":"https://github.com/danielgtaylor.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"UserBadges Client - Node.js [![Dependency Status](https://gemnasium.com/danielgtaylor/userbadges-node.png)](https://gemnasium.com/danielgtaylor/userbadges-node) [![Build Status](https://travis-ci.org/danielgtaylor/userbadges-node.png?branch=master)](https://travis-ci.org/danielgtaylor/userbadges-node)\n===========================\nA UserBadges.com Javascript API client for Node.js.\n\n * [UserBadges.com API Documentation](http://www.userbadges.com/api-documentation)\n\nInstallation\n------------\nInstall the client library via `npm`:\n\n```bash\nnpm install userbadges\n```\n\nUsage\n-----\nThe client is fairly simple to use, with just a few methods. Start by instantiating a client instance with your API secret key:\n\n```javascript\nvar userbadges = require('userbadges');\n\n// Create a client with your API key\nvar client = new userbadges.Client('my-secret-key');\n\n// Or create a client to hit a specific endpoint URL\nvar client = new userbadges.Client('my-secret-key', 'http://foo.com')\n```\n\nThen you can start making calls:\n\n```javascript\n// Get a list of badges for the 'test' service sorted reverse alphabetically\nclient.getServiceBadges({service: 'test', sort: '-name'}, function (data) {\n   console.log(data); \n});\n\n// Add a badge type called test2\nclient.addServiceBadges({service: 'test', badges: [{name: 'test2', description: 'Test description', myCustomField: 'foo'}]});\n\n// Update a user with badges\nclient.addUserBadges({service: 'test', user: 'daniel', badges: ['test1', 'test2']}, function (data) {\n   console.log(data); \n});\n```\n\nReference\n---------\nThe userbadges library has one object available:\n\n### Client (key, [endpoint])\nCreate a new client instance, optionally giving the endpoint URL to use.\n\nThe following methods are available:\n\n### Client.prototype.getServiceBadges (options, callback)\nGet a list of badges for a service. The callback should take a single `data` parameter, which is the returned JSON object from the API call. The `options` object can contain:\n\n * `service` Service name; required\n * `sort` Sort method; optional and one of `name`, `-name`, `count`, `-count`, `date`, `-date`\n\n### Client.prototype.addServiceBadges (options, callback)\nAdd or update a service's list of badges. The callback should take a single `data` parameter, which is the returned JSON object from the API call. The `options` object can contain:\n\n * `service` Service name; required\n * `badges` Array of badge objects to add including custom fields; required\n\n### Client.prototype.delServiceBadges (options, callback)\nDelete badges from a user's list of badges. The callback should take a single `data` parameter, which is the returned JSON object from the API call. The `options` object can contain:\n\n * `service` Service name; required\n * `badges` Array of badge names to remove; required\n\n### Client.prototype.getUsers (options, callback)\nGet a list of users for a service, optionally filtered by name or badges. The callback should take a single `data` parameter, which is the returned JSON object from the API call. The `options` object can contain:\n\n * `service` Service name; required\n * `names` Only get uses with these names; optional, comma-seperated list\n * `badges` Only get users with these badges; optional, comma-seperated list\n * `sort` Sort method; optional and one of `name`, `-name`, `count`, `-count`, `date`, `-date`\n\n### Client.prototype.addUserBadges (options, callback)\nAdd a list of badges to a user by name. The callback should take a single `data` parameter, which is the returned JSON object from the API call. The `options` object can contain:\n\n * `service` Service name; required\n * `user` User name; required\n * `badges` Comma-seperated list of badge names to add; required\n\n### Client.prototype.delUserBadges (options, callback)\nRemove a list of badges from a user by name. The callback should take a single `data` parameter, which is the returned JSON object from the API call. The `options` object can contain:\n\n * `service` Service name; required\n * `user` User name; required\n * `badges` Comma-seperated list of badge names to add; required\n\nContributing\n------------\nContributions are welcome - just fork the project and submit a pull request when you are ready!\n\n### Getting Started\nFirst, create a fork on GitHub. Then:\n\n```bash\ngit clone ...\ncd userbadges-node\nnpm install\n```\n\n### Unit Tests\nBefore submitting a pull request, please add any relevant tests and run them via:\n\n```bash\nnpm test\n```\n\nChanges that cause tests to fail will not be accepted.\n\nLicense\n-------\nCopyright (c) 2013 Daniel G. Taylor\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgtaylor%2Fuserbadges-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgtaylor%2Fuserbadges-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgtaylor%2Fuserbadges-node/lists"}