|
| 1 | +# tap-restcountries |
| 2 | + |
| 3 | +`tap-restcountries` is a Singer tap for the [REST Countries](https://restcountries.com/) API (v3.1). |
| 4 | + |
| 5 | +Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +Install from GitHub: |
| 10 | + |
| 11 | +```bash |
| 12 | +uv tool install git+https://github.com/ORG_NAME/tap-restcountries.git@main |
| 13 | +``` |
| 14 | + |
| 15 | +## Streams |
| 16 | + |
| 17 | +| Stream | Endpoint | Primary Key | Replication | |
| 18 | +|-----------|----------|-------------|-------------| |
| 19 | +| countries | `/all` | `cca3` | Full table | |
| 20 | + |
| 21 | +## Configuration |
| 22 | + |
| 23 | +### Accepted Config Options |
| 24 | + |
| 25 | +| Setting | Type | Required | Default | Description | |
| 26 | +|---------|------|----------|---------|-------------| |
| 27 | +| `api_url` | string | No | `https://restcountries.com/v3.1` | Base URL for the REST Countries API | |
| 28 | +| `fields` | array | No | (all) | List of fields to request — see [Fields](#fields) below | |
| 29 | + |
| 30 | +### Fields |
| 31 | + |
| 32 | +> **⚠️ Important:** The REST Countries API enforces a **maximum of 10 fields** when |
| 33 | +> calling the `/all` endpoint. If you need more fields, omit the `fields` setting |
| 34 | +> entirely to retrieve the full response, or make multiple requests with different |
| 35 | +> field selections. |
| 36 | +
|
| 37 | +Available fields: `cca2`, `cca3`, `ccn3`, `cioc`, `fifa`, `independent`, `status`, |
| 38 | +`unMember`, `name`, `altSpellings`, `translations`, `area`, `borders`, `capital`, |
| 39 | +`capitalInfo`, `continents`, `landlocked`, `latlng`, `maps`, `region`, `subregion`, |
| 40 | +`timezones`, `population`, `languages`, `demonyms`, `currencies`, `idd`, `tld`, |
| 41 | +`postalCode`, `startOfWeek`, `car`, `gini`, `flag`, `flags`, `coatOfArms`. |
| 42 | + |
| 43 | +Example configuration selecting specific fields: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "fields": ["name", "cca2", "cca3", "capital", "region", "population"] |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +### Configure using environment variables |
| 52 | + |
| 53 | +This Singer tap will automatically import any environment variables within the working directory's |
| 54 | +`.env` if the `--config=ENV` is provided, such that config values will be considered if a matching |
| 55 | +environment variable is set either in the terminal context or in the `.env` file. |
| 56 | + |
| 57 | +```bash |
| 58 | +export TAP_RESTCOUNTRIES_API_URL=https://restcountries.com/v3.1 |
| 59 | +export TAP_RESTCOUNTRIES_FIELDS='["name","cca2","capital"]' |
| 60 | +``` |
| 61 | + |
| 62 | +### Source Authentication and Authorization |
| 63 | + |
| 64 | +No authentication is required. The REST Countries API is free and open. |
| 65 | + |
| 66 | +## Usage |
| 67 | + |
| 68 | +You can easily run `tap-restcountries` by itself or in a pipeline using [Meltano](https://meltano.com/). |
| 69 | + |
| 70 | +### Executing the Tap Directly |
| 71 | + |
| 72 | +```bash |
| 73 | +tap-restcountries --version |
| 74 | +tap-restcountries --help |
| 75 | +tap-restcountries --config CONFIG --discover > ./catalog.json |
| 76 | +``` |
| 77 | + |
| 78 | +## Developer Resources |
| 79 | + |
| 80 | +Follow these instructions to contribute to this project. |
| 81 | + |
| 82 | +### Initialize your Development Environment |
| 83 | + |
| 84 | +Prerequisites: |
| 85 | + |
| 86 | +- Python 3.10+ |
| 87 | +- [uv](https://docs.astral.sh/uv/) |
| 88 | + |
| 89 | +```bash |
| 90 | +uv sync |
| 91 | +``` |
| 92 | + |
| 93 | +### Create and Run Tests |
| 94 | + |
| 95 | +Create tests within the `tests` subfolder and |
| 96 | +then run: |
| 97 | + |
| 98 | +```bash |
| 99 | +uv run pytest |
| 100 | +``` |
| 101 | + |
| 102 | +You can also test the `tap-restcountries` CLI interface directly using `uv run`: |
| 103 | + |
| 104 | +```bash |
| 105 | +uv run tap-restcountries --help |
| 106 | +``` |
| 107 | + |
| 108 | +### Testing with [Meltano](https://www.meltano.com) |
| 109 | + |
| 110 | +_**Note:** This tap will work in any Singer environment and does not require Meltano. |
| 111 | +Examples here are for convenience and to streamline end-to-end orchestration scenarios._ |
| 112 | + |
| 113 | +Use Meltano to run an EL pipeline: |
| 114 | + |
| 115 | +```bash |
| 116 | +# Install meltano |
| 117 | +uv tool install meltano |
| 118 | + |
| 119 | +# Test invocation |
| 120 | +meltano invoke tap-restcountries --version |
| 121 | + |
| 122 | +# Run a test EL pipeline |
| 123 | +meltano run tap-restcountries target-jsonl |
| 124 | +``` |
| 125 | + |
| 126 | +### SDK Dev Guide |
| 127 | + |
| 128 | +See the [dev guide](https://sdk.meltano.com/en/latest/dev_guide.html) for more instructions on how to use the SDK to |
| 129 | +develop your own taps and targets. |
| 130 | +# tap-restcountries |
0 commit comments