PHPackages                             tunr/slimsurveys-api-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. tunr/slimsurveys-api-php

ActiveLibrary

tunr/slimsurveys-api-php
========================

A REST client for the SlimSurveys API.

v1.0.1(12y ago)011PHPPHP &gt;=5.3.0

Since Sep 2Pushed 12y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

\##SlimSurveys API PHP Client

SlimSurveys is a micro-survey platform to help people improve survey completion and abandonment rates with surveys that can be completed in 30 seconds or less.

This repository contains a PHP client library to interface with the SlimSurveys API.

### API Key

[](#api-key)

First things first, visit the SlimSurveys site to request an API key.

### Installation

[](#installation)

Require the SlimSurveys client in your `composer.json` file.

```
"tunr/slimsurveys-api-php": "1.0.*"

```

Then run `composer install` to get the code and update your autoloader.

### Create the Client

[](#create-the-client)

Now with your trusty API key, create a client instance.

```
$key = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';

$slimClient = new \SlimSurveys\Client($key);

```

API methods can then be called on the client instance.

```
$response = $slimClient->getMySurveys();

```

### Authentication

[](#authentication)

Just passing an API key to the client constructor will only get you so far as most API requests require an authentication token. With your SlimSurveys user account email and password you can request an authentication token like so...

```
$email    = 'lamehandle@somewhere.com';
$password = 'XXXXXXXX';

$response = $slimClient->getAuthToken($email, $password);

$data  = $response->getData();
$token = $data->token;

```

Currently an authentication token doesn't expire so it can be stored and used for multiple requests. Once you have a token, it can be passed to the client through the constructor.

```
$key   = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
$token = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';

$slimClient = new \SlimSurveys\Client($key, $token);

```

You can also use a token setter to pass a token to an existing client if it was not available when the client was created.

```
$slimClient->setToken($token);

```

### Response

[](#response)

The following methods can be used to inspect the response from an API method.

```
$response->getInfo();
$response->getCode();
$response->isCode($expectedCode);

```

Example:

```
$response = $slimClient->getAuthToken($email, $password);

if ($response->isCode(200))
{
    $data  = $response->getData();
    $token = $data->token;
}
else
{
    // things might not be as awesome as you expected
}

```

### Data

[](#data)

The data getter allows you to return a formatted version of the JSON data returned by the SlimSurveys API. Data is returned as an object by default, but can be returned as an associative array by passing `true` to the data getter.

```
$data = $response->getData(true);

$token = $data['token'];

```

### Debugging

[](#debugging)

Since the entire client instance is returned by each API method, a simple `var_dump($response)` will provide some visibility into how an API request is configured.

```
$response = $slimClient->getMySurveys();

var_dump($response);

```

### API Methods

[](#api-methods)

The following API methods are available. They're listed in the same order as the [API documentation](https://slimsurveys.com/developer/docs) so you can easily match up the methods to the official docs.

##### Authentication

[](#authentication-1)

```
getAuthToken($email, $password)

```

##### Answers

[](#answers)

```
getSurveyAnswers($surveyId, $uvid = null)

getSurveyAnswersByUid($surveyUid, $uvid = null)

getQuestionAnswers($questionId)

createQuestionAnswer($questionId, $answer, $milestone = '', $uvid = '')

```

##### Identities

[](#identities)

```
createSurveyIdentity($surveyId, $uvid, $data)

createSurveyIdentityByUid($surveyUid, $uvid, $data)

```

##### Images

[](#images)

```
getImage($imageId)

createQuestionImage($questionId, $file, $position = 0)

deleteImage($imageId)

```

##### Options

[](#options)

```
getOption($optionId)

createQuestionOption($questionId, $value = null, $position = 0)

updateOption($optionId, $value, $position = 0)

deleteOption($optionId)

```

##### Questions

[](#questions)

```
getQuestion($questionId)

createSurveyQuestion($surveyId, $type, $text = '', $position = 0)

createSurveyQuestionByUid($surveyUid, $type, $text = '', $position = 0)

updateQuestion($questionId, $text = '', $position = 0)

deleteQuestion($questionId)

```

##### Results

[](#results)

```
getSurveyResults($surveyId)

getSurveyResultsByUid($surveyUid)

getQuestionResults($questionId)

```

##### Surveys

[](#surveys)

```
getSurvey($surveyId)

getSurveyByUid($surveyUid)

getSurveyEmbed($surveyId)

getSurveyEmbedByUid($surveyUid)

getUserSurveys($userId)

getUserSurveysByUsername($username)

getMySurveys()

createSurvey(
    $name,
    $description = null,
    $refresh     = false,
    $repeat      = false,
    $metadata    = null,
    $callback    = null
)

updateSurvey(
    $surveyId,
    $name,
    $description = null,
    $refresh     = false,
    $repeat      = false,
    $metadata    = null,
    $callback    = null
)

updateSurveyByUid(
    $surveyUid,
    $name,
    $description = null,
    $refresh     = false,
    $repeat      = false,
    $metadata    = null,
    $callback    = null
)

copySurvey($surveyId)

copySurveyByUid($surveyUid)

deleteSurvey($surveyId)

```

##### Users

[](#users)

```
me()

register($email, $password, $notifications = true)

getPasswordResetToken($email)

resetPassword($token, $password, $confirm)

updateSurveyTab($surveyId)

updateSurveyTabByUid($surveyUid)

updateVanityName($name)

updatePrivacy($flag)

updateEmail($email)

updateThanks($facebookUrl = null, $twitterUrl = null, $websiteUrl = null)

updatePassword($password, $confirm)

deleteSurveyTab()

```

### Requirements

[](#requirements)

- PHP 5.3+
- cURL

> Note: A version of PHP &lt; 5.3 will work if class prefixing is used instead of namespacing.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community1

Small or concentrated contributor base

Maturity59

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 ~1 days

Total

2

Last Release

4630d ago

### Community

### Embed Badge

![Health badge](/badges/tunr-slimsurveys-api-php/health.svg)

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

PHPackages © 2026

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