Skip to content

Getting Started with HTTP

HTTP (vapor/http) is a non-blocking, event-driven HTTP library built on SwiftNIO. It makes working with SwiftNIO's HTTP handlers easy and offers higher-level functionality like media types, client upgrading, streaming bodies, and more. Creating an HTTP echo server takes just a few lines of code.


If you use Vapor, most of HTTP's APIs will be wrapped by more convenient methods. Usually the only HTTP type you will interact with is the http property of Request or Response.


This package is included with Vapor and exported by default. You will have access to all HTTP APIs when you import Vapor.

import Vapor


The HTTP package is lightweight, pure Swift, and only depends on SwiftNIO. This means it can be used as an HTTP framework in any Swift project—even one not using Vapor.

To include it in your package, add the following to your Package.swift file.

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "Project",
    dependencies: [
        .package(url: "", from: "3.0.0"),
    targets: [
      .target(name: "Project", dependencies: ["HTTP", ... ])

Use import HTTP to access the APIs.

The rest of this guide will give you an overview of what is available in the HTTP package. As always, feel free to visit the API docs for more in-depth information.