Source plugin for Netlify's API.
Please Note: This plugin was initially created to deliver data for my dashboard and hence only queries the user and sites. If you need more functionality, I'd be happy to review your PR and merge it into this plugin!
npm install gatsby-source-netlify
Go to OAuth applications and create a new access token ("Personal access tokens").
Save the API key in an environment file like:
NETLIFY_KEY=your-access-token-here
Add the plugin and define the API key.
require("dotenv").config();
module.exports = {
plugins: [
{
resolve: "gatsby-source-netlify",
options: {
apiKey: process.env.NETLIFY_KEY,
},
},
],
};
As per netlify/js-client you can also define options when passing the access token, for example:
module.exports = {
plugins: [
{
resolve: "gatsby-source-netlify",
options: {
apiKey: process.env.NETLIFY_KEY,
opts: {
userAgent: "netlify/js-client",
scheme: "https",
host: "api.netlify.com",
pathPrefix: "/api/v1",
globalParams: {}, // parameters you want available for every request.
// Global params are only sent of the open-api spec specifies the provided params.
},
},
},
],
};