Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/ejnshtein/restcountries-js
- Owner: ejnshtein
- Created: 2018-10-23T20:58:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-20T01:32:31.000Z (over 2 years ago)
- Last Synced: 2024-04-23T13:25:55.861Z (8 months ago)
- Topics: countries, restcountries-api
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/restcountries-js
- Size: 284 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
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])