{"id":31744789,"url":"https://github.com/stacksjs/ts-countries","last_synced_at":"2025-10-09T12:18:32.367Z","repository":{"id":281606133,"uuid":"945796954","full_name":"stacksjs/ts-countries","owner":"stacksjs","description":"🌐 Modern \u0026 lightweight package for working with country data.","archived":false,"fork":false,"pushed_at":"2025-10-07T04:10:35.000Z","size":5667,"stargazers_count":3,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-07T04:24:04.887Z","etag":null,"topics":["capitals","continents","countries","iso","iso3166","languages-spoken","library","tld","typescript"],"latest_commit_sha":null,"homepage":"https://ts-countries.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stacksjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["stacksjs","chrisbbreuer"],"open_collective":"stacksjs"}},"created_at":"2025-03-10T06:21:27.000Z","updated_at":"2025-10-03T06:32:52.000Z","dependencies_parsed_at":"2025-03-29T05:24:48.943Z","dependency_job_id":"4e754f10-da51-426e-ab45-5301e8d26fea","html_url":"https://github.com/stacksjs/ts-countries","commit_stats":null,"previous_names":["stacksjs/ts-countries"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/stacksjs/ts-countries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-countries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-countries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-countries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-countries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacksjs","download_url":"https://codeload.github.com/stacksjs/ts-countries/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-countries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278866936,"owners_count":26059670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capitals","continents","countries","iso","iso3166","languages-spoken","library","tld","typescript"],"created_at":"2025-10-09T12:18:27.103Z","updated_at":"2025-10-09T12:18:32.363Z","avatar_url":"https://github.com/stacksjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/stacksjs","https://github.com/sponsors/chrisbbreuer","https://opencollective.com/stacksjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\".github/art/cover.jpg\" alt=\"Social Card of this repo\"\u003e\u003c/p\u003e\n\n[![npm version][npm-version-src]][npm-version-href]\n[![GitHub Actions][github-actions-src]][github-actions-href]\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\u003c!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] --\u003e\n\u003c!-- [![Codecov][codecov-src]][codecov-href] --\u003e\n\n# ts-countries\n\n\u003e A modern TypeScript library for managing and retrieving comprehensive country data with a simple and intuitive API.\n\n## Features\n\n- 🌍 **Comprehensive Data** _Extensive country info including names, codes, currencies, languages, and more_\n- 🔍 **Smart Search** _Powerful filtering and search capabilities_\n- 🌐 **i18n Ready** _Support for multiple languages and translations_\n- 💪 **Type-Safe** _Full TypeScript support with comprehensive type definitions_\n- 🎯 **ISO Compliant** _Implements ISO 3166-1 standards for country codes_\n- 🧪 **Well-Tested** _Comprehensive test suite ensuring reliability_\n- 📦 **Zero Dependencies** _Lightweight and self-contained_\n- 🔄 **Caching** _Built-in caching system for optimal performance_\n\n## Installation\n\n```bash\n# Using npm\nnpm install ts-countries\n\n# Using yarn\nyarn add ts-countries\n\n# Using pnpm\npnpm add ts-countries\n\n# Using bun\nbun add ts-countries\n```\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { countries, country } from 'ts-countries'\n\n// Get a single country\nconst usa = country('US')\nconsole.log(usa.getName()) // Returns 'United States'\nconsole.log(usa.getIsoAlpha2()) // Returns 'US'\nconsole.log(usa.getIsoAlpha3()) // Returns 'USA'\n\n// Get all countries\nconst allCountries = countries()\n\n// Get detailed country list\nconst detailedCountries = countries(true) // longlist format\n\n// Get hydrated Country instances\nconst countryInstances = countries(false, true) // returns Country[]\n```\n\n### Advanced Usage\n\n```typescript\nimport { Country, CountryLoader } from 'ts-countries'\n\n// Working with country data\nconst usa = country('US')\n\n// Access various country properties\nconsole.log(usa.getCapital()) // Get capital city\nconsole.log(usa.getCurrencies()) // Get currency information\nconsole.log(usa.getLanguages()) // Get official languages\nconsole.log(usa.getTimezones()) // Get timezone information\nconsole.log(usa.getGeodata()) // Get geographic data\n\n// Get translations\nconsole.log(usa.getTranslations()) // Get all translations\nconsole.log(usa.getTranslation('fra')) // Get French translation\n\n// Working with native names\nconsole.log(usa.getNativeName()) // Get native name\nconsole.log(usa.getNativeNames()) // Get all native names\n\n// Geographic information\nconsole.log(usa.getRegion()) // Get region\nconsole.log(usa.getSubregion()) // Get subregion\nconsole.log(usa.getContinent()) // Get continent\nconsole.log(usa.getBorders()) // Get bordering countries\n\n// Additional metadata\nconsole.log(usa.getDemonym()) // Get demonym\nconsole.log(usa.getCallingCode()) // Get calling code\nconsole.log(usa.getTld()) // Get top-level domain\n```\n\n### Filtering Countries\n\n```typescript\nimport { CountryCollection } from 'ts-countries'\n\nconst collection = new CountryCollection(countries(false, true))\n\n// Filter by region\nconst europeanCountries = collection.where('geo.region', 'Europe')\n\n// Filter by currency\nconst euroCountries = collection.where('currency.EUR')\n\n// Filter using comparison operators\nconst largeCountries = collection.where('geo.area', '\u003e', 1000000)\n\n// Complex filtering\nconst northAmericanEnglishSpeaking = collection\n  .where('geo.subregion', 'North America')\n  .where('languages.eng', 'English')\n```\n\n## API Reference\n\n### Main Classes\n\n#### Country\n\nRepresents a single country with comprehensive data and helper methods.\n\n#### CountryLoader\n\nStatic class for loading country data with built-in caching.\n\n#### CountryCollection\n\nCollection class for working with multiple countries and filtering.\n\n### Key Methods\n\n#### Country Class Methods\n\n- `getName()`: Get country name\n- `getOfficialName()`: Get official country name\n- `getNativeName(languageCode?)`: Get native name\n- `getIsoAlpha2()`: Get ISO 3166-1 alpha-2 code\n- `getIsoAlpha3()`: Get ISO 3166-1 alpha-3 code\n- `getIsoNumeric()`: Get ISO 3166-1 numeric code\n- `getCurrencies()`: Get currency information\n- `getLanguages()`: Get official languages\n- And many more...\n\n#### CountryLoader Methods\n\n- `country(code: string, hydrate?: boolean)`: Load single country\n- `countries(longlist?: boolean, hydrate?: boolean)`: Load all countries\n- `where(key: string, operator: string, value?: any)`: Filter countries\n\n## Error Handling\n\nThe library throws descriptive exceptions for various error conditions:\n\n- **Invalid Country Code**: When a country code doesn't exist\n- **Missing Data**: When required country data is missing\n- **Invalid Format**: When data format is incorrect\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/stacksjs/stacks/blob/main/.github/CONTRIBUTING.md) for details.\n\n## Community\n\nFor help, discussion about best practices, or any other conversation that would benefit from being searchable:\n\n[Discussions on GitHub](https://github.com/stacksjs/ts-countries/discussions)\n\nFor casual chit-chat with others using this package:\n\n[Join the Stacks Discord Server](https://discord.gg/stacksjs)\n\n## Postcardware\n\n“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.\n\nOur address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎\n\n## Credits\n\n- [Rinvex](https://github.com/rinvex) for the original PHP library\n- [Chris Breuer](https://github.com/chrisbreuer) for the TypeScript conversion\n\n## Sponsors\n\nWe would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.\n\n- [JetBrains](https://www.jetbrains.com/)\n- [The Solana Foundation](https://solana.com/)\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.\n\nMade with 💙\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/ts-countries?style=flat-square\n[npm-version-href]: https://npmjs.com/package/ts-countries\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/ts-countries/ci.yml?style=flat-square\u0026branch=main\n[github-actions-href]: https://github.com/stacksjs/ts-countries/actions?query=workflow%3Aci\n\n\u003c!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/ts-starter/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/stacksjs/ts-starter --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fts-countries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacksjs%2Fts-countries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fts-countries/lists"}