{"repo":"danielsaidi/ApiKit","free":true,"listed":false,"github":"https://github.com/danielsaidi/ApiKit","clone":"git clone https://github.com/danielsaidi/ApiKit.git","description":"Integrate with REST APIs using Swift.","language":"Swift","stars":73,"topics":["api","swift","networking","rest"],"license":"MIT","category":"networking-infra","readme_excerpt":"ApiKit ApiKit is a Swift library that makes it easy to integrate with any REST API and map its response data to Swift types. ApiKit defines an ApiClient protocol that can be used to request raw & typed data from any REST API, as well as ApiEnvironment and ApiRoute protocols that make it easy to model environments and routes The ApiClient protocol is already implemented by URLSession , so you can use URLSession.shared directly. The protocol can be used to get an abstract reference to the session, or to mock a client in unit tests. Installation ApiKit can be installed with the Swift Package Manager: Getting Started Consider that you want to integrate with the Yelp API, which can return restaurants, reviews, etc. You would first define the various API environments that you want to integrate with. In this case, let's just integrate with the v3 environment, which requires an API header token for all requests: We can then define the routes to request from the Yelp API. In this case, let's just fetch a business by unique ID: With an environment and route in place, we can now fetch a YelpBusiness with any ApiClient or URLSession : If you make this call in a function that defines the return type, you don't even have to define the type: The request will automatically map the raw response to the requested type, and throw any error that occurs. There are also non-generic variants if you want to get the raw data, or use custom error handling. See the online [getting started guide][Getting","default_branch":null,"files":null,"tree":[],"storefront":"/r/danielsaidi","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/danielsaidi/ApiKit/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}