{"id":13650736,"url":"https://github.com/golemfactory/golem-js","last_synced_at":"2025-04-05T23:07:03.460Z","repository":{"id":37421719,"uuid":"293524572","full_name":"golemfactory/golem-js","owner":"golemfactory","description":"TypeScript + NodeJS API for Golem","archived":false,"fork":false,"pushed_at":"2024-10-28T08:28:26.000Z","size":48784,"stargazers_count":30,"open_issues_count":8,"forks_count":18,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-29T14:37:26.544Z","etag":null,"topics":["distributed-computing","golem","nodejs","sdk","typescript"],"latest_commit_sha":null,"homepage":"https://docs.golem.network/docs/creators/javascript","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/golemfactory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-07T12:40:02.000Z","updated_at":"2024-10-21T15:41:36.000Z","dependencies_parsed_at":"2023-09-22T14:08:05.409Z","dependency_job_id":"3acc2d86-c45f-44b7-8f33-22ae4b612384","html_url":"https://github.com/golemfactory/golem-js","commit_stats":{"total_commits":1983,"total_committers":30,"mean_commits":66.1,"dds":0.6116994452849218,"last_synced_commit":"9e07885b56271eb7870494998f42c92195b366c5"},"previous_names":["golemfactory/golem-js","golemfactory/yajsapi"],"tags_count":295,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fgolem-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fgolem-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fgolem-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fgolem-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golemfactory","download_url":"https://codeload.github.com/golemfactory/golem-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411231,"owners_count":20934653,"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":["distributed-computing","golem","nodejs","sdk","typescript"],"created_at":"2024-08-02T02:00:40.299Z","updated_at":"2025-04-05T23:07:03.439Z","avatar_url":"https://github.com/golemfactory.png","language":"TypeScript","funding_links":[],"categories":["Golem Projects"],"sub_categories":["golem-js - the JS SDK from Golem"],"readme":"\u003cbr /\u003e\n\n\u003cp align=center\u003e\n \u003cimg src=https://repository-images.githubusercontent.com/293524572/b8635cf6-9653-416d-ae56-bc9c6a43e503 alt=\"golem-js SDK logo\" width=480 /\u003e\n\u003c/p\u003e\n\n# Golem JavaScript API\n\n![GitHub](https://img.shields.io/github/license/golemfactory/golem-js)\n![npm](https://img.shields.io/npm/v/@golem-sdk/golem-js)\n![node-current](https://img.shields.io/node/v/@golem-sdk/golem-js)\n![npm type definitions](https://img.shields.io/npm/types/@golem-sdk/golem-js)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/golemfactory/golem-js/goth.yml)\n[![GitHub issues](https://img.shields.io/github/issues/golemfactory/golem-js)](https://github.com/golemfactory/golem-js/issues)\n![Discord](https://img.shields.io/discord/684703559954333727?style=flat\u0026logo=discord)\n\n## Table of contents\n\n\u003c!-- TOC --\u003e\n\n- [Golem JavaScript API](#golem-javascript-api)\n  - [Table of contents](#table-of-contents)\n  - [Features](#features)\n  - [Getting Started](#getting-started)\n    - [What's Golem and `golem-js`?](#whats-golem-and-golem-js)\n    - [SDK Learning resources](#sdk-learning-resources)\n  - [Installation](#installation)\n  - [Supported environments](#supported-environments)\n  - [Getting started with Golem Network](#getting-started-with-golem-network)\n    - [Obtain an `app-key` to use with SDK](#obtain-an-app-key-to-use-with-sdk)\n  - [Usage](#usage)\n  - [Examples](#examples)\n  - [Documentation](#documentation)\n  - [Debugging](#debugging)\n  - [Testing](#testing)\n  - [Contributing](#contributing)\n  - [Discord](#discord)\n  - [See also](#see-also)\n  \u003c!-- TOC --\u003e\n\n## Features\n\nBecome a **Requestor** in the **Golem Network** and use this SDK to:\n\n- 🌐 Acquire compute resources from Providers using a convenient API\n- 🚢 Run your workloads with these resources and get the results back to your machine\n- 🔐 Build N-tier application deployments and run them within a VPN\n- 💰 Settle payments with Providers for the resources you've utilized\n\n## Getting Started\n\n### What's Golem and `golem-js`?\n\n**[The Golem Network](https://golem.network)** fosters a global group of creators building ambitious software solutions\nthat will shape the technological landscape of future generations by accessing computing resources across the platform.\nGolem Network is an accessible, reliable, open access and censorship-resistant protocol, democratizing access to digital\nresources and connecting users through a flexible, open-source platform.\n\n**golem-js** is the JavaScript API that allows developers to connect to their Golem nodes and manage their\ndistributed, computational loads through Golem Network.\n\n### SDK Learning resources\n\n- [Basic concepts documentation](./docs/CONCEPTS.md) - Learn about the basic and advanced building blocks at your\n  disposal.\n- [Usage documentation](./docs/USAGE.md) - Explore supported usage and implementation patterns.\n- [Feature documentation](./docs/FEATURES.md) - Description of interesting features that we've prepared.\n- [Plugin documentation](./docs/PLUGINS.md) - Learn how to write plugins that can enhance `GolemNetwork` user's experience by introducing code reusability and modularity.\n\n## Installation\n\nTo quickly get started with a new project using `golem-js`, you can use the following template:\n\n```bash\nnpx @golem-sdk/cli@latest new my-awesome-golem-project\n```\n\n`@golem-sdk/golem-js` is available as a [NPM package](https://www.npmjs.com/package/@golem-sdk/golem-js).\n\nYou can install it through `npm`:\n\n```bash\nnpm install @golem-sdk/golem-js\n```\n\nor by `yarn`:\n\n```bash\nyarn add @golem-sdk/golem-js\n```\n\n## Supported environments\n\nThe SDK is designed to work with LTS versions of Node (starting from 18)\nand with browsers. The minimum supported `yagna` version is `0.15.2`.\n\n## Getting started with Golem Network\n\nBefore you start using the SDK, you need to have `yagna` installed and running on your machine. Yagna is a service that\ncommunicates and performs operations on the Golem Network, upon your requests via the SDK. You can follow the\ninstructions below or visit\nthe [official documentation](https://docs.golem.network/docs/creators/javascript/quickstarts/quickstart#install-yagna-2)\nto set it up.\n\n```bash\n# Join the network as a requestor\ncurl -sSf https://join.golem.network/as-requestor | bash -\n\n# Start the golem node on your machine,\n# you can use `daemonize` to run this in background\nyagna service run\n```\n\nNow that you have `yagna` running, you can initialize your requestor and request funds (`tGLM` tokens) on the test\nnetwork.\n\n```bash\n# IN SEPARATE TERMINAL (if not daemonized)\n# Initialize your requestor\nyagna payment init --sender --network holesky\n\n# Request funds on the test network\nyagna payment fund --network holesky\n\n# Check the status of the funds\nyagna payment status --network holesky\n```\n\n### Obtain an `app-key` to use with SDK\n\nIf you don't have any app-keys available from `yagna app-key list`, go ahead and create one with the command below.\nYou will need this key in order to communicate with `yagna` from your application. You can set it\nas `YAGNA_APPKEY` environment variable.\n\n```bash\nyagna app-key create my-golem-app\n```\n\n## Usage\n\nYou can rent a single machine and run a simple task on it:\n\n```ts\nimport { MarketOrderSpec, GolemNetwork } from \"@golem-sdk/golem-js\";\n\n// Define the order that we're going to place on the market\nconst order: MarketOrderSpec = {\n  demand: {\n    workload: { imageTag: \"golem/alpine:latest\" },\n  },\n  market: {\n    // We're only going to rent the provider for 5 minutes max\n    rentHours: 15 / 60,\n    pricing: {\n      model: \"linear\",\n      maxStartPrice: 0.5,\n      maxCpuPerHourPrice: 1.0,\n      maxEnvPerHourPrice: 0.5,\n    },\n  },\n};\n\n(async () =\u003e {\n  const glm = new GolemNetwork();\n\n  try {\n    await glm.connect();\n    // Rent a machine\n    const rental = await glm.oneOf({ order });\n    await rental\n      .getExeUnit()\n      .then((exe) =\u003e exe.run(\"echo Hello, Golem! 👋\"))\n      .then((res) =\u003e console.log(res.stdout));\n    await rental.stopAndFinalize();\n  } catch (err) {\n    console.error(\"Failed to run the example\", err);\n  } finally {\n    await glm.disconnect();\n  }\n})().catch(console.error);\n```\n\nRead about [other available usage patterns](./docs/USAGE.md) to learn more on how you can leverage the SDK.\n\n## Examples\n\nThe [examples directory](./examples) in the repository contains various usage patterns for the SDK. You can browse\nthrough them and learn about the recommended practices. All examples are automatically tested during our release\nprocess.\n\nYou can find even more examples and tutorials in\nthe [JavaScript API section of the Golem Network Docs](https://docs.golem.network/docs/creators/javascript).\n\n## Documentation\n\nVisit our [official documentation](https://docs.golem.network/docs/creators/javascript) to learn more about the\nJavaScript SDK and how to use it.\n\n## Debugging\n\nThe SDK uses the [debug](https://www.npmjs.com/package/debug) package to provide debug logs. To enable them, set\nthe `DEBUG` environment variable to `golem-js:*` or `golem-js:market:*` to see all logs or only the market-related ones,\nrespectively. For more information, please refer to\nthe [debug package documentation](https://www.npmjs.com/package/debug).\n\n## Testing\n\nRead the dedicated [testing documentation](./docs/TESTING.md) to learn more about how to run tests of the SDK.\n\n## Contributing\n\nRead the [Contributing Guide](docs/CONTRIBUTING.md) for details on how you can get involved. In case you find an issue with the examples or the SDK itself, feel free to submit\nan [issue report](https://github.com/golemfactory/golem-js/issues) to the repository.\n\n## Discord\n\nFeel invited to join our [Discord](http://discord.gg/golem). You can meet other SDK users and developers in the `#sdk-discussion` and `#js-discussion` channels.\n\n## See also\n\n- [Golem](https://golem.network), a global, open-source, decentralized supercomputer that anyone can access.\n- Learn what you need to know to set up your Golem requestor node:\n  - [Requestor development: a quick primer](https://docs.golem.network/docs/quickstarts/python-quickstart)\n  - [Quick start](https://docs.golem.network/docs/creators/javascript/quickstarts)\n- Have a look at the most important concepts behind any Golem\n  application: [Golem application fundamentals](https://docs.golem.network/docs/creators/python/guides/application-fundamentals)\n- Learn about preparing your own Docker-like images for\n  the [VM runtime](https://docs.golem.network/docs/creators/javascript/examples/tools/converting-docker-image-to-golem-format)\n- Write your own app with [JavaScript API](https://docs.golem.network/docs/creators/javascript/quickstarts/quickstart)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolemfactory%2Fgolem-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolemfactory%2Fgolem-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolemfactory%2Fgolem-js/lists"}