# @map-colonies/node-osm-api

> easy communication with osm api

Latest version **1.0.0** (published 2020-12-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @map-colonies/node-osm-api
pnpm add @map-colonies/node-osm-api
yarn add @map-colonies/node-osm-api
bun add @map-colonies/node-osm-api
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-12-09 |
| First published | 2020-12-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 29.6 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | galta95 |
| Maintainers | glata95, tropface, rannyeli, alebinson, shimoncohen, konchashlomicl, shahar_s, schnitz, asaf.masa, syncush, mapcolonies |

## Links

- npm: https://www.npmjs.com/package/@map-colonies/node-osm-api
- Repository: https://github.com/MapColonies/node-osm-api
- Homepage: https://github.com/MapColonies/node-osm-api#readme
- Issues: https://github.com/MapColonies/node-osm-api/issues
- npm.io page: https://npm.io/package/@map-colonies/node-osm-api

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.21.0
- [http-status-codes](https://npm.io/package/http-status-codes.md) ^2.1.4

## Recent versions

- 1.0.0 (latest) — 2020-12-09

## README

# node-osm-api

Easy Node.js, TypeScript communication with OpenStreetMap api

```ts
import { Apiv6 } from '@map-colonies/node-osm-api';

const api = new Apiv6('https://www.openstreetmap.org', USER_NAME, PASSWORD);
```

## Installation

```shell
$ npm install @map-colonies/node-osm-api
```

## Usage

- Right now we only support create/upload/close changesets

In Node.js TypeScript:

Performing `Create changeset`:

```ts
let changesetID: number;

async function createChangeset() {
  try {
    changesetID = await api.createChangeset(CREATE_CHANGESET_BODY_XML);
  } catch (e) {
    console.error(e);
  }
}
```

Possibble error types:

- `UnauthorizedError`
- `BadXmlError`

---

Performing `Upload changeset`:

```ts
let diffRes: string;

async function uploadChangeset() {
  try {
    // returns osm xml diff result as string
    diffRes = await api.uploadChangeset(CHANGESET_ID, OSC_XML);
  } catch (e) {
    console.error(e);
  }
}
```

Possibble error types:

- `UnauthorizedError`
- `BadXmlError`
- `ChangesetOrDiffElementsNotFoundError`
- `ChangesetAlreadyClosedError`
- `OwnerMismatchError`
- `MismatchChangesetError`

---

Performing `Close changeset`:

```ts
async function closeChangeset() {
  try {
    await api.closeChangeset(CHANGESET_ID);
  } catch (e) {
    console.error(e);
  }
}
```

Possibble error types:

- `UnauthorizedError`
- `NotAllowedError`
- `ChangesetNotFoundError`
- `ChangesetAlreadyClosedError`
- `OwnerMismatchError`

## JavaScript

```js
const nodeOsmApi = require('node-osm-api');

const api = new nodeOsmApi.Apiv6('https://www.openstreetmap.org', USER_NAME, PASSWORD);

async function createChangeset() {
  try {
    changesetID = await api.createChangeset(CREATE_CHANGESET_BODY_XML);
  } catch (e) {
    console.error(e);
  }
}
```

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