# @keyos/api-sdk

> KeyOS API SDK For Javascript

Latest version **1.0.8** (published 2026-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @keyos/api-sdk
pnpm add @keyos/api-sdk
yarn add @keyos/api-sdk
bun add @keyos/api-sdk
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2026-04-15 |
| First published | 2020-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 36.8 KB |
| Known vulnerabilities | 0 (+36 in 1 direct dependencies) |
| Install scripts | no |
| Author | Herlangga Sefani |
| Maintainers | gaibz |
| Keywords | keyos, sdk, javascript, gaibz |

## Links

- npm: https://www.npmjs.com/package/@keyos/api-sdk
- npm.io page: https://npm.io/package/@keyos/api-sdk

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) 1.15.0

## Recent versions

- 1.0.8 (latest) — 2026-04-15
- 1.0.7 — 2026-04-15
- 1.0.5 — 2024-10-06
- 1.0.4 — 2024-10-06
- 1.0.3 — 2024-10-06
- 1.0.1 — 2023-01-05
- 1.0.0 — 2023-01-05
- 0.4.2 — 2022-03-18
- 0.3.3 — 2020-08-18
- 0.3.2 — 2020-08-18
- 0.3.1 — 2020-05-07
- 0.3.0 — 2020-04-15
- 0.2.0 — 2020-04-11
- 0.1.1 — 2020-04-11
- 0.1.0 — 2020-04-11
- … 13 more at https://npm.io/package/@keyos/api-sdk/versions

## README

# KeyOS API SDK For Javascript 

<h1 align="right">     بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم </h1>

Thanks to Allah for supporting this Project. 

Crafted with 💙 by [Herlangga Sefani](https://www.facebook.com/herlangga.sefani)

Github repository : https://github.com/gaibz/KeyOS-sdk-javascript 

Project started at end of March 2020


## Installation 

    npm install @keyos/api-sdk  

## API Documentation
Complete api documentation can be found on [KeyoS Documentation API](https://doc.keyos.id/shelves/api-documentation) 


## Usage & Example REST

### Initialization

```javascript
const { Rest } = require("@keyos/api-sdk");
let RestApi = new Rest.Api();
```
 
### Example GET Request : Search City or Subdistrict
documentation can be found in : [KeyOS Documentation City or Subdistrict](https://doc.keyos.id/books/rest-api/page/search-city-subdistrict)

```javascript
RestApi.action('GET', 'location/city_or_subdistrict', {
    q : "tasikmalaya" // q is the request parameter, see doc
}).then((response) => {
    // if request success this code will firing
    // response.getStatusCode() for get status code
    // response.getStatusText() for get status text
    // response.getBody() for get response body
    console.log({response});
}).catch((error) => {
    // in case we have some error
    // error.getStatusCode() for get status code
    // error.getStatusText() for get status text
    // error.getBody() for get response body
    console.log({error});
}).finally(() => {
    // this block is optional, and will fired after then and catch finished
});
```

If you want some more Object Oriented way (This will also trigger autocompletion if your text editor support it) : 

```javascript
let request = new Rest.ApiRequest();
request.setPath('location/city_or_subdistrict')
    .setMethod(Rest.METHOD.GET)
    .setRequestQuery({q : 'tasikmalaya'});

RestApi.call(request).then((response) => {
    console.log({response});
}).catch((error) => {
    console.log("error");
    console.log(error);
});
``` 


### Example POST Request : Login / Auth

documentation can be found in : [KeyOS Documentation Admin Login](https://doc.keyos.id/books/rest-api/page/admin-authentication)

```javascript
// we will pass the third parameter since we dont have to specify query parameter
// the fourth parameter is the request body
RestApi.action('POST', 'auth', {}, {
    username : '<some_admin_username>',
    password : '<some_admin_password>',
    roles : 'ADMIN'
}).then((response) => {
    // if request success this code will firing
    // response.getStatusCode() for get status code
    // response.getStatusText() for get status text
    // response.getBody() for get response body
    console.log({response});
}).catch((error) => {
    // in case we have some error
    // error.getStatusCode() for get status code
    // error.getStatusText() for get status text
    // error.getBody() for get response body
    console.log({error});
}).finally(() => {
    // this block is optional, and will fired after then and catch finished
});
```

Object Oriented Style : 
```javascript
let request = new Rest.ApiRequest();
// method chaining style
request.setPath('location/city_or_subdistrict')
.setMethod(Rest.METHOD.GET)
.setRequestBody({
    username : '<some_admin_username>',
    password : '<some_admin_password>',
    roles : 'ADMIN'
});

RestApi.call(request).then((response) => {
    console.log({response});
}).catch((error) => {
    console.log("error");
    console.log(error);
}).finally(() => {
    // This block is optional and will firing after then and catch executed
    // normally this is promise based
});
```

---
_Source: https://npm.io/package/@keyos/api-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
