Back

Netlify API Essential Guide

Aug 12, 20246 minute read

What type of API does Netlify provide?

Netlify offers multiple types of APIs:

  1. REST API: Netlify's main API is a REST-style API that uses JSON for serialization and OAuth 2 for authentication. This is the primary API for interacting with Netlify's services programmatically.

  2. GraphQL API: Netlify Connect provides a unified GraphQL API that allows you to bring together content from multiple data sources. This GraphQL API is specifically for accessing unified content through Netlify Connect, rather than being the main API for Netlify's core services.

  3. Webhooks: Netlify can trigger webhooks on certain events, which is another way to integrate with their platform.

To summarize:

  • Netlify's core API is a REST API
  • They also offer a GraphQL API through Netlify Connect for content unification
  • Webhooks are available for event-driven integrations

The REST API is the primary method for interacting with Netlify's services, while the GraphQL API is a specialized offering for content management through Netlify Connect. Netlify does not appear to offer a SOAP API.

Does the Netlify API have webhooks?

Yes, the official Netlify API does support webhooks. Here are the key points about Netlify webhooks:

Webhook Support

  • Netlify provides webhook functionality through their API.
  • Webhooks allow you to receive notifications when certain events occur on your Netlify site.

Event Types

You can subscribe to the following types of events with Netlify webhooks:

  • Deploy events (when a deploy starts, succeeds, fails, etc.)
  • Form submission events
  • Site creation/deletion events
  • Domain management events
  • Build events

Setting Up Webhooks

  • You can configure webhooks through the Netlify API using the /hooks endpoint.
  • Webhooks can be set up to send HTTP POST requests to a URL you specify when events occur.

Webhook Payload

  • The webhook payload will contain details about the event that occurred.
  • You can inspect the payload to determine the type of event and take appropriate actions.

Best Practices

  • Use webhooks to automate workflows and integrate Netlify with other systems.
  • Secure your webhook endpoint to ensure only legitimate Netlify requests are processed.
  • Consider using Netlify Functions to handle webhook events in a serverless manner.

In summary, Netlify's API provides robust webhook support, allowing you to subscribe to a variety of event types and automate processes based on those events. This can be very useful for integrating Netlify deployments and other site activities into your broader development and operations workflows.

Rate Limits and other limitations

Here are the key points about the API rate limits for Netlify:

General API Rate Limits

  • Most API requests are limited to 500 requests per minute.

  • You can check your current rate limit status in the HTTP headers of any API response:

    X-RateLimit-Limit: 500
    X-RateLimit-Remaining: 56 
    X-RateLimit-Reset: 1372700873
    

Specific Operation Limits

  • Deploying through the API is limited to:
    • 3 times per minute
    • 100 times per day

Netlify Identity Rate Limits

  • For Netlify Identity, there is a limit of 30 requests per 5 minutes per IP address.

Key Considerations

  • Rate limits are in place to protect Netlify from automated deploys or misbehaving applications.

  • The limits apply globally rather than by region, unless specific regional conditions are added.

  • There may be a short delay (less than a second) between when a limit is reached and when it's enforced.

  • For Enterprise plans, custom rate limiting rules can be configured.

Best Practices

  • Monitor your API usage and stay within the limits.

  • Use caching and optimize API calls where possible.

  • For high-volume needs, consider Enterprise plans for custom limits.

  • Be aware of potential issues with shared IP addresses (e.g. VPNs) hitting limits faster.

In summary, while Netlify provides generous limits for most operations, it's important to be aware of these limits, especially for high-traffic applications or when using Netlify Identity. For specific high-volume needs, reaching out to Netlify support or considering Enterprise options may be necessary.

Latest API Version

The most recent version of the Netlify API is 2.34.0.

