{"id":30880211,"url":"https://github.com/workingdog/opencageswift","last_synced_at":"2026-04-12T23:41:52.613Z","repository":{"id":309994383,"uuid":"1037162370","full_name":"workingDog/OpenCageSwift","owner":"workingDog","description":"Swift OpenCage API library to retrieve forward and reverse geocoding data","archived":false,"fork":false,"pushed_at":"2025-08-23T23:25:49.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-24T06:35:09.411Z","etag":null,"topics":["opencage","opencagedata","swift","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/workingDog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2025-08-13T06:50:09.000Z","updated_at":"2025-08-23T23:25:53.000Z","dependencies_parsed_at":"2025-08-15T03:36:57.777Z","dependency_job_id":null,"html_url":"https://github.com/workingDog/OpenCageSwift","commit_stats":null,"previous_names":["workingdog/opencageswift"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/workingDog/OpenCageSwift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workingDog%2FOpenCageSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workingDog%2FOpenCageSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workingDog%2FOpenCageSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workingDog%2FOpenCageSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/workingDog","download_url":"https://codeload.github.com/workingDog/OpenCageSwift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workingDog%2FOpenCageSwift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274146706,"owners_count":25230116,"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-09-08T02:00:09.813Z","response_time":121,"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":["opencage","opencagedata","swift","swiftui"],"created_at":"2025-09-08T06:48:48.976Z","updated_at":"2025-10-25T07:52:03.614Z","avatar_url":"https://github.com/workingDog.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCage data API Swift client library, \"Convert coordinates to and from places\"\n\n**OpenCageSwift** is a small Swift library to connect to the [OpenCage](https://opencagedata.com/) server and retrieve the forward and reverse geocoding data.\n          \n**OpenCageSwift** caters for JSON and some support for GeoJSON responses.        \n          \n                                                                    \n### Usage\n\n**OpenCageSwift** is made easy to use with **SwiftUI**. \nIt can be used with the following OS: \n\n- iOS 17.0+\n- iPadOS 17.0+\n- macOS 14.0+\n- Mac Catalyst 17.0+\n\n#### Examples\n\n[OpenCage](https://opencagedata.com/) data can be accessed through the use of a **OCProviderJson**, with simple functions.\n\n```swift\nlet ocProvider = OCProviderJson(apiKey: \"your key\")\n@State private var response: OCResponse = OCResponse()\n...\n\nAlternatively;\n\nlet ocProvider = OCProviderJson(apiKey: \"your key\", urlString: \"https://api.opencagedata.com/geocode/v1\")\n                                                                        \n\n// using a binding\nocProvider.reverseGeocode(lat: latitude, lon: longitude, response: $response, options: OCOptions())\n...\n\n\n// or using the async style, eg with `.task {...}`\nif let results = await ocProvider.reverseGeocode(lat: latitude, lon: longitude, options: OCOptions()) {\n    ....\n}\n\n// or using the callback style, eg with `.onAppear {...}`\nocProvider.reverseGeocode(lat: latitude, lon: longitude, options: OCOptions()) { response in\n       if let theResponse = response {\n           ....\n       }\n}\n```\n\n#### SwiftUI data model\n\nUsing the @Observable data model **OCDataJsonModel**\n\n\n```swift\nimport SwiftUI\nimport MapKit\nimport OpenCageSwift\n\nstruct ContentView: View {\n    let dataModel = OCDataJsonModel(apiKey: \"YOUR-KEY\")\n\n    var body: some View {\n        VStack {\n            if dataModel.isLoading {\n                ProgressView()\n            }\n            Map {\n                ForEach(dataModel.response.results) { result in\n                    if let coord = result.geometry?.asCoordinate() {\n                        Marker(result.formatted ?? \"\", systemImage: \"globe\", coordinate: coord)\n                    }\n                }\n            }\n            .mapStyle(.standard)\n            .mapControlVisibility(.automatic)\n        }\n        .task {\n            dataModel.isLoading = true\n            await dataModel.forwardGeocode(address: \"Sydney, Australia\", options: OCOptions())\n            dataModel.isLoading = false\n        }\n    }\n  \n}\n```\n\n\nFor bulk parallel processing, use **OCBatchJsonModel** for JSON geocoding in batch mode.\n\n\n### Options\n\nOptions available:\n\n-   see [OpenCage API](https://opencagedata.com/api#optional-params) for all the optional parameters available.\n\n### Installation\n\nInclude the files in the **./Sources/OpenCageSwift** folder into your project or preferably use **Swift Package Manager**.\n\n#### Swift Package Manager (SPM)\n\nCreate a Package.swift file for your project and add a dependency to:\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/workingDog/OpenCageSwift.git\", branch: \"main\")\n]\n```\n\n#### Using Xcode\n\n    Select your project \u003e Swift Packages \u003e Add Package Dependency...\n    https://github.com/workingDog/OpenCageSwift.git\n\nThen in your code:\n\n```swift\nimport OpenCageSwift\n```\n    \n### References\n\n-    [OpenCage Data API](https://opencagedata.com/api)\n\n\n### Requirement\n\nRequires a valid OpenCage key, see:\n\n-    [OpenCage Quick Start](https://opencagedata.com/api#quickstart)\n\n### License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkingdog%2Fopencageswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkingdog%2Fopencageswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkingdog%2Fopencageswift/lists"}