PHPackages                             storygrab/php-sdk - 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. storygrab/php-sdk

ActiveLibrary[API Development](/categories/api)

storygrab/php-sdk
=================

Official PHP SDK for the StoryGrab API – Partner &amp; Mobile APIs

00PHP

Since Jul 9Pushed 1mo agoCompare

[ Source](https://github.com/storygrab/php-sdk)[ Packagist](https://packagist.org/packages/storygrab/php-sdk)[ RSS](/packages/storygrab-php-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

StoryGrab PHP SDK
=================

[](#storygrab-php-sdk)

[![PHP Version](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://php.net)[![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](LICENSE)

Official PHP SDK for the [StoryGrab](https://storygrab.net) API.
Covers both the **Partner API** (for third-party integrations) and the **Mobile API** (for user-facing apps).

---

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

[](#requirements)

RequirementVersionPHP`^8.1`Guzzle`^7.0`---

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

[](#installation)

```
composer require storygrab/php-sdk
```

---

Quick Start
-----------

[](#quick-start)

### Partner API

[](#partner-api)

```
use StoryGrab\StoryGrabClient;

$client = StoryGrabClient::partner(
    apiToken: 'YOUR_PARTNER_API_TOKEN',
    baseUrl:  'https://storygrab.net'  // optional, defaults to this
);

// List all authorized profiles
$profiles = $client->partner()->profiles();
foreach ($profiles as $profile) {
    echo $profile->username . PHP_EOL;
}

// Get a single profile
$profile = $client->partner()->profile('nasa');

// Get paginated posts for a profile
$page = $client->partner()->profilePosts('nasa', perPage: 50);
foreach ($page->data as $post) {
    echo $post->shortcode . ' – ' . $post->caption . PHP_EOL;
}

// Next page
if ($page->hasMorePages()) {
    $nextPage = $client->partner()->profilePosts('nasa', perPage: 50, page: 2);
}

// All posts across every authorized profile
$posts = $client->partner()->posts(perPage: 30, page: 1);

// Latest stories (up to 50)
$stories = $client->partner()->latestStories(limit: 20);

// Create a video embed
$embed = $client->partner()->createVideoEmbed(
    videoUrl:   'https://cdn.example.com/video.mp4',
    expiresIn:  3600  // 1 hour
);
echo $embed->embedUrl; // https://storygrab.net/embed/v/
```

### Mobile API

[](#mobile-api)

```
use StoryGrab\StoryGrabClient;

$client = StoryGrabClient::mobile('https://storygrab.net');

// Authenticate (token is automatically applied to subsequent requests)
$auth = $client->mobile()->login(
    email:      'user@example.com',
    password:   'secret',
    deviceName: 'my-app-v1'
);
echo 'Logged in as: ' . $auth->user->name;

// Register a new account
$auth = $client->mobile()->register(
    name:            'Ada Lovelace',
    email:           'ada@example.com',
    password:        'secure-pass',
    passwordConfirm: 'secure-pass',
    deviceName:      'my-app'
);

// Get the authenticated user's profile
$user = $client->mobile()->user();

// Paginated feed
$feed = $client->mobile()->feed(perPage: 20);
foreach ($feed->data as $post) {
    echo $post->caption . PHP_EOL;
}

// Latest stories
$stories = $client->mobile()->stories(limit: 30);

// Search
$results = $client->mobile()->search('space telescope');
// $results['profiles'] => Profile[]
// $results['posts']    => Post[]

// Bookmarks
$bookmarks = $client->mobile()->bookmarks();

// Toggle bookmark
$status = $client->mobile()->toggleBookmark('post-ulid-here');
// 'added' | 'removed'

// Logout
$client->mobile()->logout();
```

---

Error Handling
--------------

[](#error-handling)

All SDK methods throw typed exceptions on non-2xx responses:

ExceptionHTTP Status`AuthenticationException`401, 403`NotFoundException`404`ValidationException`422`RateLimitException`429`ApiException` (base)all other errors```
use StoryGrab\Exceptions\AuthenticationException;
use StoryGrab\Exceptions\NotFoundException;
use StoryGrab\Exceptions\ValidationException;
use StoryGrab\Exceptions\RateLimitException;
use StoryGrab\Exceptions\ApiException;

try {
    $profile = $client->partner()->profile('unknown-handle');
} catch (NotFoundException $e) {
    echo 'Profile not found: ' . $e->getMessage();
} catch (AuthenticationException $e) {
    echo 'Invalid or expired token.';
} catch (ValidationException $e) {
    // Field-level errors as ['field' => ['error message', ...]]
    print_r($e->getErrors());
} catch (RateLimitException $e) {
    echo 'Slow down! Retry after a moment.';
} catch (ApiException $e) {
    echo 'API error ' . $e->getStatusCode() . ': ' . $e->getMessage();
}
```

---

Data Objects
------------

[](#data-objects)

All responses are returned as **immutable typed DTOs** (PHP 8.1 `readonly` properties):

ClassDescription`Profile`An Instagram profile`Post`An archived Instagram post (with `media: Media[]`)`Story`An archived Instagram story (with `media: Media[]`)`Media`A single media item (image or video) within a post/story`EmbedTemplate`A partner HTML/CSS/JS embed template`VideoEmbed`A generated embed token + URL`AuthResponse`Token + User returned on login/register`User`An authenticated mobile user`PaginatedResponse`Generic paginator wrapper with `data`, `currentPage`, `lastPage`, `total`, etc.---

Advanced Usage
--------------

[](#advanced-usage)

### Paginating through all pages

[](#paginating-through-all-pages)

```
$page    = 1;
$allPosts = [];

do {
    $result   = $client->partner()->posts(perPage: 100, page: $page);
    $allPosts = array_merge($allPosts, $result->data);
    $page++;
} while ($result->hasMorePages());
```

### Fetching everything at once (`per_page=all`)

[](#fetching-everything-at-once-per_pageall)

```
$all = $client->partner()->profilePosts('nasa', perPage: 'all');
```

### Using a custom Guzzle client

[](#using-a-custom-guzzle-client)

```
use GuzzleHttp\Client;
use StoryGrab\StoryGrabClient;

$http   = new Client(['base_uri' => 'https://my-proxy.example.com/api/v1/partner/', 'timeout' => 60]);
$client = StoryGrabClient::withHttpClient($http);
```

### Swapping the token at runtime

[](#swapping-the-token-at-runtime)

```
$client->setToken('new-token-after-rotation');
```

---

Running Tests
-------------

[](#running-tests)

```
composer install
composer test
```

---

License
-------

[](#license)

MIT © StoryGrab

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/151365993?v=4)[Fabian Ternis](/maintainers/fabianternis)[@fabianternis](https://github.com/fabianternis)

---

Top Contributors

[![fabianternis](https://avatars.githubusercontent.com/u/151365993?v=4)](https://github.com/fabianternis "fabianternis (3 commits)")

### Embed Badge

![Health badge](/badges/storygrab-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/storygrab-php-sdk/health.svg)](https://phpackages.com/packages/storygrab-php-sdk)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.5M7](/packages/exsyst-swagger)[lucasdotvin/laravel-soulbscription

A straightforward interface to handle subscriptions and features consumption.

709209.3k](/packages/lucasdotvin-laravel-soulbscription)[pimax/fb-messenger-php

Facebook Messenger Bot PHP API

313188.5k2](/packages/pimax-fb-messenger-php)[commercetools/commercetools-api-reference

6520.5k3](/packages/commercetools-commercetools-api-reference)

PHPackages © 2026

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