{"id":18948501,"url":"https://github.com/bahdcoder/buycoins-sdk","last_synced_at":"2025-07-03T22:04:20.600Z","repository":{"id":100512710,"uuid":"335214669","full_name":"bahdcoder/buycoins-sdk","owner":"bahdcoder","description":"Javascript sdk for the buycoins GraphQL API 💰","archived":false,"fork":false,"pushed_at":"2021-02-13T01:03:19.000Z","size":253,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T01:39:36.484Z","etag":null,"topics":["buycoins-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/bahdcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"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":"2021-02-02T08:11:52.000Z","updated_at":"2024-01-13T21:26:54.000Z","dependencies_parsed_at":"2023-05-15T14:15:11.850Z","dependency_job_id":null,"html_url":"https://github.com/bahdcoder/buycoins-sdk","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":0.35,"last_synced_commit":"54889ae3e718e7da65adaebc4a1b52ffcb44c9a3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bahdcoder/buycoins-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahdcoder%2Fbuycoins-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahdcoder%2Fbuycoins-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahdcoder%2Fbuycoins-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahdcoder%2Fbuycoins-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahdcoder","download_url":"https://codeload.github.com/bahdcoder/buycoins-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahdcoder%2Fbuycoins-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261783369,"owners_count":23208945,"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":["buycoins-api"],"created_at":"2024-11-08T13:13:47.284Z","updated_at":"2025-07-03T22:04:20.546Z","avatar_url":"https://github.com/bahdcoder.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cimg src=\"https://gblobscdn.gitbook.com/spaces%2F-M-tI8F1HM2T7LaWvK5j%2Favatar.png?alt=media\"\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003e\n    \u003cstrong\u003e\n    Elegant Javascript Sdk for the Buycoins GraphQL API (Unofficial)\n    \u003c/strong\u003e\n  \u003c/h3\u003e\n  \u003cp\u003eBuild powerful apps around the Buycoins API with a lightweight, zero-dependencies, complete and expressive SDK 🚀. \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\n[![github-actions-image]][github-actions-url] [![codecov-img]][codecov-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003e\n    \u003ca href=\"https://developers.buycoins.africa/\"\u003e\n      Buycoins API Docs\n    \u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"CONTRIBUTING.md\"\u003e\n      Contributing\n    \u003c/a\u003e\n  \u003c/h3\u003e\n\u003c/div\u003e\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eBuilt with ❤︎ by \u003ca href=\"https://twitter.com/bahdcoder\"\u003eKati Frantz\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## Table of content\n\n- [Basic Overview](#basic-overview)\n    - [Features](#features)\n- [Installation](#installation)\n    - [Get API Keys](#get-api-keys)\n    - [Install npm package](#install-npm-package)\n    - [Requirements](#requirements)\n- [Quickstart](#quickstart)\n- [Peer to Peer Trading](#peer-to-peer-trading)\n    - [Prices](#prices)\n    - [Post limit order](#post-limit-order)\n    - [Post market order](#post-market-order)\n    - [Get orders](#get-orders)\n    - [Get market book](#get-market-book)\n- [Placing orders](#placing-orders)\n    - [Buy](#buy)\n    - [Sell](#sell)\n- [Sending](#sending)\n    - [Network Fees](#network-fees)\n    - [Send](#send)\n    - [Account balances](#account-balances)\n- [Receiving](#receiving)\n    - [Create Address](#create-address)\n\n## Basic Overview\nThe `@buycoins/sdk` project provides a simple, fully customisable and elegant way to integrate the Buycoins GraphQL API into your Node.js applications. This project strives to always be in sync with the latest API changes.\n\n### Features\n\n- ⚡ ***100%*** Fully typed queries, mutations and responses\n- ⚡ ***100%*** tests coverage\n- ⚡ ***Fluent and performant*** GraphQL query builder\n- ⚡ ***Promised based*** builder pattern and fluent API\n- ⚡ ***Zero dependencies***. Light-weight and highly performant. \n\n## Installation\nThe installation is in two steps: First: get your API keys, second: install the package into your project.\n\n### Get API Keys\nBefore getting started, you would need to request access to the Buycoins API. You may send an [email to their support team](mailto:support@buycoins.africa), stating the application you would love to build. Shouldn't take more than an hour or two to get acces.\n\nOnce you do, visit your Buycoins account settings page to generate your API keys:\n\n[![buycoins-api-settings-page](https://res.cloudinary.com/bahdcoder/image/upload/v1612330294/buycoins-visit-api-settings-page_fm7i1w.png)](https://buycoins.africa/settings/api)\n\n### Install npm package\nYou may install the package using npm:\n\n```shell\nnpm install --save @buycoins/sdk\n```\n\nOr yarn:\n\n```shell\nyarn add @buycoins/sdk\n```\n\n### Requirements\nAt the moment, the SDK has been fully tested on Node.js v12.x and 14.x. Versions above v12.x should work fine too.\n\n## Quickstart\nTo quickly get started, let's make an API call to see the current prices of the cryptocurrencies supported by Buycoins.\n\nFirst, require the `buycoins` function:\n\n```js\nconst { buycoins } = require('@buycoins/sdk')\n```\n\nNext, call this function to get an API instance. You can pass in your public key and secret key as arguments into this function. \n\n```js\nconst { buycoins } = require('@buycoins/sdk')\n\nconst api = buycoins('YOWGe1KNuw', 'ed1wDGUuoVkID7rJ58vv0186z0vZ3TfbNXYiPsiC')\n```\n\nIf you omit the public and secret key arguments, the sdk would default to using `BUYCOINS_PUBLIC_KEY` and `BUYCOINS_SECRET_KEY` environment variables.\n\nOn the `api` instance, the `.prices()` method would give you an instance of the `Prices` query. The `.get()` method on that query makes the API call and resolves with the data:\n\n```js\nconst { buycoins } = require('@buycoins/sdk')\n\nconst api = buycoins()\n\napi.prices().get().then(({ data, errors }) =\u003e {\n    console.log(data, errors)\n})\n```\n\n### Customising query fields\n\nFor all queries, all the supported GraphQL fields would be fetched. You may control the fields to be queried using the `.fields()` function and passing a query builder object. Here's an example of sending crypto and getting back a transfer request:\n\n```js\nbuycoins()\n.send()\n.litecoin()\n.address('xxxx')\n.amount('0.04')\n.fields([\n  'id',\n  'fee',\n  'status',\n  {\n    transaction: [\n      'id',\n      'confirmed',\n      {\n          address: ['id', 'cryptocurrency']\n      }\n  }] \n)\n.get()\n```\n\n## Peer to Peer Trading\n\n### Prices\nYou may get the buy and sell prices of the supported currencies using the `.prices()` query. The `.buy()` and `.sell()` methods on this query can be used to get the buy prices and the sell prices respectively.\n\n```js\nconst { data, errors } = await buycoins().prices().sell().get()\n```\n\n#### Price for a single currency\nTo get the price for a specific currency, use any of the [supported currency methods](#supported-currency-methods) on the query instance.\n\n```js\nconst { data, errors } = await buycoins().prices().sell().litecoin().get()\n```\n\n### Post limit order\nTo place a limit order, first you need to [get a price](#prices). Next, call the `.limitOrder()` query. You may place an order with static or dynamic pricing using the `.static()` or `.dynamic()`. \n\n```js\nconst { data } = await buycoins().limitOrder().litecoin().dynamic('0.03422').buy().post()\n```\n\n### Post market order\nTo place a market order, you may use the `.marketOrder()` query. You may use the `.amount()` method to set the amount:\n\n```js\nconst { data } = await buycoins().marketOrder().amount('0.009').sell()\n```\n\n### Get Orders\nYou can retrieve a list of orders you have placed by calling the `.orders()` query. You can also specify whether to fetch `open` or `completed` orders using the `.open()` and `.completed()` methods.\n\n```js\nconst { data } = await buycoins().orders().ethereum().sell().completed().get()\n```\n\nYou may want to specify the fields and variables for this query. Here'an example:\n\n```js\nconst { data } = await buycoins().orders().ethereum().sell().completed().fields([{\n  orders: [\n    {\n      edges: [\n        {\n          node: ['id', 'cryptocurrency', 'staticPrice']\n        }\n      ]\n    }\n  ]\n}]).variables({\n  root: {\n    orders: {\n      after:'QnV5Y29pbnNQcmljZS1hMGNmMmQ4Yi1hY2Q0LTRjMGYtOGZkMC1lMjk4NWMxYmU3ZTU='\n    }\n  }\n}).get()\n```\n\n\n### Get Market book\nThe `marketBook()` query may be used to retrive the market book.\n\n```js\nconst { data } = await buycoins().marketBook().usdCoin().sell().get()\n```\n\n## Placing orders\n\n### Buy\nTo place a buy order, first you need to [get a price](#prices). This is required when buying.\n\nNext, call the `.buy()` query:\n\n```js\nconst { data: { getPrices: ethereumPrice } } = await buycoins().prices().ethereum().fields(['id']).get()\n\nconst { data } = await buycoins().buy().amount('0.0089').ethereum().price(ethereumPrice[0].id).post()\n```\n\n### Sell\nTo place a sell order, first you need to [get a price](#prices). This is required when selling.\n\nNext, call the `.sell()` query:\n\n```js\nconst { data: { getPrices } } = await buycoins().prices().ethereum().get()\n\nconst { data } = await buycoins().sell().ethereum().amount('0.9384').price(getPrices[0].id).post()\n```\n\n## Sending\n\n### Network fees\nThe `.estimatedNetworkFee()` query estimates the network fees.\n\n```js\nconst { data } = await buycoins().estimatedNetworkFee().litecoin().get()\n```\n\n### Send\nThe `.send()` query may be used to send cryptocurrency to an external address. You may set the external address using the `.address()` method.\n\n```js\nconst { data } = await buycoins().send().usdCoin().address('0xd39B6849d2e1dB20BAb50dd7A4F3e0882c744404').get()\n```\n\n### Account balances\nThe `.balances()` query may be used to get your portfolio balance for any currencies you hold:\n\n```js\nconst { data } = await buycoins().balances().usdCoin().get()\n```\n\n## Receiving\n\n### Create address\nTo receive cryptocurrency, you will first have to create an address on Buycoins using the `.createAddress()` mutation:\n\n```js\nconst { data } = await buycoins().createAddress().litecoin().post()\n```\n\n## Supported currency methods\nThese methods may be used to set or filter some queries or mutations by a specific currency.\n\n- `.bitcoin()`\n- `.litecoin()`\n- `.usdTether()`\n- `.usdCoin()`\n- `.ethereum()`\n- `.nairaToken()`\n\n## Contributing\nWe would love to have you contribute and make this project better. You can contribute by providing documentation, feedback, code changes or implementing new features and improvements. Please read the [contributing guide](CONTRIBUTING.md) to get started.\n\n[github-actions-image]: https://img.shields.io/github/workflow/status/bahdcoder/buycoins-sdk/Tests%20\u0026%20code%20coverage?style=for-the-badge\n[github-actions-url]: https://github.com/bahdcoder/buycoins-sdk/actions \"github-actions\"\n\n[npm-image]: https://img.shields.io/npm/v/@buycoins/sdk.svg?style=for-the-badge\u0026logo=npm\n[npm-url]: https://www.npmjs.com/package/@buycoins/sdk \"npm\"\n\n[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge\u0026logo=typescript\n\n[license-url]: LICENSE.md\n[license-image]: https://img.shields.io/github/license/bahdcoder/buycoins-sdk?style=for-the-badge\n[codecov-img]: https://img.shields.io/codecov/c/gh/bahdcoder/buycoins-sdk?style=for-the-badge\u0026token=ZO8QVVDTIB\u0026logo=codecov\n[codecov-url]: https://app.codecov.io/gh/bahdcoder/buycoins-sdk/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahdcoder%2Fbuycoins-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahdcoder%2Fbuycoins-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahdcoder%2Fbuycoins-sdk/lists"}