GloablFishWatch is an open source APIClient with ergonomic swift bindings around the globalfishingwatch.org API.
More info: https://globalfishingwatch.org/our-apis/documentation#get-all-events-post-endpoint
To use use Gloabl Fish Watch simply add it to your project as a SPM module.
The GloablFishWatch codebase supports iOS and requires Xcode 10.0 or newer. The CareKit framework has a Base SDK version of 11.0 and supprts accessing the API data with a handler. It also provides methods Combine's async/await architecture.
The Package contains a demo called FishDemo. To run the demo generate an API Key from Global Fish Watch and replce let apiKey = "UPDATE ME"
with your API key then build and run.
GloablFishWatch can be installed via SPM. Create a new Xcode project and navigate to File > Swift Packages > Add Package Dependency
. Enter the url https://github.com/mmroz/GloablFishWatch
and tap Next
. Choose the main
branch, and on the next screen, check off the packages as needed.
https://globalfishingwatch.org/our-apis/documentation#get-one-by-event-id
UIKit:
public func event(id: String, dataset: EventsApiDataSet, completion: @escaping ((Result<Event, GlobalFishWatchError>) -> Void))
Async:
public func event(id: String, dataset: EventsApiDataSet) async -> Result<Event, GlobalFishWatchError>
https://globalfishingwatch.org/our-apis/documentation#get-all-events-post-endpoint
UIKit:
public func allEvents(limit: Int, offset: Int, sort: EventSort?, datasets: Set<EventsApiDataSet>, vessels: [String]?, types: Set<EventType>?, endDate: Date?, startDate: Date?, confidences: [Int]?, encounterTypes: Set<EventEncounterType>?, completion: @escaping ((Result<EventListResponse, GlobalFishWatchError>) -> Void))
Async:
public func allEvents(limit: Int, offset: Int, sort: EventSort?, datasets: Set<EventsApiDataSet>, vessels: [String]?, types: Set<EventType>?, endDate: Date?, startDate: Date?, confidences: [Int]?, encounterTypes: Set<EventEncounterType>?) async -> Result<EventListResponse, GlobalFishWatchError>
https://globalfishingwatch.org/our-apis/documentation#basic-search
UIKit:
public func vesselSearch(limit: Int, offset: Int, datasets: Set<VesselApiDataSet>, query: String, suggestFields: [String]?, queryFields: [String]?, completion: @escaping ((Result<VesselSearchResponse, GlobalFishWatchError>) -> Void))
Async:
public func vesselSearch(limit: Int, offset: Int, datasets: Set<VesselApiDataSet>, query: String, suggestFields: [String]?, queryFields: [String]?) async -> Result<VesselSearchResponse, GlobalFishWatchError>
https://globalfishingwatch.org/our-apis/documentation#advanced-search
UIKit:
public func vesselAdvancedSearch(limit: Int, offset: Int, datasets: Set<VesselApiDataSet>, query: String, completion: @escaping ((Result<VesselSearchResponse, GlobalFishWatchError>) -> Void))
Async:
public func vesselAdvancedSearch(limit: Int, offset: Int, datasets: Set<VesselApiDataSet>, query: String) async -> Result<VesselSearchResponse, GlobalFishWatchError>
https://globalfishingwatch.org/our-apis/documentation#advanced-search
UIKit:
public func vesselAdvancedSearch(limit: Int, offset: Int, datasets: Set<VesselApiDataSet>, query: String, completion: @escaping ((Result<VesselSearchResponse, GlobalFishWatchError>) -> Void))
Async:
public func vesselAdvancedSearch(limit: Int, offset: Int, datasets: Set<VesselApiDataSet>, query: String) async -> Result<VesselSearchResponse, GlobalFishWatchError>
https://globalfishingwatch.org/our-apis/documentation#get-vessel-by-id
UIKit:
func vessel(id: String, dataset: VesselApiDataSet, completion: @escaping ((Result<Vessel, GlobalFishWatchError>) -> Void))
Async:
public func vessel(id: String, dataset: VesselApiDataSet) async -> Result<Vessel, GlobalFishWatchError>
https://globalfishingwatch.org/our-apis/documentation#get-list-of-vessels-filtered-by-ids
UIKit:
public func vessels(ids: [String], datasets: Set<VesselApiDataSet>, completion: @escaping ((Result<VesselSearchResponse, GlobalFishWatchError>) -> Void))
Async:
public func vessels(ids: [String], datasets: Set<VesselApiDataSet>) async -> Result<Vessel, GlobalFishWatchError>
GitHub is our primary forum for GloablFishWatch. Feel free to open up issues about questions, problems, or ideas.