A Harvest API wrapper for Laravel
Clone or download
Latest commit dd7389a Jun 11, 2018


A Laravel wrapper for the Harvest API

Software License Travis StyleCI Total Downloads

A small wrapper for the harvest API which aims to make your life more easier.

Currently it is only possible to receive data from harvest with this package but not to create content.


Laravel Version 5.6+

composer require byte5digital/laravel-harvest

Laravel Version 5.5

composer require byte5digital/laravel-harvest:2.0

If you want to store harvest data into your database, set the uses_database in the harvest config to true and publish the migrations:

php artisan vendor:publish --provider="Byte5\LaravelHarvest\LaravelHarvestServiceProvider"

If you only want to publish the config file add: --tag="config"


You can use either the Harvest Facade or resolve the ApiManager out of the ioc container.

// resolve out of ioc container
$harvest = app()->make('harvest');

Getting Data

Every Api call looks like this:


You can either grab the results with get() or find($id)

// getting all clients

// getting a client with id of 12345

// getting all expenses

// getting an expense with id of 12345

//... you get the idea

There are some cases which have different methods, because they rely on other objects.

// get all user_assignments with the project id of 12345

// get an user_assignments with the id of 12345 which belongs to the project id of 4567

// get all estimate messages with the estimate id of 12345

// get an estimate messages with the id of 12345 which belongs to the estimate id of 4567

List of exceptions:

  • EstimateMessage
  • InvoiceMessage
  • InvoicePayment
  • ProjectAssignment
  • TaskAssignment
  • UserAssignment

Handling Responses

Api responses can be either converted into json, a collection or a paginated collection which is basically json combined with collection.

// receiving some response
$respose = Harvest::users()->get();

// convert result to json

// convert result to collection

// convert result to paginated collection

Handle Pagination

By default harvest gives back a JSON-response with up to 100 records. If you want to limit your results you should use limit(). If you want results from a specific page just pipe fromPage() before find or get.

// get results from page 10

// limit result entries to 50

// limit result entries and get results from page 10

If your harvest entries exceeds 100 records and you just want to get the results from the next or previous page, you may call next() on the result to get to the next 100 results.

// get next result page
$result = $result->next();

// get previous result page
$result = $result->previous();

Additional Params

Adding additional params to your requests is also possible. Not every param is supported yet

supported params:

  • is_active => active()

Some Api Calls allow you to have different params:

    // get all invoices with a state of 'draft'
    // get all invoices with a client_id of '123445'
    // get all invoices with a project_id of '123445'
    // get all invoices which were updated since '2018-01-12'
    // => does also accept other formats like '12.01.2018'
    // get all invoices with an issue_date >= '2018-01-01'
    // get all invoices with an issue_date <= '2018-01-01'

Loading External Relations

When you query the API for any object which has external relations, you might want to checkout the loadExternal() method to get those relations loaded locally.

// loading all external relations of one expense model
// by default if you have enabled `uses_database` in the config
// all external relations are saved to the database.

// load all external relations without saving to db
$expense->loadExternal('*', false);

// load only user and client relations
$expense->loadExternal(['user', 'client']);


  • update/create records
  • improve tests


Run the tests with:



Please see UPGRADING for details.


Please see CHANGELOG for more information what has changed recently.


Please see CONTRIBUTING for details.


If you discover any security-related issues, please email kkoenig@byte5.de instead of using the issue tracker.


The MIT License (MIT). Please see License File for more information.