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

ActiveLibrary[API Development](/categories/api)

rhysnhall/etsy-php-sdk
======================

PHP SDK for Etsy API v3.

1.2.0(5mo ago)52106.1k↑29.8%421MITPHPPHP ^8.0

Since Aug 5Pushed 1mo ago15 watchersCompare

[ Source](https://github.com/rhysnhall/etsy-php-sdk)[ Packagist](https://packagist.org/packages/rhysnhall/etsy-php-sdk)[ RSS](/packages/rhysnhall-etsy-php-sdk/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (16)Used By (1)

Etsy PHP SDK
============

[](#etsy-php-sdk)

A PHP SDK for the Etsy API v3.

Proper documentation still to come. Want to write it for me? I'll buy you an iced latte.

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

[](#requirements)

PHP 8 or greater.

Install
-------

[](#install)

Install the package using composer.

```
composer require rhysnhall/etsy-php-sdk
```

Include the Etsy class.

```
use Etsy\Etsy;

$etsy = new Etsy(
  $client_id,
  $shared_secret,
  $access_token
);

// Do the Etsy things.
```

Usage
-----

[](#usage)

### Authorizing your app

[](#authorizing-your-app)

The Etsy API uses OAuth 2.0 authentication. You can read more about authenticating with Etsy on their [documentation](https://developers.etsy.com/documentation/essentials/authentication).

The first step in OAuth2 is to request an OAuth token. You will need an existing App API key and shared secret which you can obtain by registering an app [here](https://www.etsy.com/developers/register).

```
$client = new Etsy\OAuth\Client(
  $client_id,
  $shared_secret
);
```

Generate a URL to redirect the user to authorize access to your app.

```
$url = $client->getAuthorizationUrl(
  $redirect_uri,
  $scopes,
  $code_challenge,
  $nonce
);
```

###### Redirect URI

[](#redirect-uri)

You must set an authorized callback URL. Check out the [Etsy documentation](https://developers.etsy.com/documentation/essentials/authentication#redirect-uris) for further information.

###### Scope

[](#scope)

Depending on your apps requirements, you will need to specify the [permission scopes](https://developers.etsy.com/documentation/essentials/authentication#scopes) you want to authorize access for.

```
$scopes = ["listings_d", "listings_r", "listings_w", "profile_r"];
```

You can get all scopes, but it is generally recommended to only get what you need.

```
$scopes = \Etsy\Utils\PermissionScopes::ALL_SCOPES;
```

###### Code challenge

[](#code-challenge)

You'll need to generate a [PKCE code challenge](https://developers.etsy.com/documentation/essentials/authentication#proof-key-for-code-exchange-pkce) and save this along with the verifier used to generate the challenge. You are welcome to generate your own, or let the SDK do this for you.

```
[$verifier, $code_challenge] = $client->generateChallengeCode();
```

###### Nonce

[](#nonce)

The nonce is a single use token used for CSRF protection. You can use any token you like but it is recommended to let the SDK generate one for you each time you authorize a user. Save this for verifying the response later on.

```
$nonce = $client->createNonce();
```

The URL will redirect your user to the Etsy authorization page. If the user grants access, Etsy will send back a request with an authorization code and the nonce (state).

```
https://www.example.com/some/location?
      code=bftcubu-wownsvftz5kowdmxnqtsuoikwqkha7_4na3igu1uy-ztu1bsken68xnw4spzum8larqbry6zsxnea4or9etuicpra5zi
      &state=superstate

```

It is up to you to validate the nonce. If they do not match you should discard the response.

For more information on Etsy's response, check out the [documentation here](https://developers.etsy.com/documentation/essentials/authentication#step-2-grant-access).

The final step is to get the access token for the user. To do this you will need to make a request using the code that was just returned by Etsy. You will also need to pass in the same callback URL as the first request and the verifier used to generate the PKCE code challenge.

```
[$access_token, $refresh_token] = $client->requestAccessToken(
  $redirect_uri,
  $code,
  $verifier
);
```

You'll be provided with both an access token and a refresh token. The access token has a valid duration of 3600 seconds (1 hour). Save both of these for late use.

#### Refreshing your token

[](#refreshing-your-token)

You can refresh your authorization token (even after it has expired) using the refresh token that was previously provided. This will provide you with a new valid access token and another refresh token.

```
[$access_token, $refresh_token] = $client->refreshAccessToken($refresh_token);
```

The [Etsy documentation](https://developers.etsy.com/documentation/essentials/authentication#requesting-a-refresh-oauth-token) states that refreshed access tokens have a duration of 86400 seconds (24 hours) but on testing they appear to only remain valid for up 3600 seconds (1 hour).

#### Exchanging legacy OAuth 1.0 token for OAuth 2.0 token

[](#exchanging-legacy-oauth-10-token-for-oauth-20-token)

If you previously used v2 of the Etsy API and still have valid authorization tokens for your users, you may swap these over for valid OAuth2 tokens.

```
[$access_token, $refresh_token] = $client->exchangeLegacyToken($legacy_token);
```

This will provide you with a brand new set of OAuth2 access and refresh tokens.

### Basic use

[](#basic-use)

Create a new instance of the Etsy class using your App API key, app shared secret and a user's access token. **You must always initialize the Etsy resource before calling any resources**.

```
use Etsy\Etsy;
use Etsy\Resources\User;

$etsy = new Etsy($apiKey, $sharedSecret, $accessToken);

// Get the authenticated user.
$user = User::me();

// Get the users shop.
$shop = $user->shop();
```

#### Resources

[](#resources)

Most calls will return a `Resource`. Resources contain a number of methods that streamline your interaction with the Etsy API.

```
// Get a Listing Resource
$listing = \Etsy\Resources\Listing::get($shopId);
```

Resources contain the API response from Etsy as properties.

```
$listingTitle = $listing->title;
```

##### Associations

[](#associations)

Resources will return associations as their respective Resource when appropriate. For example the bellow call will return the `shop` property as an instance of `Etsy\Resources\Shop`.

```
$shop = $listing->shop;
```

##### `toJson`

[](#tojson)

The `toJson` method will return the Resource as a JSON encoded object.

```
$json = $listing->toJson();
```

##### `toArray`

[](#toarray)

The `toArray` method will return the Resource as an array.

```
$array = $listing->toArray();
```

#### Collections

[](#collections)

When there is more than one result a collection will be returned.

```
$reviews = Review::all();
```

Results are stored as an array of `Resource` on the `data` property of the collection.

```
$firstReview = $reviews->data[0];
```

Collections contain a handful of useful methods.

##### `first`

[](#first)

Get the first item in the collection.

```
$firstReview = $reviews->first();
```

##### `count`

[](#count)

Get the number of results in the collection. Not be confused with the `count` property which displays the number of results in a full Etsy resource.

```
$count = $reviews->count();
```

##### `append`

[](#append)

Append a property to each item in the collection.

```
$reviews->append(['shop_id' => $shopId]);
```

##### `paginate`

[](#paginate)

Most Etsy methods are capped at 100 results per call. You can use the `paginate` method to get more results than this (up to 500 results).

```
// Get 100 results using pagination.
foreach($reviews->paginate(200) as $review) {
  ...
}
```

##### `toJson`

[](#tojson-1)

Returns the items in the collection as an array of JSON strings.

```
$jsonArray = $reviews->toJson();
```

#### Direct Requests

[](#direct-requests)

You can make direct requests to the Etsy API using the static `$client` property of the Etsy class.

```
$response = Etsy::$client->get(
  "/application/listings/active",
  [
    "limit" => 25
  ]
);
```

If you still want to use the Resources classes you can convert the response into a `Resource`. Pass the response from the client as the first parameter and the name of the resource as the second. If the response is an array then a `Collection` will be returned.

```
$listings = Etsy::getResource(
  Etsy::$client->get("/application/listings/active"),
  'Listing'
);
```

### File Uploads

[](#file-uploads)

Etsy listings support uploads for files, images and videos depending on the Listing type. The SDK includes ***basic*** support for uploading files.

#### Images

[](#images)

To upload an image you need to pass the image data under the `image` parameter on your request as if it was prepared for multipart form-data.

```
$data = [
  'image' => [
    'content' => fopen('./path-to-image.jpg')
  ]
];
$image = ListingImage::create(
  $shopId,
  $listingId,
  $data
);
```

For convenience you can just include a path or an external URL and the SDK will handle ***basic*** reading of the file.

```
$data = [
  'image' => './path-to-image.jpg'
];
```

#### Other files

[](#other-files)

Video and file uploads work the same way but these also require a `name` parameter on the upload request. This name just represents the name of the file to upload.

```
ListingVideo::create(
  $shopId,
  $listingId,
  [
    'video' => './path-to-video.mp4',
    'name' => $fileName
  ]
);

ListingFile::create(
  $shopId,
  $listingId,
  [
    'file' => './downloadable-template.pdf',
    'name' => $fileName
  ]
);
```

### Instance Methods

[](#instance-methods)

Most of the SDK is built around calling static methods on the different Etsy resources. For convenience some resources contain instance methods. These are designed to streamline interaction with the SDK.

#### Save method

[](#save-method)

Many resources contain a `save()` method which is a convenient shortcut for a patch request. In most cases the current data will be compared against the values of the `_originalState` property on the Resource and if no data has been changed the patch request will be skipped.

```
$listing = \Etsy\Resources\Listing::get($listingId);

# Update listing title.
$listing->title = 'Updated title';
$listing->save();
```

#### Other methods

[](#other-methods)

Review each Resource to better understand the methods available. There are some examples below of methods available to the ***Listing*** resource.

```
$listing->images(); // Get all images for the listing.
$listing->uploadImage($imageData); // Upload a new image.
$listing->inventory(); // Get the listing inventory.
$listing->translation('en'); // Get the English translation for the listing.
```

---

Full documentation will be available soon (or so I keep saying). Email  for any assistance.

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

[](#contributing)

Help improve this SDK by contributing.

Before opening a pull request, please first discuss the proposed changes via Github issue or [email](mailto:hello@rhyshall.com).

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](https://github.com/rhysnhall/etsy-php-sdk/blob/master/LICENSE.md) file for details

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity47

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 83.7% 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 ~105 days

Recently: every ~127 days

Total

16

Last Release

165d ago

Major Versions

0.4.0.x-dev → 1.02024-07-13

PHP version history (3 changes)0.1PHP &gt;=7.0

0.1.1PHP &gt;=7.1

1.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25257505?v=4)[Rhys Hall](/maintainers/rhysnhall)[@rhysnhall](https://github.com/rhysnhall)

---

Top Contributors

[![rhysnhall](https://avatars.githubusercontent.com/u/25257505?v=4)](https://github.com/rhysnhall "rhysnhall (36 commits)")[![ng-agalanis](https://avatars.githubusercontent.com/u/181734251?v=4)](https://github.com/ng-agalanis "ng-agalanis (3 commits)")[![chrismjones](https://avatars.githubusercontent.com/u/296080?v=4)](https://github.com/chrismjones "chrismjones (2 commits)")[![codingkoaladev](https://avatars.githubusercontent.com/u/16990838?v=4)](https://github.com/codingkoaladev "codingkoaladev (1 commits)")[![mixisLv](https://avatars.githubusercontent.com/u/3735128?v=4)](https://github.com/mixisLv "mixisLv (1 commits)")

---

Tags

etsyetsy-apietsy-api-v3phpsdksdk-phpphpapisdketsy

### Embed Badge

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

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23914.2M16](/packages/hubspot-api-client)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2292.2M24](/packages/php-opencloud-openstack)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)

PHPackages © 2026

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