# cuba-weather-javascript

> Simple SDK for cuba_weather API

Latest version **1.1.3** (published 2021-03-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install cuba-weather-javascript
pnpm add cuba-weather-javascript
yarn add cuba-weather-javascript
bun add cuba-weather-javascript
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2021-03-16 |
| First published | 2020-06-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 62.9 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | kenriortega |
| Maintainers | kenriortega |
| Keywords | cuba-weather, javascript |

## Links

- npm: https://www.npmjs.com/package/cuba-weather-javascript
- Repository: https://github.com/cuba-weather/cuba-weather-javascript
- Homepage: https://github.com/cuba-weather/cuba-weather-javascript#readme
- Issues: https://github.com/cuba-weather/cuba-weather-javascript/issues
- npm.io page: https://npm.io/package/cuba-weather-javascript

## Dependencies (1)

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

## Recent versions

- 1.1.3 (latest) — 2021-03-16
- 1.1.0 — 2021-03-06
- 1.0.10 — 2020-06-26
- 1.0.9 — 2020-06-24
- 1.0.8 — 2020-06-21
- 1.0.7 — 2020-06-20
- 1.0.6 — 2020-06-20
- 1.0.5 — 2020-06-17
- 1.0.4 — 2020-06-17
- 1.0.2 — 2020-06-17

## README

# Cuba Weather JavaScript

[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)

Application programming interface of the Cuba Weather project implemented in JavaScript.

Currently the weather information is obtained from the Cuban search engine [www.redcuba.cu](https://www.redcuba.cu).

## Install

```bash
npm install cuba-weather-javascript
```

You can also clone or download this repository and at the root of the project do:

```bash
git clone https://github.com/cuba-weather/cuba-weather-javascript.git
```

## Test

```bash
npm test
```

### Package Red Cuba Client

```javascript
const { RCApiClient, RCWeather } = require('../index')
async function main() {
  let locationStr = 'Municipio Especial Isla de la Juventud'
  try {
    let res = await RCApiClient.get(locationStr)
    let weather = new RCWeather(res.data.data)
    console.log(weather.weathertoString())
  } catch (err) {
    let error = {
      status: err.response.status,
      statusText: err.response.statusText,
      locationStr,
    }
    console.log(error)
  }
}

main().catch(console.error)
```

### Get weather from RDcuba by municipality

```javascript
const {
  RCApiClient,
  RCWeather,
  RED_CUBA_SOURCE,
  MUNICIPALITIES,
  UtilsService,
} = require('../index')
async function main() {
  let locationStr = 'cerro'
  let municipality = MUNICIPALITIES.find(
    (municipality) => municipality.nameCured === locationStr
  )
  let bestSource = UtilsService.getBestDistanceByMunicipality(
    municipality,
    RED_CUBA_SOURCE
  )

  try {
    let res = await RCApiClient.get(bestSource.name)
    let weather = new RCWeather(res.data.data)
    console.log(weather.weathertoString())
  } catch (err) {
    console.log(err)
  }
}

main().catch(console.error)
```

---
_Source: https://npm.io/package/cuba-weather-javascript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
