https://github.com/pannh/rest-countries
A type-safe and seamless wrapper for the REST Countries API v3.1 (https://restcountries.com/)
https://github.com/pannh/rest-countries
api countries easy-to-use geography library npm package rest-countries typesafe typescript wrapper
Last synced: over 1 year ago
JSON representation
A type-safe and seamless wrapper for the REST Countries API v3.1 (https://restcountries.com/)
- Host: GitHub
- URL: https://github.com/pannh/rest-countries
- Owner: PannH
- Created: 2024-05-02T18:54:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-06T10:09:31.000Z (about 2 years ago)
- Last Synced: 2025-01-16T10:38:54.750Z (over 1 year ago)
- Topics: api, countries, easy-to-use, geography, library, npm, package, rest-countries, typesafe, typescript, wrapper
- Language: TypeScript
- Homepage: https://pannh.github.io/rest-countries/
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# REST Countries
This library is a wrapper for the [REST Countries API (v3.1)](https://restcountries.com/) to access information about 250 countries around the world easily and is written in TypeScript to ensure type safety and provide a better developer experience.
## Links
- [REST Countries API](https://restcountries.com/)
- [GitHub](https://github.com/PannH/rest-countries)
- [npm](https://www.npmjs.com/package/rest-countries)
- [Documentation](https://pannh.github.io/rest-countries/)
- [Contact me](https://bento.me/pannh)
## Installation
```bash
npm i rest-countries
yarn add rest-countries
pnpm add rest-countries
bun add rest-countries
```
## Example
```typescript
import { getAll, searchByName } from 'rest-countries';
// Fetch all the countries
const countries = await getAll();
// Fetch all the countries with filtered fields (this will make the request faster)
const countries = await getAll(['name', 'capital', 'population']);
// Search amoung countries by their name
const countries = await searchByName('Vietnam');
```