open-index/open-npm huggingface dataset:
npm package: @skywatch/api
Description: Skywatch API Library
Author: Skywatch
Latest version: 1.3.3

<h3 align="center">
  Skwatch API Library
</h3>

<p align="center">
  <a href="https://www.npmjs.com/package/@skywatch/api"><img src="https://img.shields.io/npm/v/@skywatch/api?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/@skywatch/api"><img src="https://img.shields.io/npm/dm/@skywatch/api?style=flat-square"></a>
</p>

## License

- Licensed under the Apache License, Version 2.0 (the "License");
npm package: @skywatch/js
Description: Skywatch JavaScript Library
Author: Skywatch
Latest version: 1.3.3

<h3 align="center">
  Skwatch JS Library
</h3>

<p align="center">
  <a href="https://www.npmjs.com/package/@skywatch/js"><img src="https://img.shields.io/npm/v/@skywatch/js?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/@skywatch/js"><img src="https://img.shields.io/npm/dm/@skywatch/js?style=flat-square"></a>
</p>

## Installation

### Step 1

```
npm install @skywatch/js
```

or

```
yarn add @skywatch/js
```

### Step 2

#### Option 1:

[Use Oauth 2.0 to get access token](/packages/js/doc/oauth2.md)

#### Option 2:

Before you start developing, you have to implement Skywatch library on your server. Please follow the guide below to create a POST method url on your server, and then keep the POST method url you generated.

Ex. Implement Skywatch library on node server, and then generate the POST API - https://localhost:3000/skywatch_service_url

##### Guide:

[Skywatch Server Installation Guide](/packages/server#readme)

## Usage

```javascript
<script src="https://cdn.jsdelivr.net/npm/@skywatch/js/dist/skywatch.min.js"></script>
<div id="root"></div>
<script>
    const options = {
      autoplay: true,
      muted: true,
      aspectRatio: '16:9',
      mobileView: false,
    };
    Skywatch.initialize('/your_server_url_with_skywatch_library', 'access_token');
    Skywatch.ArchivesPlayer(
      document.getElementById('root'),
      'device_id',
      'archiveId',
      'smart_ff',
      'seek',
      'options',
    ).then(player => {
      //do something
    });
</script>
```

## API Document

[Camera API Usage](/packages/js/doc/camera.md)

[Lock API Usage](/packages/js/doc/lock.md)

[User API Usage](/packages/js/doc/user.md)

## License

- This project is inspired by [video.js](https://www.videojs.com).
- This project is inspired by [flv.js](https://github.com/Bilibili/flv.js/).
- Licensed under the Apache License, Version 2.0 (the "License");
npm package: @skywatch/server
Description: Skywatch Server Library
Author: Skywatch
Latest version: 1.2.4

<h3 align="center">
  Skwatch API Server
</h3>

<p align="center">
  <a href="https://www.npmjs.com/package/@skywatch/server"><img src="https://img.shields.io/npm/v/@skywatch/server?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/@skywatch/server"><img src="https://img.shields.io/npm/dm/@skywatch/server?style=flat-square"></a>
</p>

## Installation

```
npm install @skywatch/server
```

or

```
yarn add @skywatch/server
```


## How to use:

Create GET and POST methods on your server.

Take [Express](https://github.com/expressjs/express) as an example.

### For dev needs, you can just copy this code snippet and launch your [Express](https://github.com/expressjs/express) service on the local.
```javascript
const bodyParser = require('body-parser');
const express = require('express');
const skywatchServer = require('@skywatch/server');

const port = 3000;

app.prepare().then(() => {
  const server = express();
  
  const verify = (req, _, buf) => {
    req.rawBody = buf.toString();
  };
  server.use(bodyParser.json({ verify }));
  server.use(bodyParser.urlencoded({ extended: false, verify }));

  // skywatch api library for GET request
  server.get('/*', async (req, res) => {
    try {
      const result = await skywatchServer.Skywatch(req);
      res.send(result.data);
    } catch (err) {
      res.status(err.response.status).send(err.response.data);
    }
  });

  // skywatch api library for POST request
  server.post('/*', async (req, res) => {
    try {
      const result = await skywatchServer.Skywatch(req);
      res.send(result.data);
    } catch (err) {
      res.status(err.response.status).send(err.response.data);
    }
  });

  server.listen(port, (err) => {
    if (err) return console.log(`Something bad happened: ${err}`);
    console.log(`Node.js server listening on ${port}`);
  });
});
```

### Detail 

```javascript
const skywatchServer = require('@skywatch/server');

server.get('/*', async (req, res) => {
  try {
    const result = await skywatchServer.Skywatch(req);
    res.send(result.data);
  } catch (err) {
    res.status(err.response.status).send(err.response.data);
  }
});

server.post('/*', async (req, res) => {
  try {
    const result = await skywatchServer.Skywatch(req);
    res.send(result.data);
  } catch (err) {
    res.status(err.response.status).send(err.response.data);
  }
});
```