Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs]: Guide on working with Etsy in Gatsby #21580

Merged
merged 22 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions docs/docs/sourcing-from-etsy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: Sourcing from Etsy
---

[Etsy](https://www.etsy.com/) is an online marketplace for buying and selling handmade, vintage, and custom items. It's long been a home for creative entrepreneurs and can be used as a data source for your Gatsby site.

## Prerequisites

This guide assumes you already have a functioning Gatsby site as well as an open Etsy shop. You can start a new Gatsby site in a few steps with the [Quick Start guide](/docs/quick-start) and then [start selling on Etsy](https://www.etsy.com/your/shop/create)!

## Getting an API key

You'll need to make sure you have two-factor authentication enabled for your Etsy account. If you don't already, you'll be prompted when you go to [register a new application](https://www.etsy.com/developers/register). Fill in the required information as completely as you can, read Etsy's terms and conditions, and create your app.
AishaBlake marked this conversation as resolved.
Show resolved Hide resolved

Note that Etsy expects developers to test the API using real data. That means your shop and listings will be live even as you're working on this site. If you're already an active Etsy seller, this shouldn't change your usual workflow much. If you're starting a new shop, be mindful of [Etsy's testing policies](https://www.etsy.com/developers/documentation/getting_started/testing#section_etsy_api_testing_policies) as you test your work.

## Using the Etsy source plugin

You can use the `gatsby-source-etsy` plugin to pull featured listings and images from your Etsy shop into your Gatsby site. To install it, run:

```bash
npm install gatsby-source-etsy
```

### Configuring the plugin

You will then need to add the plugin, your API key, and your shop ID to your `gatsby-config.js` file. That said, finding your shop ID can be confusing. While your shop does have an ID _number_, you don't actually need this to make requests against the Etsy API. You can use your shop's _name_ as a unique identifier if you don't know your shop ID.

```js:title=gatsby-config.js
plugins: [
{
resolve: "gatsby-source-etsy",
options: {
// highlight-start
apiKey: "your api key here",
shopId: "your shop id or shop name here",
// highlight-end
language: "en", // optional
},
},
],
```

### Testing your queries

Once you have everything set up, run `gatsby develop` to start your site locally. At that point, you should be able to query for data related to your featured listings in [GraphiQL](/docs/running-queries-with-graphiql/). As an example, the following query gets the total number of featured listings in the shop as well as the price, title, and description of each item.

```graphql
allFeaturedEtsyListing {
totalCount
nodes {
price
title
description
}
}
```

Make sure you have _featured_ items! To edit your store, go to the Shop Manager and select your Etsy shop under "Sales Channels". You should see an option to edit or enable featured items.

## Displaying Etsy listings

You can pull your Etsy listing data into a page or component by composing a GraphQL query and specifying the data you would like to display. For example, consider the following query, which gets the title, price, URL, and an image of each featured listing.

```graphql
allFeaturedEtsyListing {
nodes {
title
price
url
description
childEtsyListingImage {
childFile {
childImageSharp {
fixed(width: 400, height: 400) {
...GatsbyImageSharpFixed
}
}
}
}
}
}
```

Using this query on a page or in a component will allow you to display your listings. The following example loops through the featured items and displays them within a component.

```js
laurieontech marked this conversation as resolved.
Show resolved Hide resolved
{
data.allFeaturedEtsyListing.nodes.map(item => (
AishaBlake marked this conversation as resolved.
Show resolved Hide resolved
<>
<a href={item.url}>
<h2>{item.title}</h2>
</a>
<Img fixed={item.childEtsyListingImage.childFile.childImageSharp.fixed} />
laurieontech marked this conversation as resolved.
Show resolved Hide resolved
<p>${item.price}</p>
<p>{item.description}</p>
</>
))
}
```
laurieontech marked this conversation as resolved.
Show resolved Hide resolved

## Gatsby advantages

If you are familiar with Etsy, you are aware of the restrictions around branding within the platform. Shops have an extremely similar look, which limits the creativity any individual shop owner can display. In addition, you have no control over Etsy's policies. An increase in their listing fees could have a significant impact on your profits. If Etsy went out of business, you would quickly be left without any customers.
AishaBlake marked this conversation as resolved.
Show resolved Hide resolved

So why sell on Etsy at all? The answer is that Etsy shops trade individuality for discoverability. Etsy's advertising budget is enormous compared to what a shop owner, operating alone, could afford. You also benefit from the trust Etsy has built up over the years. Because people are familiar with Etsy, they'll often go straight there to purchase their handmade or vintage items.
AishaBlake marked this conversation as resolved.
Show resolved Hide resolved

Building your own site with Gatsby allows you to have the best of both worlds. You can take control over your customers' experience and drive traffic to your own blazing fast website. You're also able to avoid links to others' listings competing for your customers' attention. At the same time, you maintain all the benefits of having your products listed on Etsy.

## Other resources

- [`gatsby-source-etsy`](/packages/gatsby-source-etsy/)
- Etsy's [API documentation](https://www.etsy.com/developers/documentation/)
92 changes: 0 additions & 92 deletions docs/docs/working-with-Etsy-in-Gatsby.md

This file was deleted.

4 changes: 2 additions & 2 deletions www/src/data/sidebars/doc-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@
link: /docs/processing-payments-with-stripe/
- title: Processing Payments with Square
link: /docs/processing-payments-with-square/
- title: Working with Etsy in Gatsby
link: /docs/working-with-etsy-in-gatsby/
- title: Sourcing from Etsy
link: /docs/sourcing-from-etsy/
- title: Sourcing from WooCommerce
link: /docs/sourcing-from-woocommerce
- title: Improving Performance
Expand Down