PHPackages                             diginedbv/unirest-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. diginedbv/unirest-php

Abandoned → [https://github.com/mashape/unirest-php](/?search=https%3A%2F%2Fgithub.com%2Fmashape%2Funirest-php)Library[HTTP &amp; Networking](/categories/http)

diginedbv/unirest-php
=====================

Unirest PHP

0.99.1(12y ago)0774MITPHPPHP &gt;=5.3.0

Since Feb 12Pushed 12y ago9 watchersCompare

[ Source](https://github.com/diginedbv/unirest-php)[ Packagist](https://packagist.org/packages/diginedbv/unirest-php)[ Docs](https://github.com/diginedbv/unirest-php)[ RSS](/packages/diginedbv-unirest-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

---

\*\*To the community\*\*: At this time Unirest-PHP only support syncronous requests, and I would really love to implement asynchronous support. If you guys have any feedback or ideas please comment on issue [\#23](https://github.com/Mashape/unirest-php/issues/23). ---

Unirest for PHP [![Build Status](https://camo.githubusercontent.com/8757b7b9cc1b5629e42bb2c5ce358113a9e16979bc930b04dde687b501b4be57/68747470733a2f2f6170692e7472617669732d63692e6f72672f4d6173686170652f756e69726573742d7068702e706e67)](https://travis-ci.org/Mashape/unirest-php)
====================================================================================================================================================================================================================================================================================

[](#unirest-for-php-)

Unirest is a set of lightweight HTTP libraries available in multiple languages, ideal for most applications:

- Make `GET`, `POST`, `PUT`, `PATCH`, `DELETE` requests
- It supports form parameters, file uploads and custom body entities
- Supports gzip
- Supports Basic Authentication natively
- Customizable timeout
- Customizable default headers for every request (DRY)
- Automatic JSON parsing into a native object for JSON responses

Created with love by [thefosk](https://github.com/thefosk) @ [mashape.com](https://mashape.com)

### Install with Composer

[](#install-with-composer)

If you're using [Composer](https://github.com/composer/composer) to manage dependencies, you can add Unirest with it.

```
{
  "require" : {
    "mashape/unirest-php" : "dev-master"
  },
  "autoload": {
    "psr-0": {"Unirest": "lib/"}
  }
}
```

### Install source from GitHub

[](#install-source-from-github)

Unirest-PHP requires PHP `v5.3+`. Download the PHP library from Github, and require in your script like so:

To install the source code:

```
$ git clone git@github.com:Mashape/unirest-php.git
```

And include it in your scripts:

```
require_once '/path/to/unirest-php/lib/Unirest.php';
```

Creating Request
----------------

[](#creating-request)

So you're probably wondering how using Unirest makes creating requests in PHP easier, let's look at a working example:

```
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
  array(
    "parameter" => 23,
    "foo" => "bar"
  )
);

$response->code; // HTTP Status code
$response->headers; // Headers
$response->body; // Parsed body
$response->raw_body; // Unparsed body
```

### File Uploads

[](#file-uploads)

To upload files in a multipart form representation use the return value of `Unirest::file($path)` as the value of a parameter:

```
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
  array(
    "file" => Unirest::file("/tmp/file.txt") // Tells Unirest where the file is located
  )
);
```

### Custom Entity Body

[](#custom-entity-body)

Sending a custom body such as a JSON Object rather than a string or form style parameters we utilize json\_encode for the body:

```
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
  json_encode(
    array(
      "parameter" => "value",
      "foo" => "bar"
    )
  )
);
```

### Basic Authentication

[](#basic-authentication)

Authenticating the request with basic authentication can be done by providing the `username` and `password` arguments:

```
$response = Unirest::get("http://httpbin.org/get", null, null, "username", "password");
```

Request
=======

[](#request)

```
Unirest::get($url, $headers = array(), $parameters = NULL, $username = NULL, $password = NULL)
Unirest::post($url, $headers = array(), $body = NULL, $username = NULL, $password = NULL)
Unirest::put($url, $headers = array(), $body = NULL, $username = NULL, $password = NULL)
Unirest::patch($url, $headers = array(), $body = NULL, $username = NULL, $password = NULL)
Unirest::delete($url, $headers = array(), $body = NULL, $username = NULL, $password = NULL)
```

- `url` - Endpoint, address, or uri to be acted upon and requested information from.
- `headers` - Request Headers as associative array or object
- `body` - Request Body as associative array or object
- `username` - Basic Authentication username
- `password` - Basic Authentication password

Response
========

[](#response)

Upon recieving a response Unirest returns the result in the form of an Object, this object should always have the same keys for each language regarding to the response details.

- `code` - HTTP Response Status Code (Example `200`)
- `headers` - HTTP Response Headers
- `body` - Parsed response body where applicable, for example JSON responses are parsed to Objects / Associative Arrays.
- `raw_body` - Un-parsed response body

Advanced Configuration
======================

[](#advanced-configuration)

You can set some advanced configuration to tune Unirest-PHP:

### Timeout

[](#timeout)

You can set a custom timeout value (in **seconds**):

```
Unirest::timeout(5); // 5s timeout
```

### Default Request Headers

[](#default-request-headers)

You can set default headers that will be sent on every request:

```
Unirest::defaultHeader("Header1", "Value1");
Unirest::defaultHeader("Header2", "Value2");
```

You can clear the default headers anytime with:

```
Unirest::clearDefaultHeaders();
```

### SSL validation

[](#ssl-validation)

You can explicitly enable or disable SSL certificate validation when consuming an SSL protected endpoint:

```
Unirest::verifyPeer(false); // Disables SSL cert validation
```

By default is `true`.

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4567d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/78911?v=4)[Bipin Upadhyay](/maintainers/bipinu)[@bipinu](https://github.com/bipinu)

---

Top Contributors

[![subnetmarco](https://avatars.githubusercontent.com/u/964813?v=4)](https://github.com/subnetmarco "subnetmarco (73 commits)")[![esseguin](https://avatars.githubusercontent.com/u/1429412?v=4)](https://github.com/esseguin "esseguin (12 commits)")[![michelezonca](https://avatars.githubusercontent.com/u/392758?v=4)](https://github.com/michelezonca "michelezonca (6 commits)")[![nijikokun](https://avatars.githubusercontent.com/u/198276?v=4)](https://github.com/nijikokun "nijikokun (4 commits)")[![andreyvital](https://avatars.githubusercontent.com/u/967317?v=4)](https://github.com/andreyvital "andreyvital (3 commits)")[![bipinu](https://avatars.githubusercontent.com/u/78911?v=4)](https://github.com/bipinu "bipinu (2 commits)")[![nikkobautista](https://avatars.githubusercontent.com/u/278104?v=4)](https://github.com/nikkobautista "nikkobautista (2 commits)")[![qpleple](https://avatars.githubusercontent.com/u/774546?v=4)](https://github.com/qpleple "qpleple (2 commits)")[![jasir](https://avatars.githubusercontent.com/u/115066?v=4)](https://github.com/jasir "jasir (2 commits)")[![motdotla](https://avatars.githubusercontent.com/u/3848?v=4)](https://github.com/motdotla "motdotla (1 commits)")[![samsullivan](https://avatars.githubusercontent.com/u/3789442?v=4)](https://github.com/samsullivan "samsullivan (1 commits)")[![sonicaghi](https://avatars.githubusercontent.com/u/1213643?v=4)](https://github.com/sonicaghi "sonicaghi (1 commits)")

---

Tags

httpclientrestcurl

### Embed Badge

![Health badge](/badges/diginedbv-unirest-php/health.svg)

```
[![Health](https://phpackages.com/badges/diginedbv-unirest-php/health.svg)](https://phpackages.com/packages/diginedbv-unirest-php)
```

###  Alternatives

[apimatic/unirest-php

Unirest PHP

225.9M168](/packages/apimatic-unirest-php)[zoonman/pixabay-php-api

PixabayClient is a PHP HTTP client library to access Pixabay's API

3456.8k](/packages/zoonman-pixabay-php-api)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11263.3k1](/packages/e-moe-guzzle6-bundle)[openapi/openapi-sdk

Minimal and agnostic PHP SDK for Openapi® (https://openapi.com)

164.6k1](/packages/openapi-openapi-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
