PHPackages                             aislandener/pinterest-laravel - 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. aislandener/pinterest-laravel

AbandonedLibrary[API Development](/categories/api)

aislandener/pinterest-laravel
=============================

Laravel Package for the official Pinterest API

1.0.2(5y ago)03Apache-2.0PHPPHP &gt;=5.4

Since May 22Pushed 5y agoCompare

[ Source](https://github.com/aislandener/laravel-pinterest)[ Packagist](https://packagist.org/packages/aislandener/pinterest-laravel)[ RSS](/packages/aislandener-pinterest-laravel/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (4)Used By (0)

[![](https://camo.githubusercontent.com/70d6b255afdd04c62d3df2a176bb69f0f492c97785abbde7669ccb4817111fd4/687474703a2f2f692e696d6775722e636f6d2f63616367516c712e706e67)](https://camo.githubusercontent.com/70d6b255afdd04c62d3df2a176bb69f0f492c97785abbde7669ccb4817111fd4/687474703a2f2f692e696d6775722e636f6d2f63616367516c712e706e67) Pinterest API - Laravel
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#--pinterest-api---laravel)

---

A Package for using official [Pinterest API](https://dev.pinterest.com) with Laravel.

Requirements
============

[](#requirements)

- PHP 5.4 or higher
- Laravel 5.0 or Above
- cURL
- Registered Pinterest App

Get started
===========

[](#get-started)

To use the Pinterest API you have to register yourself as a developer and [create](https://dev.pinterest.com/apps/) an application. After you've created your app you will receive a `app_id` and `app_secret`.

> The terms `client_id` and `client_secret` are in this case `app_id` and `app_secret`.

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

[](#installation)

The Pinterest API wrapper is available on Composer.

```
composer require waleedahmad/pinterest-laravel

```

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

[](#configuration)

Add service provider for `$providers[]` array in `config/app.php` array.

```
'providers' => [
    [...] // other service providers
    \WaleedAhmad\Pinterest\ServiceProviders\PinterestServiceProvider::class,
]
```

Run `vendor:publish` command to copy pinterest configuration to app configs directory.

```
php artisan vendor:publish --provider="WaleedAhmad\Pinterest\ServiceProviders\PinterestServiceProvider"

```

Update `.env` file and fill in these `env` variables.

```
PINTEREST_KEY=YOUR_APP_KEY
PINTEREST_SECRET=YOUR_APP_SECRET
PINTEREST_REDIRECT_URI=YOUR_CALLBACK_URL

```

Getting access token in exchange for code
-----------------------------------------

[](#getting-access-token-in-exchange-for-code)

After you have initialized the class you can get a login URL:

```
$loginurl = Pinterest::auth()->getLoginUrl(CALLBACK_URL, array('read_public'));
echo 'Authorize Pinterest';
```

Check the [Pinterest documentation](https://dev.pinterest.com/docs/api/overview/#scopes) for the available scopes.

After your user has used the login link to authorize he will be send back to the given `CALLBACK_URL`. The URL will contain the `code` which can be exchanged into an `access_token`. To exchange the code for an `access_token` and set it you can use the following code:

```
if(isset($_GET["code"])){
    $token = Pinterest::auth()->getOAuthToken($_GET["code"]);
    Pinterest::auth()->setOAuthToken($token->access_token);
}
```

Get the user's profile
----------------------

[](#get-the-users-profile)

To get the profile of the current logged in user you can use the `Users::me();` method.

```
$me = Pinterest::user()->me();
echo $me;
```

Models
======

[](#models)

The API wrapper will parse all data through it's corresponding model. This results in the possibility to (for example) directly `echo` your model into a JSON string.

Models also show the available fields (which are also described in the Pinterest documentation). By default, not all fields are returned, so this can help you when providing extra fields to the request.

Available models
----------------

[](#available-models)

### [User](https://dev.pinterest.com/docs/api/users/#user-object)

[](#user)

### [Pin](https://dev.pinterest.com/docs/api/pins/#pin-object)

[](#pin)

### [Board](https://dev.pinterest.com/docs/api/boards/#board-object)

[](#board)

### Interest

[](#interest)

- id
- name

Retrieving extra fields
-----------------------

[](#retrieving-extra-fields)

If you want more fields you can specify these in the `$data` (GET requests) or `$fields` (PATCH requests) array. Example:

```
Pinterest::user()->me();
```

Response:

```
{
    "id": "503066358284560467",
    "username": null,
    "first_name": "Waleed",
    "last_name": "Ahmad",
    "bio": null,
    "created_at": null,
    "counts": null,
    "image": null
}
```

By default, not all fields are returned. The returned data from the API has been parsed into the `User` model. Every field in this model can be filled by parsing an extra `$data` array with the key `fields`. Say we want the user's username, first\_name, last\_name and image (small and large):

```
Pinterest::user()->me(array(
    'fields' => 'username,first_name,last_name,image[small,large]'
));
```

The response will now be:

```
{
    "id": "503066358284560467",
    "username": "waleedahmad",
    "first_name": "Waleed",
    "last_name": "Ahmad",
    "bio": null,
    "created_at": null,
    "counts": null,
    "image": {
        "small": {
                "url": "http://media-cache-ak0.pinimg.com/avatars/waleedahmad_1438089829_30.jpg",
                "width": 30,
                "height": 30
            },
            "large": {
                "url": "http://media-cache-ak0.pinimg.com/avatars/waleedahmad_1438089829_280.jpg",
                "width": 280,
                "height": 280
            }
        }
    }
}
```

Collection
==========

[](#collection)

When the API returns multiple models (for instance when your requesting the pins from a board) the wrapper will put those into a `Collection`.

The output of a collection contains the `data` and page `key`. If you echo the collection you will see a json encoded output containing both of these. Using the collection as an array will only return the items from `data`.

Available methods for the collection class:

Get all items
-------------

[](#get-all-items)

`all()`

```
$pins = Pinterest::user()->getMePins();
$pins->all();
```

Returns: `array`

Get item at index
-----------------

[](#get-item-at-index)

`get( int $index )`

```
$pins = Pinterest::user()->getMePins();
$pins->get(0);
```

Returns: `Model`

Check if collection has next page
---------------------------------

[](#check-if-collection-has-next-page)

`hasNextPage()`

```
$pins = Pinterest::user()->getMePins();
$pins->hasNextPage();
```

Returns: `Boolean`

Available methods
=================

[](#available-methods)

> Every method containing a `data` array can be filled with extra data. This can be for example extra fields or pagination.

Authentication
--------------

[](#authentication)

The methods below are available through `Pinterest::auth`.

### Get login URL

[](#get-login-url)

`getLoginUrl(string $redirect_uri, array $scopes, string $response_type = "code");`

```
Pinterest::auth()->getLoginUrl("https://pinterest.dev/callback.php", array("read_public"));
```

Check the [Pinterest documentation](https://dev.pinterest.com/docs/api/overview/#scopes) for the available scopes.

**Note: since 0.2.0 the default authentication method has changed to `code` instead of `token`. This means you have to exchange the returned code for an access\_token.**

### Get access\_token

[](#get-access_token)

`getOAuthToken( string $code );`

```
Pinterest::auth()->getOAuthToken($code);
```

### Set access\_token

[](#set-access_token)

`setOAuthToken( string $access_token );`

```
Pinterest::auth()->setOAuthToken($access_token);
```

### Get state

[](#get-state)

`getState();`

```
Pinterest::auth()->getState();
```

Returns: `string`

### Set state

[](#set-state)

`setState( string $state );`

This method can be used to set a state manually, but this isn't required since the API will automatically generate a random state on initialize.

```
Pinterest::auth()->setState($state);
```

Rate limit
----------

[](#rate-limit)

### Get limit

[](#get-limit)

`getRateLimit();`

This method can be used to get the maximum number of requests.

```
Pinterest::getRateLimit();
```

Returns: `int`

### Get remaining

[](#get-remaining)

`getRateLimitRemaining();`

This method can be used to get the remaining number of calls.

```
Pinterest::getRateLimitRemaining();
```

Returns: `int`

Users
-----

[](#users)

The methods below are available through `Pinterest::users`.

> You also cannot access a user’s boards or Pins who has not authorized your app.

### Get logged in user

[](#get-logged-in-user)

`me( array $data );`

```
Pinterest::user()->me();
```

Returns: `User`

### Find a user

[](#find-a-user)

`find( string $username_or_id );`

```
Pinterest::user()->find('waleedahmad');
```

Returns: `User`

### Get user's pins

[](#get-users-pins)

`getMePins( array $data );`

```
Pinterest::user()->getMePins();
```

Returns: `Collection`

### Search in user's pins

[](#search-in-users-pins)

`getMePins( string $query, array $data );`

```
Pinterest::user()->searchMePins("cats");
```

Returns: `Collection`

### Search in user's boards

[](#search-in-users-boards)

`searchMeBoards( string $query, array $data );`

```
Pinterest::user()->searchMeBoards("cats");
```

Returns: `Collection`

### Get user's boards

[](#get-users-boards)

`getMeBoards( array $data );`

```
Pinterest::user()->getMeBoards();
```

Returns: `Collection`

### Get user's followers

[](#get-users-followers)

`getMeFollowers( array $data );`

```
Pinterest::user()->getMeFollowers();
```

Returns: `Collection`

Boards
------

[](#boards)

The methods below are available through `Pinterest::boards`.

### Get board

[](#get-board)

`get( string $board_id, array $data );`

```
Pinterest::boards()->get("waleedahmad/pinterest-laravel");
```

Returns: `Board`

### Create board

[](#create-board)

`create( array $data );`

```
Pinterest::boards()->create(array(
    "name"          => "Test board from API",
    "description"   => "Test Board From API Test"
));
```

Returns: `Board`

### Edit board

[](#edit-board)

`edit( string $board_id, array $data, string $fields = null );`

```
Pinterest::boards-edit("waleedahmad/pinterest-laravel", array(
    "name"  => "Test board after edit"
));
```

Returns: `Board`

### Delete board

[](#delete-board)

`delete( string $board_id, array $data );`

```
Pinterest::boards()->delete("waleedahmad/pinterest-laravel");
```

Returns: `True|PinterestException`

Pins
----

[](#pins)

The methods below are available through `Pinterest::pins`.

### Get pin

[](#get-pin)

`get( string $pin_id, array $data );`

```
Pinterest::pins()->get("181692166190246650");
```

Returns: `Pin`

### Get pins from board

[](#get-pins-from-board)

`fromBoard( string $board_id, array $data );`

```
Pinterest::pins()->fromBoard("waleedahmad/pinterest-laravel");
```

Returns: `Collection`

### Create pin

[](#create-pin)

`create( array $data );`

Creating a pin with an image hosted somewhere else:

```
Pinterest::pins()->create(array(
    "note"          => "Test board from API",
    "image_url"     => "https://download.unsplash.com/photo-1438216983993-cdcd7dea84ce",
    "board"         => "waleedahmad/pinterest-laravel"
));
```

Creating a pin with an image located on the server:

```
Pinterest::pins()->create(array(
    "note"          => "Test board from API",
    "image"         => "/path/to/image.png",
    "board"         => "waleedahmad/pinterest-laravel"
));
```

Creating a pin with a base64 encoded image:

```
Pinterest::pins()->create(array(
    "note"          => "Test board from API",
    "image_base64"  => "[base64 encoded image]",
    "board"         => "waleedahmad/pinterest-laravel"
));
```

Returns: `Pin`

### Edit pin

[](#edit-pin)

`edit( string $pin_id, array $data, string $fields = null );`

```
Pinterest::pins()->edit("181692166190246650", array(
    "note"  => "Updated name"
));
```

Returns: `Pin`

### Delete pin

[](#delete-pin)

`delete( string $pin_id, array $data );`

```
Pinterest::pins()->delete("181692166190246650");
```

Returns: `True|PinterestException`

Following
---------

[](#following)

The methods below are available through `Pinterest::following`.

### Following users

[](#following-users)

`users( array $data );`

```
Pinterest::following()->users();
```

Returns: `Collection`

### Following boards

[](#following-boards)

`boards( array $data );`

```
Pinterest::following()->boards();
```

Returns: `Collection`

### Following interests/categories

[](#following-interestscategories)

`interests( array $data );`

```
Pinterest::following()->interests();
```

Returns: `Collection`

### Follow an user

[](#follow-an-user)

`followUser( string $username_or_id );`

```
Pinterest::following()->followUser("waleedahmad");
```

Returns: `True|PinterestException`

### Unfollow an user

[](#unfollow-an-user)

`unfollowUser( string $username_or_id );`

```
Pinterest::following()->unfollowUser("waleedahmad");
```

Returns: `True|PinterestException`

### Follow a board

[](#follow-a-board)

`followBoard( string $board_id );`

```
Pinterest::following()->followBoard("503066289565421201");
```

Returns: `True|PinterestException`

### Unfollow a board

[](#unfollow-a-board)

`unfollowBoard( string $board_id );`

```
Pinterest::following()->unfollowBoard("503066289565421201");
```

Returns: `True|PinterestException`

### Follow an interest

[](#follow-an-interest)

> According to the Pinterest documentation this endpoint exists, but for some reason their API is returning an error at the moment.

`followInterest( string $interest );`

```
Pinterest::following()->followInterest("architecten-911112299766");
```

Returns: `True|PinterestException`

### Unfollow an interest

[](#unfollow-an-interest)

> According to the Pinterest documentation this endpoint exists, but for some reason their API is returning an error at the moment.

`unfollowInterest( string $interest );`

```
Pinterest::following()->unfollowInterest("architecten-911112299766");
```

Returns: `True|PinterestException`

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~410 days

Total

3

Last Release

2144d ago

### Community

Maintainers

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

---

Top Contributors

[![waleedahmad](https://avatars.githubusercontent.com/u/4622791?v=4)](https://github.com/waleedahmad "waleedahmad (9 commits)")[![aislandener](https://avatars.githubusercontent.com/u/12144342?v=4)](https://github.com/aislandener "aislandener (2 commits)")[![suchiavana](https://avatars.githubusercontent.com/u/55969988?v=4)](https://github.com/suchiavana "suchiavana (1 commits)")

---

Tags

apilaravelpinterest

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aislandener-pinterest-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/aislandener-pinterest-laravel/health.svg)](https://phpackages.com/packages/aislandener-pinterest-laravel)
```

###  Alternatives

[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162155.1k1](/packages/joisarjignesh-bigbluebutton)[waleedahmad/pinterest-laravel

Laravel Package for the official Pinterest API

108.6k](/packages/waleedahmad-pinterest-laravel)

PHPackages © 2026

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