npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-source-pixabay

v1.0.3

Published

A Gatsby source plugin to load resources from the Pixabay API.

Downloads

13

Readme

gatsby-source-pixabay

This source plugin for Gatsby will make images from Pixabay available in GraphQL queries.

Installation

# Install the plugin
yarn add gatsby-source-pixabay

In gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-pixabay',
      options: {
        key: 'YOUR_PIXABAY_API_KEY'
      }
    }
  ]
};

NOTE: To get a Pixabay API key, register for a Pixabay account. You can find your API key in the “Search Images” section of the Pixabay API docs.

Configuration Options

The configuration options for this plugin mirror the “Search Image” options. Please review those docs for more details.

| Option | Default | Description | | ---------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | key | | [required] Your Pixabay API key | | q | | A URL encoded search term. If omitted, all images are returned. This value may not exceed 100 characters, e.g. "yellow+flower" | | lang | "en" | Language code of the language to be searched in.Accepted values: cs, da, de, en, es, fr, id, it, hu, nl, no, pl, pt, ro, sk, fi, sv, tr, vi, th, bg, ru, el, ja, ko, zh | | image_type | "all" | Filter results by image type.Accepted values: "all", "photo", "illustration", "vector" | | orientation | "all" | Whether an image is wider than it is tall, or taller than it is wide.Accepted values: "all", "horizontal", "vertical" | | category | | Filter results by category.Accepted values: fashion, nature, backgrounds, science, education, people, feelings, religion, health, places, animals, industry, food, computer, sports, transportation, travel, buildings, business, music | | min_width | 0 | Minimum image width. | | min_height | 0 | Minimum image height. | | colors | | Filter images by color properties. A comma separated list of values may be used to select multiple properties.Accepted values: "grayscale", "transparent", "red", "orange", "yellow", "green", "turquoise", "blue", "lilac", "pink", "white", "gray", "black", "brown" | | editors_choice | "false" | Select images that have received an Editor's Choice award.Accepted values: "true", "false" | | safesearch | "false" | A flag indicating that only images suitable for all ages should be returned.Accepted values: "true", "false" | | order | "popular" | How the results should be ordered.Accepted values: "popular", "latest" | | page | 1 | Returned search results are paginated. Use this parameter to select the page number. | | per_page | 20 | Determine the number of results per page.Accepted values: 3 - 200 number. |

Example Configuration

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-pixabay',
      options: {
        key: process.env.PIXABAY_API_KEY,
        q: 'candy',
        image_type: 'photo',
        editors_choice: true,
        safesearch: true,
        order: 'popular',
        per_page: 200
      }
    }
  ]
};

Querying Pixabay Images

Once the plugin is configured, two new queries are available in GraphQL: allPixabayPhoto and pixabayPhoto.

Here’s an example query to load 10 images:

query PhotoQuery {
  allPixabayPhoto(limit: 10) {
    edges {
      node {
        largeImageURL
        pageURL
        tags
        user
      }
    }
  }
}

See the Pixabay API docs or the GraphiQL UI for info on all returned fields.