{"id":18764088,"url":"https://github.com/oddbit/nexudus-js","last_synced_at":"2025-04-13T04:33:04.540Z","repository":{"id":57140304,"uuid":"104450798","full_name":"oddbit/nexudus-js","owner":"oddbit","description":"An easy to use and Typscript friendly API client for Nexudus.","archived":false,"fork":false,"pushed_at":"2019-03-22T14:19:36.000Z","size":26,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-26T21:47:03.635Z","etag":null,"topics":["access-management","coworking","coworking-space","coworking-space-management","membership-management","nexudus","npm-module","npm-package","typescript"],"latest_commit_sha":null,"homepage":"http://help.spaces.nexudus.com/en/api","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oddbit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-22T08:28:35.000Z","updated_at":"2024-05-08T05:12:44.000Z","dependencies_parsed_at":"2022-09-04T22:10:32.164Z","dependency_job_id":null,"html_url":"https://github.com/oddbit/nexudus-js","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Fnexudus-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Fnexudus-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Fnexudus-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Fnexudus-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oddbit","download_url":"https://codeload.github.com/oddbit/nexudus-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248664392,"owners_count":21141945,"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":["access-management","coworking","coworking-space","coworking-space-management","membership-management","nexudus","npm-module","npm-package","typescript"],"created_at":"2024-11-07T18:28:39.712Z","updated_at":"2025-04-13T04:33:04.299Z","avatar_url":"https://github.com/oddbit.png","language":"TypeScript","readme":"# @oddbit/nexudus \n![License](https://img.shields.io/npm/l/@oddbit/nexudus.svg)\n![NPM version](https://img.shields.io/npm/v/@oddbit/nexudus.svg)\n![Total NPM downloads](https://img.shields.io/npm/dt/@oddbit/nexudus.svg)\n[![Travis build status](https://img.shields.io/travis/oddbit/nexudus-js.svg)](https://travis-ci.org/oddbit/nexudus-js)\n\nAn easy to use and Typscript friendly API client for Nexudus.\n\n## Admin API \nThe admin API requires a [registered Nexudus \"App\"](http://help.spaces.nexudus.com/en/api/getting-started.html) and an auth token.\n\n\u003e The Nexudus Spaces API allows you to develop Apps and modules that extend the Nexudus Spaces platform. You can implment features that your business may require or even create solutions that can be sold to other Nexudus Spaces customers.\n\nIn order to create an App you need a Nexudus account for your business or if you have set up a \"test space\" for sandbox testing (perhaps you should check first with Nexudus to see what they advice: info@nexudus.com).\n\nLog in to your space and enter the \"Apps list\" and create an entry for your own App: https://spaces.nexudus.com/Apps/Applications\n\nSelect all the permissions that are matching the API endpoints that you intend to be using.\n\n### Usage\nBefore you can use the *admin API client* you must complete an installation request that Nexudus will push to your endpoint when a someone is choosing to activate/install your App.\n\nPlease read the [official API documentation](http://help.spaces.nexudus.com/en/api/authentication.html) to learn more about the variables that are passed in the `requests.query` that is used to initialize `AppInstallationRequest` in the example below.\n\n#### Consuming installation request\n\n```typescript\nimport * as nexudus from \"@oddbit/nexudus\";\n\nfunction apiEndoint(request, response) {\n    // Store your secret/public app keys safely somewhere...\n    const application = new nexudus.Application(SECRET_APP_KEY, PUBLIC_APP_KEY);\n\n    const installationRequest = new nexudus.AppInstallationRequest(request.query);\n\n    try {\n        application.validate(installationRequest);\n    } catch(err) {\n        response.status(401).send(\"The installation request was not valid\");\n        return;\n    }\n    const apiAuthToken = application.createAuthToken(installationRequest);\n\n    // ...\n    // Store the apiAuthToken somewhere in your database\n    // ...\n    // Do other stuffs\n    // ...\n\n    response.status(200).send(\"Install succsess!\");\n}\n```\n\n#### Fetch all businesses\nIn the example below, we're fetching all `Business` objects that a certain account. See the documentation the official documentation for how Nexudus is organizing the hierarchy and relationships between *businesses*, *user*, *coworkers* and *check-ins*. \n\n```typescript\nimport * as nexudus from \"@oddbit/nexudus\";\n\nconst apiClient = new nexudus.AdminApiClient(apiAuthToken);\nconst nexudusBusinessList = await apiClient.getBusinesses();\nnexudusBusinessList.forEeach(nexudusBusiness =\u003e {\n    console.log(`Got business '${nexudusBusiness.Name}' with id: ${nexudusBusiness.Id}`);\n});\n```\n#### Fetch businesses and filter results\nCurrently it's only supported to filter the results by \"time of update\", which allows you to only fetch records that has been updated after a certain point in time.\n\n ```typescript\nconst timestamp = new Date(2015, 3, 1);\nconst nexudusBusinessList = await apiClient.getBusinesses({updatedAfter: timestamp.getTime()});\n```\n\n#### Fetch single businesses \n\n ```typescript\n// You must know the Nexudus ID of the business\nconst nexudusBusiness = await apiClient.getBusiness(12345);\n```\n\n#### Update \nThe API client will perform an **update** if the data object contains an `Id`. The operation will fail if Nexudus does not know of any corresponding object with that id (i.e. if it hasn't been created yet).\n\n ```typescript\nconst nexudusBusiness = {\n    \"Id\": 123456,\n    \"Name\": \"Kumpul Coworking Space\",\n    \"WebAddress\": \"https://www.kumpul.co\"\n} as nexudus.Business;\nawait apiClient.saveBusiness(nexudusBusiness);\n```\n\n#### Create \nThe API client will **create** a new record at Nexudus if there is no `Id` attribute present. \n ```typescript\nconst nexudusBusiness = {\n    \"Name\": \"Kumpul Coworking Space\",\n    \"WebAddress\": \"https://www.kumpul.co\"\n} as nexudus.Business;\nawait apiClient.saveBusiness(nexudusBusiness);\n```\n\n#### Delete \n\n ```typescript\n// You must know the Nexudus ID of the business\nawait apiClient.deleteBusiness(12345);\n```\n\n\n## Public API\nThe public API is designed to work with the public resources of the space **and** also member restricted resources. The API is using the member's email and password for authentication, which makes it easier to use and apply in your application. But it is also restricted in its powers. You can't do things like \"check in\" or \"check out\".\n\n### Usage\n\nIn the example below, we're fetching the `Coworker` object of the user *\"john.doe@example.com\"* at Nexudus. See the documentation on the difference between \"User\" and \"Coworker\" at [Nexudus's API documentation](http://help.spaces.nexudus.com/en/api/public/profile.html).\n\nThe API client is throwing a `HTTP 401` error if username or password is wrong.\n\n```typescript\nimport * as nexudus from \"@oddbit/nexudus\";\n\nconst apiClient = new nexudus.PublicApiClient(\"kumpul\", \"john.doe@example.com\", \"secretPassword\");\n\ntry {\n    const nexudusCoworker = await apiClient.getCoworker();\n} catch (err) {\n    console.log(`You just got yourself a HTTP ${err.statusCode} error: ${err.message}`);\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foddbit%2Fnexudus-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foddbit%2Fnexudus-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foddbit%2Fnexudus-js/lists"}