Cancel

Netlify Cheatsheets

Netlify Cheatsheets

Netlify is where you can host your static site free of charge with Free Let’s Encrypt SSL/TLS certificate and free CloudFront. Click here to use Netlify’s API via CURL command.

Useful Commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
netlify init # for initializing new project
netlify login # for login if you have credentials
netlify link # Link your local current project to Netlify site/app

# Create an empty site/app
netlify sites:create

# Delete a site/app
netlify sites:delete SITE_ID

# List all sites you have access to
netlify sites:list

# Open site/app
netlify open --site

# Open admin panel
netlify open --admin

# Deploy local site/app to production, If you are logged in
netlify deploy --message "A message with Commit ID" --open --prod

# If you have Netlify Access Token, and don't have login credentials
export NETLIFY_AUTH_TOKEN=YOUR_TOKEN
netlify deploy --message "A message with Commit ID" --open --prod --auth $NETLIFY_AUTH_TOKEN

# Show list of Netlify APIs
# https://open-api.netlify.com/#operation/listSites
# https://docs.netlify.com/api/get-started/#make-a-request
netlify api --list

Netlify CRUD Operation via CURL

  1. CRUD stands for Create/POST, Read/GET, Update/PUT and Delete/DELETE.
  2. Netlify Cheatsheets can be found here https://deletify.app/tech-world/learn-real-power-of-curl-command-with-cheatsheets.md/
1
2
NETLIFY_TOKEN=<YOUR_TOKEN>
NETLIFY_API_URL=https://api.netlify.com/api/v1/sites

GET

1
2
3
4
5
6
7
8
9
10
11
12
13
# return all items
curl \
  -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NETLIFY_TOKEN" \
  $NETLIFY_API_URL

# return single item only
curl \
  -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NETLIFY_TOKEN" \
  $NETLIFY_API_URL/{add_site_id}

POST

1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NETLIFY_TOKEN" \
  $NETLIFY_API_URL \
  # -d "`cat ./data.json`"
  -d '{
    "name": "NAME",
    "custom_domain": "DOMAIN",
    "force_ssl": true, // use only if you have certificate installed by netlify
    "processing_settings": {
      "skip": false
    }
  }'

PUT

1
2
3
4
5
6
curl \
  -X PUT \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NETLIFY_TOKEN" \
  $NETLIFY_API_URL/{add_site_id} \
  -d '{"name": "NEW NAME"}'

DELETE

1
2
3
4
5
curl \
  -X DELETE \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NETLIFY_TOKEN" \
  $NETLIFY_API_URL/{add_site_id}