{"id":18799157,"url":"https://github.com/marcoeidinger/npsapi-swift","last_synced_at":"2026-01-02T15:30:14.028Z","repository":{"id":108327189,"uuid":"234389992","full_name":"MarcoEidinger/npsapi-swift","owner":"MarcoEidinger","description":"Swift library for the US National Park Service application program interface (NPS API)","archived":false,"fork":false,"pushed_at":"2020-04-29T14:28:24.000Z","size":2006,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-29T18:32:15.462Z","etag":null,"topics":["national-park-service-api","nps-api","swift","swift-library"],"latest_commit_sha":null,"homepage":null,"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/MarcoEidinger.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-01-16T18:58:07.000Z","updated_at":"2020-04-29T14:28:26.000Z","dependencies_parsed_at":"2023-03-11T21:15:45.480Z","dependency_job_id":null,"html_url":"https://github.com/MarcoEidinger/npsapi-swift","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoEidinger%2Fnpsapi-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoEidinger%2Fnpsapi-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoEidinger%2Fnpsapi-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcoEidinger%2Fnpsapi-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcoEidinger","download_url":"https://codeload.github.com/MarcoEidinger/npsapi-swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239727281,"owners_count":19687144,"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":["national-park-service-api","nps-api","swift","swift-library"],"created_at":"2024-11-07T22:14:14.829Z","updated_at":"2026-01-02T15:30:13.968Z","avatar_url":"https://github.com/MarcoEidinger.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NatParkSwiftKit\n\n[![Swift Package Manager Compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n[![Build Status](https://travis-ci.com/MarcoEidinger/npsapi-swift.svg?branch=master)](https://travis-ci.com/MarcoEidinger/npsapi-swift)\n[![](https://img.shields.io/badge/Protected_by-Hound-a873d1.svg)](https://houndci.com)\n[![codebeat badge](https://codebeat.co/badges/9694c6d7-c09f-4b9d-9a58-10ce2783cb69)](https://codebeat.co/projects/github-com-marcoeidinger-npsapi-swift-master)\n[![codecov.io](https://codecov.io/gh/MarcoEidinger/npsapi-swift/branch/master/graphs/badge.svg)](https://codecov.io/gh/MarcoEidinger/npsapi-swift/branch/master)\n[![documentation](https://raw.githubusercontent.com/MarcoEidinger/npsapi-swift/master/docs/badge.svg?sanitize=true)](https://marcoeidinger.github.io/npsapi-swift/)\n\nSwift library for the US National Park Service application program interface (NPS API). The API provides information about parks / monuments / historical sites throughout the US.\n\nThe required API key can be requested for free from [NPS Developer website](https://www.nps.gov/subjects/developer/get-started.htm)\n\n## Installation\n\n## Swift Package Manager\n\nIf you encounter any problem or have a question on adding package to an Xcode project, I suggest the [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) guide article from Apple.\n\n## Carthage\n\nAdd the following to your **Cartfile**.\n\n```\ngithub \"MarcoEidinger/npsapi-swift\" \"master\"\n```\n\n## Usage\n\nExample to fetch information for a single park\n\n```swift\nimport NatParkSwiftKit\n\nlet api = DataService(apiKey: \"your-secret-API-key\")\nlet cancellablePipeline = api.fetchParks()\n\t.replaceError(with: nil)\n    .sink { (park) in\n\t\tguard let park = park else { return }\n\t\tprint(\"Park \\(park.parkCode) is a \\(park.designation)\")\n    }\n```\n\nParks and other entities of the National Park Service Data API can be fetched in bulks. The result type is a tuple containing\n1) the data and\n2) total count (of items matching your query)\n\n```swift\nimport NatParkSwiftKit\n\nlet api = DataService(apiKey: \"your-secret-API-key\")\nlet cancellablePipeline = api.fetchParks()\n    .sink(receiveCompletion: { _ in\n        print(\"Park request completed (either failed or was successful)\")\n    }, receiveValue: { (results) in\n\t\tlet (parks, allParksCount) = results\n        parks.forEach {\n            print(\"Park \\($0.parkCode) is a \\($0.designation)\")\n        }\n    }\n)\n```\n\nAs a default, the result set is limited to 50 records. Hence, in the previous example, the following is true\n\n```swift\n// parks.count == 50\n// allParksCount \u003e= 497\n```\n\nThe limit can be decreased or increased by setting **limit** in [`RequestOptions`](https://marcoeidinger.github.io/npsapi-swift/Structs/RequestOptions.html)\n\nBelow is a more complex search\n\n```swift\nimport NatParkSwiftKit\n\nlet api = DataService(apiKey: \"your-secret-API-key\")\nlet publisher = api.fetchParks(by: nil, in: [.california], RequestOptions.init(limit: 5, searchQuery: \"Yosemite National Park\", fields: [.images, .entranceFees, .entrancePasses]))\n\nlet subscription = publisher\n    .sink(receiveCompletion:\n        { (completion) in\n            switch completion {\n            case .finished:\n                print(\"Finished successfully\")\n            case .failure(let error):\n                print(error)\n            }\n    }\n    ) { (results) in\n\t\tlet (parks, _) = results\n        print(parks.count) // 1\n}\n```\n\nAnalog to the HTTP API it is possible to use pagination by specifying **start** in conjunction with **limit** of `RequestOptions`. \nHowever, I discourage to use it as the NPS server implementation seems to be unreliable  \n\nComplete client-side API documentation is available [here](https://marcoeidinger.github.io/npsapi-swift/)\n\n## Supported Types\n\n* Parks\n* Alerts\n* NewsReleases\n* VisitorCenters\n* Places (a.k.a Assets)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoeidinger%2Fnpsapi-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoeidinger%2Fnpsapi-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoeidinger%2Fnpsapi-swift/lists"}