PHPackages                             surveygizmo/surveygizmo-api - 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. surveygizmo/surveygizmo-api

ActiveLibrary[API Development](/categories/api)

surveygizmo/surveygizmo-api
===========================

Official PHP library for SurveyGizmo API

v1.0.4-stable(7y ago)985.0k↓40%9[1 PRs](https://github.com/SurveyGizmoOfficial/PHP_SurveyGizmo_Api/pulls)MITPHP

Since Nov 9Pushed 6y ago5 watchersCompare

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

READMEChangelog (5)DependenciesVersions (7)Used By (0)

Official PHP library for SurveyGizmo API
========================================

[](#official-php-library-for-surveygizmo-api)

[![Latest Stable Version](https://camo.githubusercontent.com/2900fd2f4b60e26b5800199e10e774ab4c3122c4ea527fca843400cfcaa9baed/68747470733a2f2f706f7365722e707567782e6f72672f73757276657967697a6d6f2f73757276657967697a6d6f2d6170692f762f737461626c65)](https://packagist.org/packages/surveygizmo/surveygizmo-api)[![Total Downloads](https://camo.githubusercontent.com/d4f261c849ae93c8da0c44151384b1e54a5ebf2ef2f43d03f4db2af56798ff0e/68747470733a2f2f706f7365722e707567782e6f72672f73757276657967697a6d6f2f73757276657967697a6d6f2d6170692f646f776e6c6f616473)](https://packagist.org/packages/surveygizmo/surveygizmo-api)[![Latest Unstable Version](https://camo.githubusercontent.com/cc9b0fbf73ca6a117edee698025bafc971d3605e6a925b15c96871a7b3b08c54/68747470733a2f2f706f7365722e707567782e6f72672f73757276657967697a6d6f2f73757276657967697a6d6f2d6170692f762f756e737461626c65)](https://packagist.org/packages/surveygizmo/surveygizmo-api)[![License](https://camo.githubusercontent.com/186dd5a9f9c240465bb55315ae050cb628e77031e234d019745cb692bc74c1f8/68747470733a2f2f706f7365722e707567782e6f72672f73757276657967697a6d6f2f73757276657967697a6d6f2d6170692f6c6963656e7365)](https://packagist.org/packages/surveygizmo/surveygizmo-api)[![composer.lock](https://camo.githubusercontent.com/743a0412a2181b2515952257ad756ba8281d78d6da8ac3563100c3c3fa88b093/68747470733a2f2f706f7365722e707567782e6f72672f73757276657967697a6d6f2f73757276657967697a6d6f2d6170692f636f6d706f7365726c6f636b)](https://packagist.org/packages/surveygizmo/surveygizmo-api)

Summary
-------

[](#summary)

The library is intended to make integrating with SurveyGizmo easier and quicker than using the API directly. The following objects are supported via this library and are all namespaced under SurveyGizmo (e.g. \\SurveyGizmo\\Resources\\Survey).

Requirements
------------

[](#requirements)

- PHP 5.3+
- cURL
- Active SurveyGizmo Account

Recommended Installation
------------------------

[](#recommended-installation)

This library is now available in [packagist](https://packagist.org/), and you can include [surveygizmo/surveygizmo-api](https://packagist.org/packages/surveygizmo/surveygizmo-api) in your [composer](https://getcomposer.org/doc/00-intro.md) configuration files to autoload it:

```
$ composer require surveygizmo/surveygizmo-api
Using version ^1.0 for surveygizmo/surveygizmo-api
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing surveygizmo/surveygizmo-api (v1.0.3-stable): Loading from cache
Writing lock file
Generating autoload files
```

Manual Installation
-------------------

[](#manual-installation)

1. Download the library and add it to your project.
2. Include the SurveyGizmoAutoLoader.php file, replacing `` with the appropriate path.

```
require_once "/SurveyGizmoAutoLoader.php";
```

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

[](#configuration)

1. If you are not using our US data center, you will need to choose the appropriate region (US, CA, or EU). If you are not sure if you are using the US, EU, or CA API, see:

```
try {
	\SurveyGizmo\SurveyGizmoAPI::setRegion('EU');
} catch (Exception $e) {
	die('Region not available');
}
```

2. Authenticate using your SurveyGizmo [API Key and Secret](https://apihelp.surveygizmo.com/help/article/link/authentication).

```
try {
	\SurveyGizmo\SurveyGizmoAPI::auth("", "");
} catch (Exception $e) {
	die("Error Authenticating");
}
```

3. If needed, configure [rate limiting](https://apihelp.surveygizmo.com/help/api-request-limits).

```
//set max retries of requests to 10, when request is rate limited it will be retried after 5 seconds.
\SurveyGizmo\ApiRequest::setRepeatRateLimitedRequest(10);
```

4. If needed, configure the request timeout duration (in seconds, defaults to 35 if not specified)

```
//this is the maximum wait period before aborting requests, you may need to
//increase this from the default of 35 seconds if working with oversize surveys
\SurveyGizmo\ApiRequest::setRequestTimeout(60);
```

Code Samples
------------

[](#code-samples)

Please refer to the [Samples folder](https://github.com/SurveyGizmoOfficial/PHP_SurveyGizmo_Api/tree/master/Samples) for more thorough example use cases.

To use these samples, copy the example file and then supply your own credentials:

```
$ cd Samples
$ cp .credentials.example .credentials
$ vi .credentials # then supply your credentials accordingly
$ php new_survey.php # run once prior to running manipulate_survey.php
$ php manipulate_survey.php
```

##### Supported Objects

[](#supported-objects)

- Survey
    - Responses
    - Questions
    - Pages
    - Statistics
    - Reports
    - Campaigns
        - EmailMessages
- Account
    - Users
    - Teams
- Contacts
- ContactLists
    - Contacts

API Object Reference
--------------------

[](#api-object-reference)

This Library uses the version 5 SurveyGizmo API, please refer to our [API Documentation](https://apihelp.surveygizmo.com/help/version-5) for more information.

#### All objects use the following standard functions:

[](#all-objects-use-the-following-standard-functions)

```
::fetch(,);

```

> Returns an array of objects based on filter and paging options.

```
::get($id);

```

> Returns a single object based on id

```
->save();

```

> Saves a newly created or updated instance of an object

```
->delete();

```

> Deletes an instance of an object

### Surveys

[](#surveys)

###### Fetching Surveys

[](#fetching-surveys)

See filter and paging below.

```
$surveys = \SurveyGizmo\Resources\Survey::fetch(,);
```

###### Getting a Single Survey

[](#getting-a-single-survey)

```
$survey_id = ;
$survey = \SurveyGizmo\Resources\Survey::get(survey_id);
```

###### Updating a Survey

[](#updating-a-survey)

```
$survey->title = "TEST UPDATE FROM API LIBRARY";
$survey->save();
```

###### Creating a Survey

[](#creating-a-survey)

```
$survey = new \SurveyGizmo\Resources\Survey();
$survey->title = "NEW SURVEY";
$results = $survey->save();
```

###### Deleting a Survey

[](#deleting-a-survey)

```
$survey = $survey->delete();
```

### Survey Helper Functions

[](#survey-helper-functions)

The Survey object provides a few help functions to easily access related collections and objects.

```
	//get questions
	$survey->getQuestions(,);
	$survey->getQuestion($question_id);
	//get responses
	$survey->getResponses(,);
	$survey->getResponse($id);
	//get reports
	$survey->getReports(,);
	$survey->getReport($id);
	//get statistics
	$survey->getStatistics();
	$survey->getStatisticsByID($question_id);
	//get campaigns
	$survey->getCampaigns();
	$survey->getCampaign($id);
	//get email messages
	$survey->getCampaign($id)->getEmailMessages();
	$survey->getCampaign($id)->getEmailMessage($email_id);
```

### Questions

[](#questions)

To access the questions on a survey you'll need an instance of a \\SurveyGizmo\\Resources\\Survey object.

###### Get all Survey Questions

[](#get-all-survey-questions)

```
$questions = $survey->getQuestions();
```

###### Getting and Updating a Survey Question

[](#getting-and-updating-a-survey-question)

```
$question = $survey->getQuestion();
$question->title->English = "LIBRARY TEST";
$ret = $question->save();
```

### Responses

[](#responses)

To access the responses for a survey you'll need an instance of a \\SurveyGizmo\\Resources\\Survey object. See filter and paging below.

###### Get all Survey Responses

[](#get-all-survey-responses)

```
$responses = $survey->getResponses(,);
```

###### Get a Single Responses

[](#get-a-single-responses)

```
$responses = $survey->getResponse(survey_data[$question_id]['answer'] = 'YES';
$ret = $response->save();
```

#### Filtering &amp; Paging Objects

[](#filtering--paging-objects)

All fetch methods take both optional $filter and $options arguments.

###### Filtering

[](#filtering)

```
$filter = new \SurveyGizmo\Helpers\Filter();
$filter_item = new \SurveyGizmo\Helpers\FilterItem();
$filter_item->setField('title');
$filter_item->setOperator('=');
$filter_item->setCondition('TEST from API');
$filter->addFilterItem($filter_item);
$surveys = \SurveyGizmo\Resources\Survey::fetch($filter);
```

###### Paging Collections

[](#paging-collections)

Sometimes you will need to page through collections of objects. To accommodate this use the optional $options argument on any fetch method;

```
$options = array( 'page' => 3, 'limit' => 100 );
$surveys = \SurveyGizmo\Resources\Survey::fetch($filter,$options);
```

### Error Messages &amp; Responses

[](#error-messages--responses)

In the case of an error we will return the following responses and status codes:

```
Method not implemented (404)
Method not supported (405)
Not Authorized (401)

```

### Simple API request

[](#simple-api-request)

To perform a API call without going through a specific resource class, use \\SurveyGizmo\\ApiRequest::call.

```
$response = \SurveyGizmo\ApiRequest::call('contactlist', null, null, null);
```

Tests
-----

[](#tests)

Unit tests are included under the `/Tests` directory. They can be run by calling PHPUnit within the Tests folder:

```
$ phpunit
```

Contributors
------------

[](#contributors)

The library was developed and is maintained by the [SurveyGizmo](http://www.surveygizmo.com) Development Team.

License
-------

[](#license)

This project is licensed under the terms of the MIT license.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 87% 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 ~131 days

Total

5

Last Release

2587d ago

### Community

Maintainers

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

---

Top Contributors

[![SurveyGizmoOfficial](https://avatars.githubusercontent.com/u/19310598?v=4)](https://github.com/SurveyGizmoOfficial "SurveyGizmoOfficial (140 commits)")[![wvdongen](https://avatars.githubusercontent.com/u/1862615?v=4)](https://github.com/wvdongen "wvdongen (17 commits)")[![burnhamrobertp](https://avatars.githubusercontent.com/u/231052?v=4)](https://github.com/burnhamrobertp "burnhamrobertp (2 commits)")[![amcastror](https://avatars.githubusercontent.com/u/3622318?v=4)](https://github.com/amcastror "amcastror (1 commits)")[![gonzie](https://avatars.githubusercontent.com/u/17484372?v=4)](https://github.com/gonzie "gonzie (1 commits)")

### Embed Badge

![Health badge](/badges/surveygizmo-surveygizmo-api/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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