Downloads featured listing info and images for your shop!
Install the package from npm:
npm i gatsby-source-etsy
Next, add the plugin to your gatsby-config.js
file:
module.exports = {
plugins: [
{
resolve: 'gatsby-source-etsy',
options: {
apiKey: 'your api key here',
shopId: 'your shop id here',
language: 'en', // optional
},
},
],
};
Listing info:
{
allFeaturedEtsyListing(
sort: { fields: featured_rank, order: ASC }
limit: 4
) {
nodes {
currency_code
title
listing_id
price
url
}
}
}
Query transformed/optimized images for a listing (e.g. for use with gatsby-image
- see below):
{
allFeaturedEtsyListing(
sort: { fields: featured_rank, order: ASC }
limit: 4
) {
nodes {
childrenEtsyListingImage {
rank
childFile {
childImageSharp {
fluid {
base64
tracedSVG
aspectRatio
width
height
src
srcSet
srcWebp
srcSetWebp
originalName
}
}
}
}
}
}
}
- allFeaturedEtsyListing
- allEtsyListingImage
- featuredEtsyListing
- childrenEtsyListingImage
- etsyListingImage
- childFile
Install the necessary packages:
npm install gatsby-image gatsby-plugin-sharp gatsby-transformer-sharp
Query:
{
featuredEtsyListing {
childrenEtsyListingImage {
childFile {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
}
}
See gatsby-image
for more.