{"id":18542731,"url":"https://github.com/coinbase/coinbase-commerce-node","last_synced_at":"2025-03-28T22:13:12.890Z","repository":{"id":41253024,"uuid":"137251042","full_name":"coinbase/coinbase-commerce-node","owner":"coinbase","description":"Coinbase Commerce Node","archived":false,"fork":false,"pushed_at":"2023-10-20T00:31:17.000Z","size":387,"stargazers_count":151,"open_issues_count":37,"forks_count":53,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-21T21:07:50.124Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-06-13T17:48:43.000Z","updated_at":"2025-03-05T16:34:10.000Z","dependencies_parsed_at":"2024-06-18T15:20:43.705Z","dependency_job_id":"dc5b4327-eee4-41d5-95f0-33e912749c5c","html_url":"https://github.com/coinbase/coinbase-commerce-node","commit_stats":{"total_commits":24,"total_committers":14,"mean_commits":"1.7142857142857142","dds":0.7916666666666666,"last_synced_commit":"d46c59684423b07d068e001ae8c5d58abb9cbbc1"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fcoinbase-commerce-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/coinbase-commerce-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245325222,"owners_count":20596818,"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-06T20:10:09.507Z","updated_at":"2025-03-28T22:13:12.867Z","avatar_url":"https://github.com/coinbase.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/coinbase/coinbase-commerce-node.svg?style=svg)](https://circleci.com/gh/coinbase/coinbase-commerce-node)\n# Coinbase Commerce\n**Note: This repository is not actively maintained.**\n\nThe official Node.js library for the [Coinbase Commerce API](https://commerce.coinbase.com/docs/).\n\n# Table of contents\n\n\u003c!--ts--\u003e\n   * [Node.js Versions](#node.js-version)\n   * [Documentation](#documentation)\n   * [Installation](#installation)\n   * [Usage](#usage)\n      * [Checkouts](#checkouts)\n      * [Charges](#charges)\n      * [Events](#events)\n      * [Webhooks](#webhooks)\n   * [Testing and Contributing](#testing-and-contributing)\n\u003c!--te--\u003e\n\n## Node.js versions\nNode.js v0.10.48 and above are supported.\n\n## Documentation\nFor more details visit [Coinbase API docs](https://commerce.coinbase.com/docs/api/).\n\nTo start using this library register an account on [Coinbase Commerce](https://commerce.coinbase.com/signup).\nYou will find your ``API_KEY`` from User Settings.\n\nNext initialize a ``Client`` for interacting with the API. The only required parameter to initialize a client is ``apiKey``, however, you can also pass in ``baseUrl``, ``apiVersion``  and ``timeout``.\nParameters can be also be set post-initialization:\n``` js\nvar coinbase = require('coinbase-commerce-node');\nvar Client = coinbase.Client;\n\nvar clientObj = Client.init('API_KEY');\nclientObj.setRequestTimeout(3000);\n```\n\nThe API resource class provides the following static methods: ``list, all, create, retrieve, updateById, deleteById``.  Additionally, the API resource class also provides the following instance methods: ``save, delete, insert, update``.\n\nEach API method returns an ``ApiResource`` which represents the JSON response from the API.\nWhen the response data is parsed into objects, the appropriate ``ApiResource`` subclass will automatically be used.\n\nClient supports the handling of common API errors and warnings.\nAll errors that occur during any interaction with the API will be raised as exceptions.\n\n\n| Error                    | Status Code |\n|--------------------------|-------------|\n| APIError                 |      *      |   \n| InvalidRequestError      |     400     |   \n| ParamRequiredError       |     400     |  \n| ValidationError          |     400     |  \n| AuthenticationError      |     401     |  \n| ResourceNotFoundError    |     404     |\n| RateLimitExceededError   |     429     |\n| InternalServerError      |     500     |\n| ServiceUnavailableError  |     503     |\n\n## Installation\n\nInstall with ``npm``:\n``` sh\nnpm install coinbase-commerce-node --save\n```\n\nType definitions are available for TypeScript users:\n```sh\nnpm install @types/coinbase-commerce-node --save-dev\n```\n## Usage\n``` js\nvar coinbase = require('coinbase-commerce-node');\nvar Client = coinbase.Client;\n\nClient.init('API_KEY');\n```\n## Checkouts \n[Checkouts API docs](https://commerce.coinbase.com/docs/api/#checkouts)\nMore examples on how to use checkouts can be found in the [`examples/resources/checkout.js`](examples/resources/checkout.js) file\n\n### Load checkout resource class\n``` js\nvar coinbase = require('coinbase-commerce-node');\nvar Checkout = coinbase.resources.Checkout;\n```\n### Retrieve\n``` js\nCheckout.retrieve(\u003ccheckout_id\u003e, function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n```\n### Create\n``` js\nvar checkoutData = {\n    'name': 'The Sovereign Individual',\n    'description': 'Mastering the Transition to the Information Age',\n    'pricing_type': 'fixed_price',\n    'local_price': {\n        'amount': '100.00',\n        'currency': 'USD'\n    },\n    'requested_info': ['name', 'email']\n};\nCheckout.create(checkoutData, function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n\n// or\n\nvar checkoutObj = new Checkout();\n\ncheckoutObj.name = 'The Sovereign Individual';\ncheckoutObj.description = 'Mastering the Transition to the Information Age';\ncheckoutObj.pricing_type = 'fixed_price';\ncheckoutObj.local_price = {\n    'amount': '100.00',\n    'currency': 'USD'\n};\ncheckoutObj.requested_info = ['name', 'email'];\n\ncheckoutObj.save(function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n```\n### Update\n``` js\nvar checkoutObj = new Checkout();\n\ncheckoutObj.id = \u003ccheckout_id\u003e;\ncheckoutObj.name = 'new name';\n\ncheckoutObj.save(function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n// or\nvar newParams = {\n    'name': 'New name'\n};\n\nCheckout.updateById(\u003ccheckout_id\u003e, newParams, function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n```\n### Delete\n``` js\nvar checkoutObj = new Checkout();\n\ncheckoutObj.id = \u003ccheckout_id\u003e;\ncheckoutObj.delete(function (error, response) {\n console.log(error);\n console.log(response);\n});\n\n// or\n\nCheckout.deleteById(\u003ccheckout_id\u003e, function (error, response) {\n console.log(error);\n console.log(response);  \n});\n```\n### List\n``` js\nvar params = {\n    'limit': 2,\n    'order': 'desc'\n};\n\nCheckout.list(params, function (error, list, pagination) {\n  console.log(error);\n  console.log(list);\n  console.log(pagination);\n});\n```\n### Get all checkouts\n``` js\nvar params = {\n    'order': 'desc'  \n};\n\nCheckout.all(params, function (error, list) {\n  console.log(error);\n  console.log(list);\n});\n\n```\n## Charges\n[Charges API docs](https://commerce.coinbase.com/docs/api/#charges)\nMore examples on how to use charges can be found in the [`examples/resources/charge.js`](examples/resources/charge.js) file\n\n### Load charge resource class\n``` js\nvar coinbase = require('coinbase-commerce-node');\nvar Charge = coinbase.resources.Charge;\n```\n### Retrieve\n``` js\nCharge.retrieve(\u003ccharge_id\u003e, function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n```\n### Create\n``` js\nvar chargeData = {\n    'name': 'The Sovereign Individual',\n    'description': 'Mastering the Transition to the Information Age',\n    'local_price': {\n        'amount': '100.00',\n        'currency': 'USD'\n    },\n    'pricing_type': 'fixed_price'\n\n}\nCharge.create(chargeData, function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n\n// or\nvar chargeObj = new Charge();\n\nchargeObj.name = 'The Sovereign Individual';\nchargeObj.description = 'Mastering the Transition to the Information Age';\nchargeObj.local_price = {\n    'amount': '100.00',\n    'currency': 'USD'\n};\nchargeObj.pricing_type = 'fixed_price';\nchargeObj.save(function (error, response) {\n  console.log(error);\n  console.log(response);\n});\n```\n### List\n``` js\nCharge.list({}, function (error, list, pagination) {\n  console.log(error);\n  console.log(list);\n  console.log(pagination);\n});\n```\n### Get all changes\n``` js\nCharge.all({}, function (error, list) {\n  console.log(error);\n  console.log(list);\n});\n```\n## Events\n[Events API Docs](https://commerce.coinbase.com/docs/api/#events)\nMore examples on how to use events can be found in the [`examples/resources/event.js`](examples/resources/event.js) file\n\n### Load event resource class\n``` js\nvar coinbase = require('coinbase-commerce-node');\nvar Event = coinbase.resources.Event;\n```\n### Retrieve\n``` js\nEvent.retrieve(\u003cevent_id\u003e, function (error, response) {\n    console.log(error);\n    console.log(response);\n});\n```\n### List\n``` js\nEvent.list({}, function (error, list, pagination) {\n  console.log(error);\n  console.log(list);\n  console.log(pagination);\n});\n```\n### Get all events\n``` js\nEvent.all({}, function (error, list) {\n  console.log(error);\n  console.log(list);\n});\n```\n## Using Promises\n\nIn addition to using callbacks, every method also return a promise.\n``` js\n// Try create and retrieve created charge\nvar chargeObj = new Charge({\n    'description': 'Mastering the Transition to the Information Age',\n    'metadata': {\n        'customer_id': 'id_1005',\n        'customer_name': 'Satoshi Nakamoto'\n    },\n    'name': 'Test Name',\n    'payments': [],\n    'pricing_type': 'no_price'\n});\n\nchargeObj.save().then(function (response) {\n    console.log('Created charge(promise)');\n    console.log(response);\n\n    if (response \u0026\u0026 response.id) {\n        return Charge.retrieve(response.id);\n    }\n}).then(function (response) {\n    console.log('Retrieved charge(promise)');\n    console.log(response);\n}).catch(function (error) {\n    console.log('Unable to retrieve charge(promise)');\n    console.log(error);\n});\n```\n\n## Webhooks\nCoinbase Commerce signs the webhook events it sends to your endpoint, allowing you to validate and verify that they weren't sent by someone else.\nYou can find a simple example of how to use this with Express in the [`examples/webhook`](examples/webhook) folder\n### Verify Signature header\n``` js\nvar Webhook = require('coinbase-commerce-node').Webhook;\n\ntry {\n    Webhook.verifySigHeader(rawBody, signature, sharedSecret);\n    console.log('Successfully verified');\n} catch(error) {\n    console.log('Failed');\n    console.log(error);\n}\n```\n\n### Testing and Contributing\nAny and all contributions are welcome! The process is simple: fork this repo, make your changes, run the test suite, and submit a pull request. To run the tests, clone the repository and run the following commands:\n\n``` sh\nnpm install\nnpm run test\n```\n\nLicense\n----\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fcoinbase-commerce-node/lists"}