{"id":32181427,"url":"https://github.com/sgsfak/clj-ocgeo","last_synced_at":"2025-10-21T22:46:23.526Z","repository":{"id":62431486,"uuid":"232174512","full_name":"sgsfak/clj-ocgeo","owner":"sgsfak","description":"A Clojure library for accessing the OpenCage geocoder ","archived":false,"fork":false,"pushed_at":"2020-01-08T22:44:09.000Z","size":16,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T22:46:20.832Z","etag":null,"topics":["geocoding","opencage-api","opencage-geocoder"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/sgsfak.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}},"created_at":"2020-01-06T19:54:22.000Z","updated_at":"2022-08-10T09:42:53.000Z","dependencies_parsed_at":"2022-11-01T20:46:31.227Z","dependency_job_id":null,"html_url":"https://github.com/sgsfak/clj-ocgeo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sgsfak/clj-ocgeo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgsfak%2Fclj-ocgeo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgsfak%2Fclj-ocgeo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgsfak%2Fclj-ocgeo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgsfak%2Fclj-ocgeo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgsfak","download_url":"https://codeload.github.com/sgsfak/clj-ocgeo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgsfak%2Fclj-ocgeo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280348056,"owners_count":26315367,"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-21T02:00:06.614Z","response_time":58,"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":["geocoding","opencage-api","opencage-geocoder"],"created_at":"2025-10-21T22:46:19.315Z","updated_at":"2025-10-21T22:46:23.518Z","avatar_url":"https://github.com/sgsfak.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj-ocgeo\n\nA Clojure library for accessing the [OpenCage Geocoding API](https://opencagedata.com/)\n\n[![Clojars Project](https://img.shields.io/clojars/v/clj-ocgeo.svg)](https://clojars.org/clj-ocgeo)\n[![cljdoc badge](https://cljdoc.org/badge/clj-ocgeo/clj-ocgeo)](https://cljdoc.org/d/clj-ocgeo/clj-ocgeo/0.2.1/)\n\n\n## Getting started\n\nSimply add `clj-ocgeo` as a dependency to your lein project:\n\n```clojure\n[clj-ocgeo \"0.2.1\"]\n```\n\nThen execute\n\n```\nlein deps\n```\n\nAnd import the library into your namespace\n\n```clojure\n(:use clj-ocgeo.core)\n```\n\nOr  in the \"repl\":\n\n```clojure\n(require '[clj-ocgeo.core :refer :all])\n```\n\n## Usage\n\nThe client should have an API key by [registering](https://opencagedata.com/users/sign_up) with the OpenCage Geocoder. It's also always good to check the [best practices for using the OpenCage API](https://opencagedata.com/api#bestpractices), and in particular [how to format forward geocoding queries](https://github.com/OpenCageData/opencagedata-roadmap/blob/master/query-formatting.md).\n\nTo make a \"forward\" request to get the coordinates of a given place or address, the following function call can be used:\n\n```clojure\n(forward-request \"Friedrich-Ebert-Straße 7, 48153 Münster, Germany\" \"6d0e711d72d74daeb2b0bfd2a5cdfdba\")\n```\n\nOr a \"reverse\" request (i.e. given the latitude and longitude coordinates, it returns a list of human understandable place names or addresses):\n\n```clojure\n(forward-request 51.9526599 7.632473 \"6d0e711d72d74daeb2b0bfd2a5cdfdba\")\n```\n\nBoth functions return a [Clojure Map](https://clojure.org/guides/learn/hashed_colls#_maps) with keyword keys so for example to get the status code of the `response` you can do:\n\n```clojure\n(:status response)\n;; Returns:\n;; {:code 200, :message \"OK\"}\n```\n\n(For this specific example, you can also call the `response-ok?` helper function  that returns `true` when the status code is 200)\n\nA number of keyword arguments corresponding to the [optional parameters](https://opencagedata.com/api#forward-opt) of the OpenCage Geocoding API can be also supplied to both \"request\" functions, e.g.\n\n```clojure\n(forward-request 51.9526599 7.632473 \"6d0e711d72d74daeb2b0bfd2a5cdfdba\"\n\t\t:countrycode \"de\" :no_annotations true :min_confidence 5)\n```\n\nAnother example, showing the first result of a request is shown below:\n\n```clojure\n(when-let [r (-\u003e (forward-request \"Friedrich-Ebert-Straße 7\" \"6d0e711d72d74daeb2b0bfd2a5cdfdba\")\n                 :results\n                 first)]\n  (pprint r))\n\n;; {:annotations\n;;  {:timezone\n;;   {:name \"Europe/Berlin\",\n;;    :now_in_dst 0,\n;;    :offset_sec 3600,\n;;    :offset_string \"+0100\",\n;;    :short_name \"CET\"},\n;;   :roadinfo\n;;   {:drive_on \"right\",\n;;    :road \"Friedrich-Ebert-Straße\",\n;;    :speed_in \"km/h\"},\n;;   :geohash \"u1jrt9ty1t8rg3r5wttm\",\n;;   :what3words {:words \"episodes.mass.below\"},\n;;   :flag \"🇩🇪\",\n;;   :OSM\n;;   {:edit_url\n;;    \"https://www.openstreetmap.org/edit?way=125838041#map=17/51.95266/7.63247\",\n;;    :note_url\n;;    \"https://www.openstreetmap.org/note/new#map=17/51.95266/7.63247\u0026layers=N\",\n;;    :url\n;;    \"https://www.openstreetmap.org/?mlat=51.95266\u0026mlon=7.63247#map=17/51.95266/7.63247\"},\n;;   :currency\n;;   {:symbol \"€\",\n;;    :name \"Euro\",\n;;    :thousands_separator \".\",\n;;    :iso_numeric \"978\",\n;;    :subunit_to_unit 100,\n;;    :iso_code \"EUR\",\n;;    :decimal_mark \",\",\n;;    :alternate_symbols [],\n;;    :symbol_first 1,\n;;    :smallest_denomination 1,\n;;    :subunit \"Cent\",\n;;    :html_entity \"\u0026#x20AC;\"},\n;;   :MGRS \"32UMC0602156656\",\n;;   :Mercator {:x 849643.007, :y 6757899.137},\n;;   :qibla 128.55,\n;;   :sun\n;;   {:rise\n;;    {:apparent 1578468960,\n;;     :astronomical 1578461580,\n;;     :civil 1578466560,\n;;     :nautical 1578463980},\n;;    :set\n;;    {:apparent 1578497760,\n;;     :astronomical 1578505140,\n;;     :civil 1578500160,\n;;     :nautical 1578502740}},\n;;   :DMS {:lat \"51° 57' 9.57564'' N\", :lng \"7° 37' 56.90280'' E\"},\n;;   :callingcode 49,\n;;   :Maidenhead \"JO31tw58vp\",\n;;   :UN_M49\n;;   {:regions\n;;    {:DE \"276\", :EUROPE \"150\", :WESTERN_EUROPE \"155\", :WORLD \"001\"},\n;;    :statistical_groupings [\"MEDC\"]}},\n;;  :bounds\n;;  {:northeast {:lat 51.9528202, :lng 7.6325938},\n;;   :southwest {:lat 51.9525445, :lng 7.6323594}},\n;;  :components\n;;  {:city_district \"Münster-Mitte\",\n;;   :suburb \"Innenstadtring\",\n;;   :continent \"Europe\",\n;;   :political_union \"European Union\",\n;;   :neighbourhood \"Josef\",\n;;   :house_number \"7\",\n;;   :city \"Münster\",\n;;   :_type \"building\",\n;;   :county \"Münster\",\n;;   :postcode \"48153\",\n;;   :state \"North Rhine-Westphalia\",\n;;   :ISO_3166-1_alpha-3 \"DEU\",\n;;   :country_code \"de\",\n;;   :state_district \"Regierungsbezirk Münster\",\n;;   :ISO_3166-1_alpha-2 \"DE\",\n;;   :country \"Germany\",\n;;   :road \"Friedrich-Ebert-Straße\"},\n;;  :confidence 10,\n;;  :formatted \"Friedrich-Ebert-Straße 7, 48153 Münster, Germany\",\n;;  :geometry {:lat 51.9526599, :lng 7.632473}}\nnil\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgsfak%2Fclj-ocgeo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgsfak%2Fclj-ocgeo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgsfak%2Fclj-ocgeo/lists"}