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

AbandonedArchivedLibrary[API Development](/categories/api)

lemaur/laravel-pinterest-api
============================

0.3.5(3y ago)5486[6 PRs](https://github.com/leMaur/laravel-pinterest-api/pulls)MITPHPPHP ^8.1CI failing

Since Mar 26Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/leMaur/laravel-pinterest-api)[ Packagist](https://packagist.org/packages/lemaur/laravel-pinterest-api)[ Docs](https://github.com/lemaur/laravel-pinterest-api)[ RSS](/packages/lemaur-laravel-pinterest-api/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (13)Versions (18)Used By (0)

Laravel Pinterest Api
=====================

[](#laravel-pinterest-api)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a6fe2de7b17827cdacf39389c090f4567c513f169d6faf6726da09e10a50aab2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656d6175722f6c61726176656c2d70696e7465726573742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lemaur/laravel-pinterest-api)[![Total Downloads](https://camo.githubusercontent.com/08ad3e82c4661262b3abb1e3c3286a04f67f9c2d5fa7d5573fdfe0cb7ec3f972/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c656d6175722f6c61726176656c2d70696e7465726573742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lemaur/laravel-pinterest-api)[![License](https://camo.githubusercontent.com/c4771ed321722fc17e46d5ad8acb98effea8db7d45639b04a62c8e1b7ad3720f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c656d6175722f6c61726176656c2d70696e7465726573742d6170692e7376673f7374796c653d666c61742d73717561726526636f6c6f723d79656c6c6f77)](https://github.com/leMaur/laravel-pinterest-api/blob/main/LICENSE.md)[![Tests](https://camo.githubusercontent.com/8105d71727c3ae259e67593cb006b478347348d7b708ac9c2f8417a28797be29/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c656d6175722f6c61726176656c2d70696e7465726573742d6170692f72756e2d74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/leMaur/laravel-pinterest-api/actions/workflows/run-tests.yml)[![GitHub Sponsors](https://camo.githubusercontent.com/67130ea26c0cdbb7c18af5c1fd1c7995f000bc3da607abffed1e39d789f48b2f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f6c656d6175723f7374796c653d666c61742d73717561726526636f6c6f723d656134616161)](https://github.com/sponsors/leMaur)[![Trees](https://camo.githubusercontent.com/f12f2059f308501188008a8639ea876a9d8f8f3ce4047ea60b328985fc08b312/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f636f6c6f723d79656c6c6f77677265656e267374796c653d666c61742d737175617265266c6162656c3d54726565732671756572793d2532342e746f74616c2675726c3d68747470732533412532462532467075626c69632e6f66667365742e656172746825324675736572732532466c656d6175722532467472656573)](https://ecologi.com/lemaur?r=6012e849de97da001ddfd6c9)

An Object-Oriented wrapper for consuming Pinterest API with Laravel.

It uses [Pinterest API v5](https://developers.pinterest.com/docs/api/v5/).

> **Warning**: This package DOESN'T store Pinterest's credentials, you should provide your own logic!
> 👉 Please read carefully the [Manage credentials](#manage-credentials) section! 👈

Support Me
----------

[](#support-me)

Hey folks,

Do you like this package? Do you find it useful, and it fits well in your project?

I am glad to help you, and I would be so grateful if you considered supporting my work.

You can even choose 😃:

- You can [sponsor me 😎](https://github.com/sponsors/leMaur) with a monthly subscription.
- You can [buy me a coffee ☕ or a pizza 🍕](https://github.com/sponsors/leMaur?frequency=one-time&sponsor=leMaur) just for this package.
- You can [plant trees 🌴](https://ecologi.com/lemaur?r=6012e849de97da001ddfd6c9). By using this link we will both receive 30 trees for free and the planet (and me) will thank you.
- You can "Star ⭐" this repository (it's free 😉).

Roadmap
-------

[](#roadmap)

This package still in development.
You can vote for endpoints not yet covered by [requesting them here](https://github.com/lemaur/laravel-pinterest-api/discussions/new?category=polls).
If so, it would be great if you wanted [sponsor me](https://github.com/sponsors/leMaur) to support my work.

- Pins
    - list
    - create
    - get
    - delete
    - update
    - save
    - analytics
- Boards
    - list
    - create
    - get
    - delete
    - update
    - pins
- Board Sections
- Ad Accounts
- Ad Groups
- Ads
- Audience Insights
- Audiences
- Bulk
- Campaigns
- Catalogs
- Conversion Events
- Conversion Tags
- Customer Lists
- Integrations
- Interests
- Keywords
- Media
- OAuth
- Order Lines
- Product Group Promotions
- Product Groups
- Resources
- Search
- Terms
- Terms of Service
- User Account

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

[](#installation)

You can require the package via composer:

```
composer require lemaur/laravel-pinterest-api
```

You can install it with:

```
php artisan pinterest-api:install
```

Manage credentials
------------------

[](#manage-credentials)

[Pinterest API Authentication](https://developers.pinterest.com/docs/getting-started/authentication/) follows the [OAuth2 standard](https://datatracker.ietf.org/doc/html/rfc6749/).

The package contains helpful methods to obtain the credentials from Pinterest OAuth server, but where to store them is up to you! Every project is different, with different requirements. You can store credentials on disk, or you can write them on DB and so on...

> **Note**: You'll need to register a new app on Pinterest and get the app ID and secret key.
> But don't worry, we'll do it in the [next section](#require-pinterest-access).

Here I'll show you how to configure your project to manage credentials.

The authentication flow returns an object containing `access_token` and `refresh_token` within the expiration timestamps and other information.

Here an example:

```
{
    "access_token": "{an access token string prefixed with 'pina'}",
    "refresh_token": "{a refresh token string prefixed with 'pinr'}",
    "response_type": "authorization_code",
    "token_type": "bearer",
    "expires_in": 2592000,
    "refresh_token_expires_in": 31536000,
    "scope": "boards:read boards:write pins:read"
}
```

The package emits `Lemaur\Pinterest\Events\CredentialsRetrieved::class` event within `Lemaur\Pinterest\Data\OAuthData` object when it receives the credentials. You can listen for this event in your project and store the credentials where you want.

To do that, you need to create a new listener

```
php artisan make:listener --event=\\Lemaur\\Pinterest\\Events\\CredentialsRetrieved StorePinterestCredentials
```

And inside the `handle` method you can decide where to store the credentials.

```
// file: app/Listeners/StorePinterestCredentials.php

/**
 * Handle the event.
 *
 * @param  \Lemaur\Pinterest\Events\CredentialsRetrieved  $event
 * @return void
 */
public function handle(CredentialsRetrieved $event)
{
    // Store the credentials from `$event->oauth`.
    // Where `$event->oauth` is an instance of `Lemaur\Pinterest\Data\OAuthData`.

    /**
     * For e.g. you can extend your User model by adding a json column `pinterest_credentials`
     * and store the credentials for each authenticated user.
     *
     * \Illuminate\Support\Facades\Auth::user()->update([
     *     'pinterest_credentials' = $event->oauth->toArray(),
     * ]);
     */
}
```

Don't forget to register the listener in the `App\Providers\EventServiceProvider`.

```
// file: app/Providers/EventServiceProvider.php

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
    \Lemaur\Pinterest\Events\CredentialsRetrieved::class => [
        \App\Listeners\StorePinterestCredentials::class,
    ],
];
```

Now it's time to edit the service provider. Open `App\Providers\PinterestServiceProvider`, and inside the `register` method you will find a predefined implementation.

As you can see in the `@TODO` comment, here is where you should pass the credentials you previously stored.

```
public function register(): void
{
    $this->app->singleton(PinterestContract::class, fn (Application $app) => new PinterestService(
        config: ConfigData::fromConfig($app['config']['pinterest']),
        oauth: OAuthData::from([]), // @TODO:  **Note**: For local development it's preferred to use `http://localhost/pinterest/callback`

```
PINTEREST_API_REDIRECT_URI=http://localhost/pinterest/callback
```

### Generate an access token

[](#generate-an-access-token)

1. To start the OAuth flow and request user access run `php artisan pinterest:get-access-code-link`
2. Copy/Paste the link to your browser and follow the instructions on screen.
3. At the end of the process you will see a white page with a text saying "All good! You can close this page."

Now you are ready to call the Pinterest API.

NOTES
=====

[](#notes)

Pinterest provides an `access_token` valid for 30 days and a `refresh_token` valid for 1 year.
The package automatically retrieves a new access token every time it expires, as long as the refresh token is still valid.
After 1 year, when you try to call an API endpoint, the package will throw a `OAuthException` with a message informing you to request a new access code.

If you are curious you can [read the codebase to learn more](https://github.com/leMaur/laravel-pinterest-api/blob/main/src/Services/Concerns/BuildBaseRequest.php#L18).

Or you can use `Lemaur\Pinterest\Facades\Pinterest::oauth()->credentials()->accessTokenExpiresIn` to get the number of days before the access token will expire.
The same for the refresh token `Lemaur\Pinterest\Facades\Pinterest::oauth()->credentials()->refreshTokenExpiresIn`.

Testing
-------

[](#testing)

The package offers a nifty fake method to help you write your tests.
If you want some examples, I suggest to look at [the package test suite](https://github.com/leMaur/laravel-pinterest-api/tree/main/tests).

```
Pinterst::assertSent(callable $callback): void
```

```
Pinterst::assertNotSent(callable $callback): void
```

```
Pinterst::assertSentCount(int $count): void
```

```
Pinterst::assertNothingSent(): void
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Maurizio](https://github.com/lemaur)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance55

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.2% 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 ~3 days

Total

8

Last Release

1176d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2696e190d36ed3a6809d954e3ae2153f969be340ef9b188f8a02bdc98b52f6c7?d=identicon)[leMaur](/maintainers/leMaur)

---

Top Contributors

[![leMaur](https://avatars.githubusercontent.com/u/2118799?v=4)](https://github.com/leMaur "leMaur (45 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

apilaravellemaurpinterestpinterest-apiv5apilaravelpinterestv5lemaur

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[nativephp/mobile

NativePHP for Mobile

1.1k75.1k91](/packages/nativephp-mobile)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1123.7k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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