{"id":13674472,"url":"https://github.com/noandrea/geo2tz","last_synced_at":"2025-04-05T17:05:33.969Z","repository":{"id":47133016,"uuid":"261702733","full_name":"noandrea/geo2tz","owner":"noandrea","description":"A self-hostable REST-like API to get the time zone from geo coordinates","archived":false,"fork":false,"pushed_at":"2025-03-24T10:14:33.000Z","size":126255,"stargazers_count":79,"open_issues_count":4,"forks_count":17,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T16:08:36.132Z","etag":null,"topics":["api","geo","rest","timezones"],"latest_commit_sha":null,"homepage":"","language":"Go","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/noandrea.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-06T08:51:22.000Z","updated_at":"2025-03-24T10:14:25.000Z","dependencies_parsed_at":"2025-02-03T20:41:18.826Z","dependency_job_id":null,"html_url":"https://github.com/noandrea/geo2tz","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noandrea%2Fgeo2tz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noandrea%2Fgeo2tz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noandrea%2Fgeo2tz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noandrea%2Fgeo2tz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noandrea","download_url":"https://codeload.github.com/noandrea/geo2tz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"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","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":["api","geo","rest","timezones"],"created_at":"2024-08-02T11:00:51.165Z","updated_at":"2025-04-05T17:05:33.929Z","avatar_url":"https://github.com/noandrea.png","language":"Go","funding_links":[],"categories":["Software"],"sub_categories":["Maps and Global Positioning System (GPS)"],"readme":"# Geo2Tz\n\n[![QA](https://github.com/noandrea/geo2tz/actions/workflows/quality.yml/badge.svg)](https://github.com/noandrea/geo2tz/actions/workflows/quality.yml) [![GoDoc](https://godoc.org/github.com/noandrea/geo2tz?status.svg)](https://godoc.org/github.com/noandrea/geo2tz) [![Go Report Card](https://goreportcard.com/badge/github.com/noandrea/geo2tz)](https://goreportcard.com/report/github.com/noandrea/geo2tz)\n\nA self-host-able service to get the timezone given geo-coordinates (lat/lng)\n\nTimezone data comes from [github.com/evansiroky/timezone-boundary-builder](https://github.com/evansiroky/timezone-boundary-builder).\n\n[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua/)\n\n## Maturity Level\n\nThis project is considered mature and stable, having undergone extensive testing and refinement over time. It is now in a state where it can be reliably used in production environments. The following statistic shows the number of docker pulls for the project:  \n\n![Docker Pulls](https://img.shields.io/docker/pulls/noandrea/geo2tz?style=for-the-badge)\n\n### Contributing\nWe value your feedback and contributions! If you encounter any bugs or have ideas for new features, please don't hesitate to [open an issue](https://github.com/noandrea/geo2tz/issues/new). Your input is crucial in helping us improve and evolve the project.\n\n## Motivations\n\nGeo-coordinates might be sensitive information to share in any context, this project provides a privacy-friendly, self-hosted solution to ensure that coordinates were not leaked to 3rd party services.\n\n## API\n\nthe service exposes one API to retrieve the timezone given a pair of coordinates:\n\n```http\nGET /tz/${LATITUDE}/${LONGITUDE}\n```\n\nthat returns a JSON reply (`http/200`), for example:\n\n```console\ncurl -s http://localhost:2004/tz/51.477811/0 | jq\n```\n\n```json\n{\n  \"coords\": {\n    \"lat\": 51.47781,\n    \"lon\": 0\n  },\n  \"tz\": \"Europe/London\"\n}\n\n```\n\nor in case of errors (`http/4**`), for example:\n\n```console\ncurl -v http://localhost:2004/tz/51.477811/1000 | jq\n*   Trying 127.0.0.1:2004...\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to localhost (127.0.0.1) port 2004 (#0)\n\u003e GET /tz/51.477811/1000 HTTP/1.1\n\u003e Host: localhost:2004\n\u003e User-Agent: curl/7.81.0\n\u003e Accept: */*\n\u003e\n* Mark bundle as not supporting multiuse\n\u003c HTTP/1.1 400 Bad Request\n\u003c Content-Type: application/json; charset=UTF-8\n\u003c Vary: Origin\n\u003c Date: Fri, 23 Jun 2023 19:09:29 GMT\n\u003c Content-Length: 54\n\u003c\n{ [54 bytes data]\n100    54  100    54    0     0  89403      0 --:--:-- --:--:-- --:--:-- 54000\n* Connection #0 to host localhost left intact\n\n```\n\n```json\n{\n  \"message\": \"lon value 1000 out of range (-180/+180)\"\n}\n```\n\nThe version of the database is exposed at `/tz/version`:\n\n```console\ncurl -s http://localhost:2004/tz/version | jq\n```\n\n```json\n{\n  \"version\": \"2024a\",\n  \"url\": \"https://github.com/evansiroky/timezone-boundary-builder/releases/tag/2024a\",\n  \"geo_data_url\": \"https://github.com/evansiroky/timezone-boundary-builder/releases/download/2024a/timezones-with-oceans.geojson.zip\"\n}\n```\n\n### Authorization\n\nGeo2Tz supports a basic token authorization mechanism, if the configuration value for `web.auth_token_value` is a non-empty string, geo2tz will check the query parameter value to authorize incoming requests.\n\nFor example, running the service with:\n\n```sh\ndocker run --pull=always -p 2004:2004 -e GEO2TZ_WEB_AUTH_TOKEN_VALUE=secret ghcr.io/noandrea/geo2tz:latest\n```\n\nwill enable authorization. With the authorization enabled, a query that does not specify the token will fail with an HTTP code 401:\n\n```sh\n\u003e curl -sv http://localhost:2004/tz/41.902782/12.496365 | jq\n```\n\n```\n*   Trying 127.0.0.1:2004...\n* Connected to localhost (127.0.0.1) port 2004 (#0)\n\u003e GET /tz/41.902782/12.496365 HTTP/1.1\n\u003e Host: localhost:2004\n\u003e User-Agent: curl/7.81.0\n\u003e Accept: */*\n\u003e\n* Mark bundle as not supporting multiuse\n\u003c HTTP/1.1 401 Unauthorized\n\u003c Content-Type: application/json; charset=UTF-8\n\u003c Vary: Origin\n\u003c Date: Sun, 31 Jul 2022 20:06:56 GMT\n\u003c Content-Length: 27\n\u003c\n{ [27 bytes data]\n* Connection #0 to host localhost left intact\n{\n  \"message\": \"unauthorized\"\n}\n```\n\nPassing the token in the query parameters will succeed instead:\n\n```sh\n\u003e curl -s http://localhost:2004/tz/41.902782/12.496365\\?t\\=secret | jq\n```\n\n```json\n{\n  \"coords\": {\n    \"lat\": 41.902782,\n    \"lon\": 12.496365\n  },\n  \"tz\": \"Europe/Rome\"\n}\n```\n\n\n## Docker\n\nDocker image is available at [geo2tz](https://github.com/noandrea/geo2tz/pkgs/container/geo2tz)\n\n```sh\ndocker run --pull=always -p 2004:2004 ghcr.io/noandrea/geo2tz:latest\n```\n\nThe image is built on [scratch](https://hub.docker.com/_/scratch):\n\n\n## Docker compose\n\nDocker compose YAML example\n\n```yaml\nversion: '3'\nservices:\n  geo2tz:\n    container_name: geo2tz\n    image: ghcr.io/noandrea/geo2tz:latest\n    ports:\n    - 2004:2004\n    # uncomment to enable authorization via request token\n    # environment:\n    # - GEO2TZ_WEB_AUTH_TOKEN_VALUE=somerandomstringhere\n    # - GEO2TZ_WEB_AUTH_TOKEN_PARAM_NAME=t\n    # - GEO2TZ_WEB_LISTEN_ADDRESS=\":2004\"\n\n```\n\n## K8s\n\nKubernetes configuration example:\n\n```yaml\n---\n# Deployment\napiVersion: extensions/v1beta1\nkind: Deployment\nmetadata:\n  labels:\n    app: geo2tz\n  name: geo2tz\nspec:\n  replicas: 1\n  revisionHistoryLimit: 3\n  selector:\n    matchLabels:\n      app: geo2tz\n  template:\n    metadata:\n      labels:\n        app: geo2tz\n    spec:\n      containers:\n      - env:\n        # if this var is not empty it will enabled token authorization for requests\n        #- name: GEO2TZ_WEB_AUTH_TOKEN_VALUE\n        #  value: \"secretsmaybebetter\" # default is empty\n        #- name: GEO2TZ_WEB_AUTH_TOKEN_PARAM_NAME\n        #  value: \"t\" # default value\n        #- name: GEO2TZ_WEB_LISTEN_ADDRESS\n        #  value: \":2004\" # default value\n        image: ghcr.io/noandrea/geo2tz:latest\n        imagePullPolicy: Always\n        name: geo2tz\n        ports:\n        - name: http\n          containerPort: 2004\n---\n# Service\n# the service for the above deployment\napiVersion: v1\nkind: Service\nmetadata:\n  name: geo2tz-service\nspec:\n  type: ClusterIP\n  ports:\n  - name: http\n    port: 80\n    protocol: TCP\n    targetPort: http\n  selector:\n    app: geo2tz\n\n```\n\n## Development notes\n\nTo update the timezone database you have a few options:\n\n1. download the version specified in the `tzdata/version.json` file\n\n```console\ngeo2tz update current\n```\n\n2. update to the latest version available\n\n```console\ngeo2tz update latest\n```\n\n2. update to a specific version\n\n```console\ngeo2tz update 2023b\n```\n\n\nthe `update` command will download the timezone geojson zip and generate a version file in the `tzdata` directory, the version file is used to track the current version of the database.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoandrea%2Fgeo2tz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoandrea%2Fgeo2tz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoandrea%2Fgeo2tz/lists"}