How to use REST Countries — a practical guide

If you're here, you probably want working code in five minutes. That's exactly what this guide does.

Five steps to get started

  1. 1
    GET /v3.1/all for all countries.
  2. 2
    /v3.1/name/israel for a name.
  3. 3
    /v3.1/alpha/il for ISO code.

Shortest snippet that will actually run

curl "https://restcountries.com/v3.1/alpha/il"

Common mistakes (the honest list)

Don't fetch /all every time — download once and cache.