PHPackages                             wallstreetio/ontraport - 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. wallstreetio/ontraport

ActiveLibrary[API Development](/categories/api)

wallstreetio/ontraport
======================

A PHP package to easily integrate the Ontraport API.

v1.1.0(6y ago)34.6k1[2 issues](https://github.com/wallstreetio/ontraport/issues)1MITPHPPHP &gt;=5.5

Since Mar 6Pushed 6y ago2 watchersCompare

[ Source](https://github.com/wallstreetio/ontraport)[ Packagist](https://packagist.org/packages/wallstreetio/ontraport)[ RSS](/packages/wallstreetio-ontraport/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (3)Versions (7)Used By (1)

Ontraport API
=============

[](#ontraport-api)

[![Build Status](https://camo.githubusercontent.com/0520b6e6841f187f16a8e8ffd14d480d9dcd97d7918347577a83826c25f5a22f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f77616c6c737472656574696f2f6f6e747261706f72742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/wallstreetio/ontraport)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Latest Version](https://camo.githubusercontent.com/228e0741e8503ec0b61f03fe1d6b99d437e25202f3a7f9ecdfb25299e248035f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f77616c6c737472656574696f2f6f6e747261706f72742e7376673f7374796c653d666c61742d737175617265)](https://github.com/wallstreetio/ontraport/releases)

The Ontraport API package, by [WallStreet.io](https://wallstreet.io), is a simple and elegant way to communicate with [Ontraport](https://ontraport.com).

```
$products = $ontraport->products
    ->where('name', 'ONTRAPages')
    ->orWhere('name', 'ONTRAForms')
    ->get();
```

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

[](#installation)

```
composer require wallstreetio/ontraport
```

Configuration
-------------

[](#configuration)

Once you have the package installed, you can start using the API right away.

```
$ontraport = new \Wsio\Ontraport\Ontraport('APP_ID', 'APP_KEY');
```

Usage
-----

[](#usage)

The Ontraport API provides a fluent, query builder syntax that you might be used to from the popular `Eloquent` ORM.

In the examples below we will focus on the Contacts endpoint in Ontraport, but the same syntax can apply to any of the [Ontraport objects](#list-of-provided-ontraport-objects).

#### List Objects

[](#list-objects)

The `get` method will return an array of all of the objects (within Ontraport's limit of 50).

```
$contacts = $ontraport->contacts->get();
```

You may wish to add constraints to the query to retrieve a subset of the objects. For example:

```
$contacts = $ontraport->contacts
    ->where('firstname', 'Bob')
    ->orderBy('id')
    ->get();
```

In the above example, we fetched all the contacts with the firstname, Bob, in ascending order sorted by the `id` field.

For pagination, you can limit the number of results to retrieve as well as the offset to start.

```
$contacts = $ontraport->contacts
    ->range(25)
    ->start(50)
    ->get();
```

The above examples will grab 25 contacts offset by the first 50 contacts.

#### Find Object

[](#find-object)

In addition to retrieving all of the objects, you may also retrieve single objects using `find` and `first`. Instead of an array of objects, these methods return a single object:

```
$contact = $ontraport->contacts->find(1);
```

Like the `get` method, we can stack the `first` method with constraints as well.

```
$contact = $ontraport->contacts->where('email', 'dev@wallstreet.io')->first();
```

The `contact` variable that is returned is an instance of `\Wsio\Ontraport\Fluent` which allows us to treat the Ontraport response as an object.

```
echo $contact->email; // dev@wallstreet.io
```

#### Create Object

[](#create-object)

```
$contact = $ontraport->contacts->create([
    'email' => 'dev@wallstreet.io'
]);
```

You may also come across situations where you want to update an existing record or create a new record if none exists. The Ontraport API provides a `saveOrUpdate` method to allow for this.

```
$contact = $ontraport->contacts->saveOrUpdate([
    'firstname' => 'Tamer',
    'email' => 'dev@wallstreet.io'
]);
```

#### Update Object

[](#update-object)

```
$ontraport->contacts->update(1, [
    'email' => 'tamer@wallstreet.io'
]);
```

If we have already retrieved an object, we can change the attributes of the object using the `Fluent` interface. When we are ready to save the changes we can call the `save` method. For example:

```
$contact = $ontraport->contacts->find(1);

$contact->lastname = 'Rules';

$contact->save();
```

#### Delete Object

[](#delete-object)

```
$ontraport->contacts->delete(1);
```

Similary, if we have previously retrieved the object, we can utilize the `delete` method to remove the object in Ontraport.

```
$contact = $ontraport->contacts->find(1);

$contact->delete();
```

#### Delete Many Objects

[](#delete-many-objects)

```
$ontraport->contacts->delete() // uh-oh :)

$ontraport->contacts->where('email', 'tamer@wallstreet.io')->delete();
```

Examples
--------

[](#examples)

Fetch all contacts where the lastname attribute is empty.

```
$ontraport->contacts->where('lastname', null)->get();

// OR

$ontraport->contacts->whereNull('lastname')->get();
```

Fetch all the products with the names: ONTRAPages and ONTRAForms.

```
$ontraport->products->whereIn('name', ['ONTRAPages', 'ONTRAForms'])->get();
```

Fetch all contacts in descending order.

```
$ontraport->contacts->orderBy('id', 'desc')->get();

$ontraport->contacts->orderByDesc('id')->get();
```

The Ontraport API allows you to stack these methods on top of each other, for example:

```
$ontraport->contacts
    ->whereNull('firstame')
    ->where('email', 'dev@wallstreet.io')
    ->orderByDesc('id')
    ->get();
```

In the above example, we grabbed all the `active` contacts without a `firstname` attribute in descending order.

List of Provided Ontraport Objects
----------------------------------

[](#list-of-provided-ontraport-objects)

For the full list of objects that Ontraport provides and better documentation for each of the endpoints, please refer to the [Ontraport Documentation](http://api.ontraport.com/doc/#/).

- Contacts
- Tasks
- Staff
- Sequences
- Rules
- Messages
- Subscribers
- Notes
- Blasts
- Tags
- Products
- Purchases
- Fulfillments
- LandingPages
- CustomObjects

Each of these objects can be called directly on the Ontraport instance.

```
$sequences = $ontraport->sequences->get();

$purchase = $ontraport->purchases->find(1);
```

Extension
---------

[](#extension)

In attempt to mimic Ontraport's dynamic nature, internally all Ontraport endpoints are treated as if they were the same. If an endpoint does not exist or requires a different structure, extending/overriding is a breeze.

Let's say we have a `tasks` objects but it doesn't have the `assign` endpoint we need. We can extend the `ontraport` instance to allow for it.

First we will create a new `Task` class that extends the `Resource` class.

```
class Task extends \Wsio\Ontraport\Resources\Resource
{
    protected $namespace = 'Task';

    public function assign(array $data = [])
    {
        return $this->ontraport->post('task/assign', $data);
    }
}
```

Then we call the extend method on an our `ontraport` instance.

```
$ontraport->extend('tasks', Task::class);
```

The endpoint can now be accessed through the `ontraport` instance and `tasks` object.

```
$ontraport->tasks->assign([
    'message_id' => 1,
    'due_date' => 'now'
]);
```

Likewise, this approach can be used for objects that this package does not offer in the list [above](#list-of-provided-ontraport-objects).

In most cases this can be a little much especially for one-off requests. The Ontraport instance provides `get`, `post`, `put`, and `delete` helper methods that you can utilize instead.

```
$task = $ontraport->post('task/assign', [
    'message_id' => 1,
    'due_date' => 'now'
]);
```

Documentation
=============

[](#documentation)

- [Ontraport Documentation](http://api.ontraport.com/doc/#/)

Tests
=====

[](#tests)

To run the testsuite, you will need to clone this repository and install the dev requirements.

```
git clone https://github.com/wallstreetio/ontraport.git ontraport
cd ontraport
composer install --dev
```

Then you can run the unit tests

```
phpunit
```

If you want to run the full test suite, you will need to edit your `phpunit.xml` file with the proper `ONTRAPORT_APP_ID` and `ONTRAPORT_API_KEY`.

> *Note: The full testsuite will run tests that will add, change, and delete contacts.* **Make sure you are using a testing account.**

License
=======

[](#license)

WallStreet.io Ontraport API is open-sourced software licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 90.5% 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 ~199 days

Recently: every ~249 days

Total

6

Last Release

2355d ago

Major Versions

v0.1.0 → 1.0.x-dev2017-08-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/c589aef00e9b0686d551813f56fc3fc118c301f60769bcaa397d16058051247e?d=identicon)[wallstreetio](/maintainers/wallstreetio)

---

Top Contributors

[![tamerashkar](https://avatars.githubusercontent.com/u/8474125?v=4)](https://github.com/tamerashkar "tamerashkar (19 commits)")[![wallstreetio](https://avatars.githubusercontent.com/u/22944693?v=4)](https://github.com/wallstreetio "wallstreetio (2 commits)")

---

Tags

apiontraportphpphpapiontraportoap

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/wallstreetio-ontraport/health.svg)

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

###  Alternatives

[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)

PHPackages © 2026

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