Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ejnshtein/restcountries-js

restcountries api wrapper for javascript
https://github.com/ejnshtein/restcountries-js

countries restcountries-api

Last synced: 2 months ago
JSON representation

restcountries api wrapper for javascript

Awesome Lists containing this project

README

        

# Restcountries-js

This is a Javascript wrapper around API provided by [Restcountries](https://restcountries.eu).

## Installation

npm i restcountries-js

## Example in Node.js

```js
const restcountries = require('restcoutries-js')
restcountries().all()
.then(data => {
console.log(data)
})
```

## ES6 import

```js
import restcountries from 'restcoutries-js'
restcoutries().all().then(data => {
console.log(data)
})
```

## Webrowser

```html


restcoutries().all().then(data => {
console.log(data)
})

```

## restcountries-js API

You can use your own API server, but it will work only with clone of [this](https://github.com/apilayer/restcountries). This wrapper uses https://restcountries.eu endpoint as default.

#### restcountries(baseUrl)

```js
restcountries('http://my.path.to/api').all()
.then(data => {
console.log(data)
})
```

### restcountries method aliases

#### restcountries.all([extra])
#### restcountries.name(name[, fullText[, extra]])
#### restcountries.code(code[, extra])
#### restcountries.codes(codes[, extra])
#### restcountries.currency(currency[, extra])
#### restcountries.capital(capital[, extra])
#### restcountries.callingCode(callingCode[, extra])
#### restcountries.region(region[, extra])
#### restcountries.regionalBloc(regionalBloc[, extra])

These methods full description availble here: https://github.com/apilayer/restcountries

## Contact

[Telegram](https://t.me/ejnshtein) or by [email](mailto:[email protected])