PHPackages                             samrap/gemini - 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. [API Development](/categories/api)
4. /
5. samrap/gemini

ActiveLibrary[API Development](/categories/api)

samrap/gemini
=============

A Gemini API client for PHP developers.

v0.1.1(8y ago)55281[1 PRs](https://github.com/samrap/gemini/pulls)MITPHPPHP &gt;=7.0

Since Feb 23Pushed 5y agoCompare

[ Source](https://github.com/samrap/gemini)[ Packagist](https://packagist.org/packages/samrap/gemini)[ RSS](/packages/samrap-gemini/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (4)Used By (0)

[![](https://camo.githubusercontent.com/da234b06658339e20d8422ffc6cc379e2c97a9c3270dcbb1e656775ea7ff9436/68747470733a2f2f692e696d6775722e636f6d2f6839784b426b512e706e67)](https://camo.githubusercontent.com/da234b06658339e20d8422ffc6cc379e2c97a9c3270dcbb1e656775ea7ff9436/68747470733a2f2f692e696d6775722e636f6d2f6839784b426b512e706e67)

 [![Build Status](https://camo.githubusercontent.com/4dd92768920d235bd219c03067f18062ab0bf430afce010c3f94ecade082fc4e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f73616d7261702f67656d696e692e7376673f7374796c653d666c61742d737175617265)](https://github.com/samrap/gemini)

---

**Note:** This is currently in early development and not yet ready for production purposes.

---

This is a PHP client implementation for the [Gemini](https://gemini.com/) digital asset exchange REST API. It is built on expressive contracts that mirror the available public and private API methods, with a decoupled HTTP implementation for the underlying requests. If you are looking to interact with the Gemini API without worrying about the underlying HTTP requests and responses, then this package is for you.

Installation
------------

[](#installation)

In order to talk to the API, you will need to install a compatible HTTP client or adapter. This package utilizes HTTPlug which defines how HTTP messages should be sent and received. You can use any library to send HTTP messages that implements [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation).

Here is a list of all officially supported clients and adapters by HTTPlug:

Read more about HTTPlug in [their docs](http://docs.php-http.org/en/latest/httplug/users.html).

---

**Note:** The [Guzzle6 Adapter](http://docs.php-http.org/en/latest/clients/guzzle6-adapter.html) will be used in the following examples.

---

Once you have chosen your HTTP implementation, go ahead and install it with this package:

```
composer require php-http/guzzle6-adapter samrap/gemini

```

That's all you have to do to get started. The client will automatically find your chosen HTTP implementation under the hood, so you can focus on the fun stuff!

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

In order to talk to the API, you will need to create an instance of the `Samrap\Gemini\Gemini` class. This class implements the API contracts necessary for you to do everything the REST API has to offer.

The class takes two arguments, a `key` and `secret`, which are your API key and secret, respectively. Of course, if you only plan on using the [Public APIs](https://docs.gemini.com/rest-api/#symbols), you may ignore these arguments:

```
use Samrap\Gemini\Gemini;

$key = 'mykey';
$secret = '1234abcd'
$gemini = new Gemini($key, $secret);
```

The Gemini client's methods map directly to the available APIs in the documentation. For example, if you want to get data from the [Symbols API](https://docs.gemini.com/rest-api/#symbols), simply call the `symbols` method on the Gemini client:

```
$gemini = new Gemini();
$symbols = $gemini->symbols();

print_r($symbols); // ["btc-usd", "ethbtc", "ethusd"]
```

The return value of all API calls is the HTTP response's decoded JSON as an associative array. The Gemini client handles all the HTTP requests and responses, allowing you to focus on the data that matters most.

APIs with more than one word, such as [Current Order Book](https://docs.gemini.com/rest-api/#current-order-book), are called as *camelCase* versions of themselves. Parameters in the URI scheme are passed as individual arguments, while URL (GET) parameters are given as an associative array. Let's take a look at what it would look like to access the public **Current Order Book** API:

```
$gemini = new Gemini();
$symbol = 'ethusd';
$orderBook = $gemini->currentOrderBook($symbol, [
    'limit_bids' => 10,
    'limit_asks' => 10,
]);
```

As with all methods, the return value will be the decoded JSON from the response body. Optional URL parameters can be ignored. Since the `limit_bids` and `limit_asks` parameters are optional, we could just as easily write the following:

```
$gemini = new Gemini();
$symbol = 'ethusd';
$orderBook = $gemini->currentOrderBook($symbol);
```

Piece of cake!

### Private APIs

[](#private-apis)

The Gemini client automatically handles authentication and request signing for you. This means that accessing the Private APIs (APIs that require a session) is just as easy as talking to the public ones. Let's place a [new buy order](https://docs.gemini.com/rest-api/#new-order):

```
$gemini = new Gemini('mykey', '1234abcd');
$order = $gemini->newOrder([
    'client_order_id' => '20150102-4738721',
    'symbol' => 'btcusd',
    'amount' => '34.12',
    'price' => '622.13',
    'side' => 'buy',
    'type' => 'exchange limit',
    'options' => ['maker-or-cancel'],
]);
```

That's it! If the request was successful, the value of `$order` will be an associative array of the response JSON. If an error occurred, the Gemini Client throws an exception representing the exact error. See [Error Handling](#error-handling) for more information.

### API Reference

[](#api-reference)

The Gemini client implements two contracts, `Samrap\Gemini\PublicApi` and `Samrap\Gemini\PrivateApi`. These contracts contain the API methods and their parameters, should you need a reference.

### Error Handling

[](#error-handling)

The Gemini client automatically converts all API errors into exceptions named after the **reason** in each [Error Payload](https://docs.gemini.com/rest-api/#error-payload). An `AuctionNotOpen` error will throw a `Samrap\Gemini\Exceptions\AuctionNotOpenException`, a `ClientOrderIdTooLong` will throw a `Samrap\Gemini\Exceptions\ClientOrderIdTooLongException`, etc. Every exception extends the `Samrap\Gemini\Exceptions\GeminiException`. This gives you great flexibility to handle specific errors you might expect, while adding a catch-all at the end.

Imagine we are writing a method to allow users to check the status of their orders. A lot can go wrong. A user might enter the incorrect order ID, so we will need to account for that. Additionally, the API might be down for maintenance and we certainly would want to log that information. Just to be safe, we should log any other error that *could* occur. Ok, let's write it:

```
use Samrap\Gemini\Exceptions\GeminiException;
use Samrap\Gemini\Exceptions\MaintenanceException;
use Samrap\Gemini\Exceptions\OrderNotFoundException;

// ...

public function getOrderStatus($order_id)
{
    try {
        $status = $this->gemini->orderStatus([
            'order_id' => $order_id,
        ])
    } catch (OrderNotFoundException $e) {
        return 'The order you searched for does not exist.';
    } catch (MaintenanceException $e) {
        $this->logger->critical($e->getMessage());

        return 'The API is currently unavailable';
    } catch (GeminiException $e) {
        $this->logger->warn($e->getMessage())
    }

    return $status['original_amount'];
}
```

As you can see, this is much more expressive than dealing with response status codes or checking the error payload to figure out what to do next. The Gemini client handles all of this for you, allowing you to focus on the requirements of your application.

More
----

[](#more)

More documentation is coming as development continues.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

3006d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/78e66e2a9fc45b509f43164b07af8521a71941b081abfbbaec6597bd6d4f4a21?d=identicon)[samrap](/maintainers/samrap)

---

Tags

bitcoincryptocurrencyethereumgeminigemini-apiapiclientbitcoincryptocurrencyGeminiethereum

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samrap-gemini/health.svg)

```
[![Health](https://phpackages.com/badges/samrap-gemini/health.svg)](https://phpackages.com/packages/samrap-gemini)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)[coinpaymentsnet/coinpayments-php

A PHP wrapper for the CoinPayments.net v1 API.

55126.2k](/packages/coinpaymentsnet-coinpayments-php)[apigee/apigee-client-php

Client library for connecting to the Apigee Edge API.

27558.7k3](/packages/apigee-apigee-client-php)[swader/diffbot-php-client

A PHP wrapper for using Diffbot's API

5328.5k](/packages/swader-diffbot-php-client)[dhope0000/lxd

PHP-based API wrapper for LXD REST API.

136.2k](/packages/dhope0000-lxd)

PHPackages © 2026

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