Pigeon HTTP Client for Unity

Streamline API calls in Unity with Pigeon—built-in auth, better error handling, and a cleaner, more efficient alternative to UnityWebRequest.

When working with REST APIs in Unity, developers often default to using UnityWebRequest. While UnityWebRequest is a capable tool, it can become cumbersome when dealing with modern API integrations, especially those requiring authentication and proper error handling. This is where Pigeon HTTP Client comes in.

Download Pidgeon on our store!

Why Another HTTP Client?

Pigeon was created to address common pain points when working with REST APIs in Unity projects. While UnityWebRequest works well for basic scenarios, it lacks some essential features that modern API integrations require:

  • No built-in authentication flow management

  • Manual JSON serialization/deserialization for each request

  • Verbose error handling code

  • Limited request configuration options

  • No automatic retry mechanisms

Key Features

Authentication Made Simple

Instead of manually managing authentication tokens and refresh flows, Pigeon provides an authentication layer that handles: - Automatic token injection into requests - Token refresh on 401 responses - Global authentication error handling

Fluent API Design

The client uses a builder pattern that makes request configuration clear and concise:


Pigeon.Post("/api/users")
    .SetBody(JsonUtility.ToJson(user))
    .SetSuccessCallback(OnSuccess)
    .SetErrorCallback(OnError)
    .SetTimeout(5)
    .Send

Compare this to the equivalent UnityWebRequest code:


var request = new UnityWebRequest("/api/users", "POST");
request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(JsonUtility.ToJson(user)));
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
await request.SendWebRequest();

if (request.result == UnityWebRequest.Result.Success) {
    OnSuccess(request.downloadHandler.text);
} else if (request.result == UnityWebRequest.Result.ConnectionError) {
    OnError(request.error

Proper Error Handling

Pigeon separates different types of errors and provides specific callbacks:

  • Network errors (connection issues, timeouts)

  • HTTP errors (4xx, 5xx responses)

  • Authentication errors (with automatic handling)

Unity-Optimized

The client is designed specifically for Unity's environment: - Works with Unity's threading model - Proper integration with MonoBehaviour lifecycle - Built-in support for Unity's JsonUtility - Configurable logging for debugging

Getting Started

  1. Initialize the client with your configuration:


Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("Accept", "application/json");
headers.Add("Content-Type", "application/json");

Pigeon.Initialize()
    .SetHostname("https://api.example.com")
    .SetDefaultHeaders(headers)
    .SetDefaultAuthLayer(new YourAuthLayer())
    .Log(RequestLogger.LOG_LEVEL.ALL


  1. Make requests:


csharp
Pigeon.Get("/users")
    .SetSuccessCallback(response => {
        var users = JsonUtility.FromJson<UserList>(response);
        // Handle the response
    })
    .SetErrorCallback(error => {
        Debug.LogError($"Error: {error.GetCode()} - {error.GetMessage()}");
    })
    .Send

When to Use Pigeon

Pigeon is particularly useful when: - Your project involves complex API integrations - You need to handle authentication flows - You want to reduce boilerplate code - You need consistent error handling - You're building a game that heavily relies on backend services

While UnityWebRequest remains a solid choice for simple HTTP operations, Pigeon provides a more developer-friendly approach for modern API integrations in Unity projects.

Download Pidgeon on our store!

Text by:

Pavel Matyas

Published on

Feb 13, 2025

Share this article

augg.io s.r.o. • Světova 523/1, 180 00, Praha 8, Czech Republic • IČ: 173 94 155

©augg.io s.r.o, all rights reserved

This project was implemented with the financial support of the Technology Incubation Programme.

augg.io s.r.o.
Světova 523/1, 180 00,

Praha 8, Czech Republic

IČ: 173 94 155

©augg.io s.r.o, all rights reserved

This project was implemented with the financial support of the Technology Incubation Programme.

augg.io s.r.o. • Světova 523/1, 180 00, Praha 8,
Czech Republic • IČ: 173 94 155

©augg.io s.r.o, all rights reserved

This project was implemented with the financial support of the Technology Incubation Programme.