PHPackages                             siapepfrance/pinterest-php-client - 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. siapepfrance/pinterest-php-client

ActiveLibrary[API Development](/categories/api)

siapepfrance/pinterest-php-client
=================================

PHP client for the Pinterest API

0.3.14(4y ago)0460Apache-2.0PHPPHP &gt;=5.4

Since Aug 6Pushed 4y agoCompare

[ Source](https://github.com/siapepfrance/pinterest-php-client)[ Packagist](https://packagist.org/packages/siapepfrance/pinterest-php-client)[ RSS](/packages/siapepfrance-pinterest-php-client/feed)WikiDiscussions master Synced 2d ago

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

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

[](#--pinterest-api-v5---php)

[![](https://camo.githubusercontent.com/79bea952633fc39a63cef920dc475dd86c483e270e8f6ad819abff1105294ae0/68747470733a2f2f7472617669732d63692e6f72672f6469726b67726f656e656e2f70696e7465726573742d7068702d636c69656e742e737667)](https://travis-ci.org/dirkgroenen/pinterest-php-client)[![](https://camo.githubusercontent.com/19d1d80f39bab5bae2fae598cee8b4707aa27a8614a7ed758ded020e423541dc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6469726b67726f656e656e2f70696e7465726573742d7068702d636c69656e742e737667)](https://scrutinizer-ci.com/g/dirkgroenen/pinterest-php-client/?branch=master)[![](https://camo.githubusercontent.com/dab88953c89759a3c95d8f537dcfad7c4850709a3b7f7f21eae362fd6b8fa87b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6469726b67726f656e656e2f70696e7465726573742d7068702d636c69656e742e737667)](https://scrutinizer-ci.com/g/dirkgroenen/pinterest-php-client/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fc7ee3f03b82434d6738dcd290800b4b5769a341d7c74327a230a6638644b3a7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6469726b67726f656e656e2f70696e7465726573742d7068702d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dirkgroenen/pinterest-php-client/?branch=master)[![Packagist](https://camo.githubusercontent.com/9c950694044f0b24ebad1c11d29303c941f65b2eb835586041a0399472ed360b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469726b67726f656e656e2f70696e7465726573742d7068702d636c69656e742e737667)](https://packagist.org/packages/dirkgroenen/pinterest-php-client)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#)

A PHP client for the official [Pinterest API V5+](https://developers.pinterest.com/docs/api/v5/).

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

[](#requirements)

- PHP 5.4 or higher (actively tested on PHP &gt;=7.1)
- cURL
- Registered Pinterest App

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

[](#get-started)

To use the Pinterest API V5+ you have to register yourself as a developer and [create](https://developers.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 V5+ wrapper is available on Github only so you need two steps to install it.

The Pinterest API V5+ client is available on Composer

```
composer require siapepfrance/pinterest-php-client

```

If you're not using Composer (which you should start using, unless you've got a good reason not to) you can include the `autoload.php` file in your project.

Simple Example
--------------

[](#simple-example)

```
use SiapepFrance\Pinterest\Pinterest;

$pinterest = new Pinterest(CLIENT_ID, CLIENT_SECRET);
```

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

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

Check the [Pinterest documentation](https://developers.pinterest.com/docs/api/v5/#tag/Scopes) for the available scopes.

After your user has used the login link to authorize he will be send back to the given `REDIRECT_URI`. 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->setRedirectUri(REDIRECT_URI)->getOAuthToken($_GET["code"]);
    $pinterest->auth->setOAuthToken($token->access_token);
}
```

Get the user's account
----------------------

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

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

```
$userAccount = $pinterest->user_accounts->get();
echo $userAccount;
```

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 Accounts](https://developers.pinterest.com/docs/api/v5/#tag/user_account)

[](#user-accounts)

### [Boards](https://developers.pinterest.com/docs/api/v5/#tag/boards)

[](#boards)

### [Pins](https://developers.pinterest.com/docs/api/v5/#tag/pins)

[](#pins)

### [Ad Accounts](https://developers.pinterest.com/docs/api/v5/#tag/ad_accounts)

[](#ad-accounts)

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_accounts->get();
```

Response:

```
{
    "account_type": "PINNER",
    "profile_image": "https://www.siapep.fr/profile",
    "website_url": "https://www.siapep.fr",
    "username": "siapepfrance"
}
```

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->boards->listBoards();
$pins->all();
```

Returns: `array`

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

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

`get( int $index )`

```
$pins = $pinterest->boards->listBoards();
$pins->get(0);
```

Returns: `Model`

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

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

`hasNextPage()`

```
$pins = $pinterest->boards->listBoards();
$pins->hasNextPage();
```

Get the next page if collection has next page
---------------------------------------------

[](#get-the-next-page-if-collection-has-next-page)

`getNextPage()`

```
$pins = $pinterest->boards->getNextPage();
$pins->getNextPage();
```

Returns: `Boolean`

Get pagination data
-------------------

[](#get-pagination-data)

Returns an array with an `URL` and `cursor` for the next page, or `false` when no next page is available.

`pagination`

```
$pins = $pinterest->boards->listBoards();
$pins->pagination['cursor'];
```

Returns: `Array`

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("boards:read,boards:write,boards:write_secret,pins:read,pins:write,pins:write_secret"));
```

Check the [Pinterest documentation](https://developers.pinterest.com/docs/api/v5/#tag/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.**

### Set redirect\_uri (this method is useful when using the authorization\_code flow to authenticate )

[](#set-redirect_uri-this-method-is-useful-when-using-the-authorization_code-flow-to-authenticate-)

`setRedirectUri( string $redirect_uri );`

```
$pinterest->auth->setRedirectUri($redirect_uri);
```

### 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);
```

### Refresh the expired access\_token thanks to the refresh token

[](#refresh-the-expired-access_token-thanks-to-the-refresh-token)

`refreshOAuthToken( string $refresh_token );`

```
$pinterest->auth->refreshOAuthToken($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)

> Note that you should call an endpoint first, otherwise `getRateLimit()` will return `unknown`.

### 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`

User Accounts
-------------

[](#user-accounts-1)

The methods below are available through `$pinterest->user_accounts`.

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

### Get logged in user account

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

`get( array $data );`

```
$pinterest->user_accounts->get();
```

Returns: `UserAccount`

### Get logged in user account analytics

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

`getAnalytics( array $data );`

```
$pinterest->user_accounts->getAnalytics($data);
```

Returns: `Collection`

Boards
------

[](#boards-1)

The methods below are available through `$pinterest->boards`.

### List boards

[](#list-boards)

`listBoards( array $data );`

```
$pinterest->boards->listBoards();
```

Returns: `Collection`

### Get board

[](#get-board)

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

```
$pinterest->boards->get();
```

Returns: `Board`

### Create board

[](#create-board)

`create( array $data );`

```
$pinterest->boards->create(array(
    "name"          => "Test board from API",
    "description"   => "Test Board From API Test",
    "privacy"       => "PUBLIC"
));
```

Returns: `Board`

### Edit board

[](#edit-board)

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

```
$pinterest->boards->edit("1234567890", array(
    "name"  => "Test board after edit"
));
```

Returns: `Board`

### Get board pins

[](#get-board-pins)

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

```
$pinterest->boards->pins("1234567890", []);
```

Returns: `Collection`

### Delete board

[](#delete-board)

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

```
$pinterest->boards->delete("1234567890", []);
```

Returns: `True|PinterestException`

Sections
--------

[](#sections)

The methods below are available through `$pinterest->sections`.

### Create section on board

[](#create-section-on-board)

`create( string $boardId, array $data );`

```
$pinterest->sections->create("1234567890", array(
    "name" => "Test from API"
));
```

Returns: `Section`

### Update section on board

[](#update-section-on-board)

`create( string $boardId, string $sectionId, array $data );`

```
$pinterest->sections->update("1234567890", "10111213", array(
    "name" => "Test from API"
));
```

Returns: `Section`

### Get sections on board

[](#get-sections-on-board)

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

```
$pinterest->sections->get("1234567890");
```

Returns: `Collection`

### Get pins from section

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

> Note: Returned board ids can't directly be provided to `pins()`. The id needs to be extracted from &lt;BoardSection xxx&gt;

`get( string $boardId, string $sectionId, array $data );`

```
$pinterest->sections->pins("1234567890", "10111213");
```

Returns: `Collection`

### Delete section

[](#delete-section)

`delete( string $boardId, string $sectionId );`

```
$pinterest->sections->delete("1234567890", "10111213");
```

Returns: `boolean`

Pins
----

[](#pins-1)

The methods below are available through `$pinterest->pins`.

### Get pin

[](#get-pin)

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

```
$pinterest->pins->get("10111213");
```

Returns: `Pin`

### Get pins from board

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

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

```
$pinterest->pins->fromBoard("1234567890");
```

Returns: `Collection`

### Create pin

[](#create-pin)

`create( array $data );`

Creating a pin with an image hosted somewhere else:

```
$pinterest->pins->create(array(
    'link' => 'https://www.siapep.fr',
    'title' => 'Test board from API',
    'description' => $message,
    'alt_text' => "",
    'board_id' => '1234567890',
    'board_section_id' => null,
    'media_source' => [
        'source_type' => 'image_url',
        'url' => 'https://www.siapep.fr/api/public/file/23/getcontent'
    ]
));
```

Creating a pin with a base64 encoded image on the server:

```
// Get the image and convert into string
$img = file_get_contents('/path/to/image.png');

// Encode the image string data into base64
$imgBase64 = base64_encode($img);

$pinterest->pins->create(array(
    'link' => 'https://www.siapep.fr',
    'title' => 'Test Pin from API',
    'description' => 'Test Pin description from API',
    'alt_text' => "",
    'board_id' => '1234567890',
    'board_section_id' => null,
    'media_source' => [
        'source_type' => 'image_base64',
        'content_type' => 'image/png',
        'data' => $imgBase64
    ]
));
```

Returns: `Pin`

### Edit pin

[](#edit-pin)

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

```
$pinterest->pins->edit("15161718", array(
    'description' => 'Test Pin description from API bis',
));
```

Returns: `Pin`

### Delete pin

[](#delete-pin)

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

```
$pinterest->pins->delete("181692166190246650");
```

Returns: `True|PinterestException`

Ad Accounts
-----------

[](#ad-accounts-1)

The methods below are available through `$pinterest->ad_accounts`.

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

### Get ad accounts

[](#get-ad-accounts)

`get( array $data );`

```
$pinterest->ad_accounts->get();
```

Returns: `AdAccount`

### Get ad accounts analytics

[](#get-ad-accounts-analytics)

`getAnalytics( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getAnalytics($adAccountId, $data);
```

Returns: `Collection`

### Get ad accounts campaigns

[](#get-ad-accounts-campaigns)

`getCampaigns( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getCampaigns($adAccountId, $data);
```

Returns: `Collection`

### Get ad account campaign analytics

[](#get-ad-account-campaign-analytics)

`getCampaignAnalytics( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getCampaignAnalytics($adAccountId, $data);
```

Returns: `Collection`

### Get ad account groups

[](#get-ad-account-groups)

`getAdGroups( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getAdGroups($adAccountId, $data);
```

Returns: `Collection`

### Get ad account group analytics

[](#get-ad-account-group-analytics)

`getAdGroupAnalytics( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getAdGroupAnalytics($adAccountId, $data);
```

Returns: `Collection`

### Get ad account ads

[](#get-ad-account-ads)

`getAds( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getAds($adAccountId, $data);
```

Returns: `Collection`

### Get ad account ad analytics

[](#get-ad-account-ad-analytics)

`getAdAnalytics( string $adAccountId, array $data );`

```
$pinterest->ad_accounts->getAdAnalytics($adAccountId, $data);
```

Returns: `Collection`

Examples
========

[](#examples)

Use can take a look at the `./demo` directory for a simple example.

Let me know if you have an (example) project using the this library.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 79.1% 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 ~101 days

Recently: every ~488 days

Total

23

Last Release

1699d ago

### Community

Maintainers

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

---

Top Contributors

[![dirkgroenen](https://avatars.githubusercontent.com/u/1001391?v=4)](https://github.com/dirkgroenen "dirkgroenen (144 commits)")[![jeandonaldroselin](https://avatars.githubusercontent.com/u/6600353?v=4)](https://github.com/jeandonaldroselin "jeandonaldroselin (7 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (6 commits)")[![pavelhouzva](https://avatars.githubusercontent.com/u/4955758?v=4)](https://github.com/pavelhouzva "pavelhouzva (4 commits)")[![aimflaiims](https://avatars.githubusercontent.com/u/17019518?v=4)](https://github.com/aimflaiims "aimflaiims (3 commits)")[![mikropiks](https://avatars.githubusercontent.com/u/47701642?v=4)](https://github.com/mikropiks "mikropiks (3 commits)")[![bercium](https://avatars.githubusercontent.com/u/909988?v=4)](https://github.com/bercium "bercium (3 commits)")[![sfai05](https://avatars.githubusercontent.com/u/1597348?v=4)](https://github.com/sfai05 "sfai05 (2 commits)")[![itzmukeshy7](https://avatars.githubusercontent.com/u/5780768?v=4)](https://github.com/itzmukeshy7 "itzmukeshy7 (2 commits)")[![nWidart](https://avatars.githubusercontent.com/u/882397?v=4)](https://github.com/nWidart "nWidart (2 commits)")[![kalenjohnson](https://avatars.githubusercontent.com/u/2036520?v=4)](https://github.com/kalenjohnson "kalenjohnson (1 commits)")[![NinoSkopac](https://avatars.githubusercontent.com/u/1783732?v=4)](https://github.com/NinoSkopac "NinoSkopac (1 commits)")[![gpopoteur](https://avatars.githubusercontent.com/u/952557?v=4)](https://github.com/gpopoteur "gpopoteur (1 commits)")[![jamesinealing](https://avatars.githubusercontent.com/u/1590569?v=4)](https://github.com/jamesinealing "jamesinealing (1 commits)")[![ishikawam](https://avatars.githubusercontent.com/u/1132355?v=4)](https://github.com/ishikawam "ishikawam (1 commits)")[![martinstuecklschwaiger](https://avatars.githubusercontent.com/u/1061218?v=4)](https://github.com/martinstuecklschwaiger "martinstuecklschwaiger (1 commits)")

---

Tags

apiclientwrapperpinterest

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/siapepfrance-pinterest-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/siapepfrance-pinterest-php-client/health.svg)](https://phpackages.com/packages/siapepfrance-pinterest-php-client)
```

###  Alternatives

[dirkgroenen/pinterest-api-php

PHP Wrapper for the official Pinterest API

176495.2k4](/packages/dirkgroenen-pinterest-api-php)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[swader/diffbot-php-client

A PHP wrapper for using Diffbot's API

5328.5k](/packages/swader-diffbot-php-client)[opensaucesystems/lxd

PHP-based API wrapper for LXD REST API.

305.8k](/packages/opensaucesystems-lxd)[dhope0000/lxd

PHP-based API wrapper for LXD REST API.

136.2k](/packages/dhope0000-lxd)

PHPackages © 2026

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