RESTful APIs Tutorial: Creating Your Own Lightweight REST Library in Swift

Updated on September 25th, 2019

⏱ Reading Time: < 1 min

Most applications nowadays communicate with servers to exchange data, and they do so by consuming RESTful APIs, also called RESTful web services. Using REST, applications can send requests to servers, and servers send responses as answers back to client apps. The whole communication is based on standard rules that REST architectural style defines. Obviously, developers are meant to be able to use RESTful APIs either by integrating third-party libraries to their projects, or by implementing their own solution to achieve that.

In this tutorial I am going to show you how to build your own lightweight class to perform web requests. I’ll take you from the beginning and step by step we’ll create together a complete solution which will offer a neat and simple to use API to prepare and make requests.

Some basic knowledge about web services, REST and its various concepts is required in the upcoming parts of this post. If you are not confident with this topic, maybe you would like to take a look at wikipedia or this article that explains a lot of things. Before you proceed, make sure you understand what a HTTP message is, as well as the meaning of the following terms:

  • HTTP method
  • Request & Response HTTP headers
  • URL query parameters
  • HTTP body

By the end of this post you will have a class fully capable of making web requests and exchanging data with any server!

→ Keep Reading at AppCoda

Stay Up To Date

Subscribe to my newsletter and get notifiied instantly when I post something new on

    We respect your privacy. Unsubscribe at any time.