Key points to consider:

  • Netlify provides a REST-style API that uses JSON for serialization and OAuth 2 for authentication.

  • The API allows developers to handle atomic deploys of websites, manage form submissions, inject JavaScript snippets, and perform various other tasks related to Netlify's hosting service.

  • The API documentation is available as an OpenAPI reference that developers can explore.

  • Netlify regularly updates its platform and API with new features and improvements, as evidenced by their changelog.

API Usage:

  • The base URL for API requests is https://api.netlify.com/api/v1.

  • Developers can interact with various endpoints, such as /sites, /deploys, /hooks, and more, to manage different aspects of their Netlify projects.

  • The API supports operations like creating and managing sites, handling deployments, working with environment variables, and managing files.

Best practices:

  1. Always refer to the latest API documentation for the most up-to-date information on endpoints and features.

  2. Use authentication tokens securely and avoid exposing them in client-side code.

  3. Be aware of rate limits and implement proper error handling in your API requests.

  4. Keep an eye on the Netlify changelog for updates and new features that might be relevant to your projects.

  5. Consider using the Netlify SDK or community-developed tools like n8n.io's Netlify node for easier interaction with the API.

It's worth noting that while the API version is 2.34.0, Netlify uses a versioning system for specific features within their Frameworks API. This allows for backward compatibility as new features are introduced.

How to get a Netlify developer account and API Keys?

To get a developer account for Netlify to create an API integration, you can follow these steps:

1. Create a Netlify account

If you don't already have one, sign up for a Netlify account at https://app.netlify.com/signup.

2. Generate a personal access token

To authenticate API requests, you'll need to generate a personal access token:

  1. Log in to your Netlify account
  2. Go to User Settings > Applications > Personal access tokens
  3. Click "New access token"
  4. Enter a description for the token
  5. Select permissions and expiration as needed
  6. Copy and securely store the generated token

3. Set up your development environment

To start developing an integration:

  1. Install Node.js if you haven't already
  2. Install the Netlify CLI: npm install netlify-cli -g
  3. Authenticate the CLI with your Netlify account: netlify login

4. Create a new integration

You have two options to create a new integration:

Option A: Use the guided CLI setup

Run:

npx create @netlify/sdk@latest

Follow the prompts to configure your integration.

Option B: Use an integration template

Go to the Netlify integration templates and click "Deploy to Netlify" on one of the templates. This will create and deploy a sample integration.

What can you do with the Netlify API?

Here's the markdown text with the trailing list of URLs and citation references removed, and any URLs inside the content formatted correctly for the markdown file format:

Here's a list of data models you can interact with using the Netlify API, along with what is possible for each:

Sites

  • Create new sites
  • Get site details
  • Update site settings
  • Delete sites
  • Get all sites for a team
  • Deploy sites
  • Cancel ongoing deployments

Deployments

  • Create new deployments
  • Get deployment details
  • List deployments for a site
  • Cancel ongoing deployments

Forms

  • Get form submissions
  • Delete form submissions
  • Export form data

Build Hooks

  • Create build hooks
  • Trigger builds via hooks
  • Delete build hooks

Environment Variables

  • Set environment variables
  • Get environment variable values
  • Update environment variables
  • Delete environment variables

Deploy Keys

  • Create deploy keys
  • Get deploy key details
  • Delete deploy keys

Split Testing

  • Create split tests
  • Update split test settings
  • Get split test data
  • Stop split tests

Functions

  • Upload function files
  • Get function details
  • Invoke functions

Identity

  • Manage users (create, update, delete)
  • Get user details
  • Manage roles and permissions

Snippets

  • Create code snippets
  • Update snippet content
  • Delete snippets
  • Get snippet details

Webhooks

  • Create webhooks
  • Update webhook settings
  • Delete webhooks
  • Get webhook details

Teams

  • Get team details
  • Manage team members
  • Update team settings

DNS

  • Manage DNS records
  • Get DNS zone details

Audit Logs

  • Retrieve audit log entries

The Netlify API allows you to programmatically manage most aspects of your Netlify sites and account. This includes core site functionality, deployments, forms, serverless functions, user management, and more.