Installing curl (for Windows)

The curl command, used in the Particle cloud examples is generally built-in on the Mac and Linux, but not Windows. These instructions explain how to install it.

Installation

Download

Download the files from https://curl.haxx.se/download.html. You generally want one of the two highlighted files, depending on whether you have 32-bit or 64-bit Windows:

  • Win32 Generic - Win32 zip 7.51.0 binary SSL SSH
  • Win64 Generic - Win64 x86_64 zip 7.51.0 binary SSL SSH

Click on the version number (7.51.0, for example) to download the file.

If you are unsure, this Microsoft knowledge base article on how to tell whether you have a 32-bit or 64-bit Windows installation may be helpful.

Download Options

You should also go to the page http://curl.haxx.se/docs/caextract.html. Right click on the link to cacert.pem and select Save Target to save the file to your Downloads folder.

Save Target

You first need to create a place to save your curl installation. I like to put the files in C:\Program Files\curl. In the Windows File Explorer:

  1. Select This PC
  2. Select your C: drive, called Windows 10 (C:) in this example, but your may be different.
  3. Double click Program Files

Create folder in program files

Right click on the right side of the window, select New then Folder.

Create folder in program files

Name the new folder curl. Then moved the files you downloaded into this directory.

Create curl directory in program files

Open the .zip file that you downloaded earlier. Inside the src folder should be the file curl.exe. Copy this into the new directory that you just created.

Copy curl.exe

Also copy the cacert.pem.htm file into the curl directory.

Copy cacert.pem.htm

Rename the cacert.pem.htm file to curl-ca-bundle.crt. You should get a warning about changing the filename extension. Click Yes.

Rename cacert.pem.htm

Depending on your system settings, the filename extension may be hidden. This will cause some problems. You can tell because the the curl program is just curl not curl.exe and also cacert.pem is of type HTML Document.

No filename extensions

One way to fix this is to just turn on filename extension viewing. Open the Control Panel and select Appearance and Personalization.

Apperance

Then Folder Options.

Folder Options

Click the View tab (1) and then deselect the checkbox for Hide extensions for known file types (2).

Hide Extension

Then you can finally rename the file curl-ca-bundle.crt and have it show up as type Security Certificate.

Rename

Editing the path - Windows 10

Click on the Windows Start menu, then the Settings (gear icon).

Start Settings

In the Windows 10 Settings window, type environment into the box at the top and select Edit the system environment variables.

Settings

Click the Environment Variables button at the bottom of the page.

Enviroment Variables

In the Environment Variables window, select Path in the bottom list (System variables) and click Edit.

Edit

In the Edit environment variable window, click New then enter a new row in the table, C:\Program Files\curl.

Edit New

After editing the system path environment variable you'll need to restart the computer.

Editing the path - Windows 7 and 8

You need to open the Control Panel.

Open Control Panel

And then click on System and Security.

System and Security

Then click System.

System and Secury

Then click on the Advanced System Settings link on the left side of the window.

Advanced Settings

Then click on Environment Variables...

Environment

Click on Path in the bottom list (System variables) and click Edit.

Finally, position the cursor at the end of the box and add to the end:

;C:\Program Files\curl

There must be a semicolon separating the new item from the previous last item, and then the path to the directory we just created.

Edit variable

After editing the system path environment variable you'll need to restart the computer or log out and log back in.

Testing

Most calls require an access token. At CLI, you can create by using

particle token create

Make sure you keep your token secret, because it allows access and control over all of your devices.

You should now be able to open a Command Prompt window and type in a command like:

curl https://api.particle.io/v1/devices?access_token=PASTE_YOUR_ACCESS_TOKEN_HERE

Also note: Many of the examples show a command that continues across lines with a backslash (\) at the end of the line. This is the correct character for Mac and Linux, but using the Windows Command Prompt you should use the carat (^) instead.