- Введение в curl и его установка
- О curl
- Установка curl
- Установка на MacOS
- Установка на Windows
- Создание тестового вызова API
- curl и Windows
- curl intro and installation
- About curl
- Installing curl
- Install curl on Mac
- Install curl on Windows
- Make a test API call
- Notes about using curl with Windows
- Using cURL with HTTP/2 on Mac OS X
- Instructions
- Learn how to install & run cURL on Windows/MacOSX/Linux
- What is cURL?
- Step-by-Step
- 1. Windows Installation
- 2. MacOSX Installation
- cURL for Mac
- Review
- Free Download
- specifications
- An open source command-line utility for macOS designed to help you transfer files from or onto a server, by using different protocols
- What’s new in cURL 7.79.1:
- Compile, build and install cURL
- Supports multiple transfer protocols
- Useful transfer tools
- Powerful file transfer solution for the command line
Введение в curl и его установка
Хотя Postman удобен, его трудно использовать для представления в документации, как совершать запросы с его помощью. Кроме того, разные пользователи, вероятно, используют разные клиенты с графическим интерфейсом или вообще не используют их (предпочитая командную строку)
Вместо того, чтобы описывать, как выполнять REST-запросы с использованием GUI-клиента, такого как Postman, наиболее традиционный метод документирования синтаксиса запроса — использовать curl.
О curl
curl — это утилита командной строки, которая позволяет выполнять HTTP-запросы с различными параметрами и методами. Вместо того, чтобы переходить к веб-ресурсам в адресной строке браузера, можно использовать командную строку, чтобы получить те же ресурсы, извлеченные в виде текста.
Note: Иногда curl пишется как cURL, что означает Client URL.
curl является более распространенным написанием, так что оба варианта верны.
Установка curl
curl доступен на MacOS по умолчанию, для Windows требуется установка. Ниже представлены инструкции по установке curl.
Установка на MacOS
Проверить установлен ли curl на MacOS можно так:
- Открываем Терминал (нажимаем Cmd + spacebar для открытия Спотлайт и вводим Terminal).
- В терминале пишем curl -V . Ответ должен быть примерно таким:
Если такого ответа нет, то curl необходимо скачать и установить
Установка на Windows
Установка curl в Windows включает другие шаги. Сначала определяем версию windows: 32-разрядная или 64-разрядная версия Windows, щелкнув правой кнопкой мыши Компьютер и выбрав Свойства . Затем следуем инструкциям на этой странице. Нужно выбрать одну из бесплатных версий с правами Администратора.
После установки проверяем версию установленной curl;
- Открываем командную строку нажав кнопку Пуск и введя cmd
- В строке пишем curl -V
Ответ должен быть примерно таким:
Создание тестового вызова API
После установки curl делаем тестовый вызов API
В ответ должен вернуться минимизированный JSON:
curl и Windows
Если вы используете Windows, обратите внимание на следующие требования к форматированию при использовании curl:
- Используйте двойные кавычки в командной строке Windows. (Windows не поддерживает одинарные кавычки.);
- Не используйте обратную косую черту \ для разделения строк. (Это только для удобства чтения и не влияет на вызов на Mac.)
- Добавив -k в команду curl, вы можете обойти сертификат безопасности curl, который может быть необходимым.
Источник
curl intro and installation
While Postman is convenient, it’s hard to use it to represent how to make calls with it in your documentation. Additionally, different users probably use different GUI clients, or none at all (preferring the command line instead).
Instead of describing how to make REST calls using a GUI client like Postman, the most conventional method for documenting request syntax is to use curl.
About curl
curl is a command-line utility that lets you execute HTTP requests with different parameters and methods. Instead of going to web resources in a browser’s address bar, you can use the command line to get these same resources, retrieved as text.
Sometimes curl is written as cURL. It stands for Client URL. “curl” is the more common convention for its spelling, but both refer to the same thing.
Installing curl
curl is usually available by default on Macs but requires some installation on Windows. Follow these instructions for installing curl:
Install curl on Mac
If you have a Mac, by default, curl is probably already installed. To check:
- Open Terminal (press Cmd + spacebar to open Stoplight, and then type “Terminal”).
In Terminal type curl -V . The response should look something like this:
If you don’t see this, you need to download and install curl.
Install curl on Windows
Installing curl on Windows involves a few more steps. First, determine whether you have 32-bit or 64-bit Windows by right-clicking Computer and selecting Properties. Then follow the instructions in this Confused by Code page. Most likely, you’ll want to choose the With Administrator Privileges (free) installer.
After you install curl, test your version of curl by doing the following:
- Open a command prompt by clicking the Start button and typing cmd.
- Type curl -V .
The response should be as follows:
Make a test API call
After you have curl installed, make a test API call:
(In the above code, replace APIKEY with your actual API key.)
You should get minified JSON response back like this:
In Windows, Ctrl+ V doesn’t work; instead, you right-click and then select Paste.
Notes about using curl with Windows
If you’re using Windows, note the following formatting requirements when using curl:
- Use double quotes in the Windows command line. (Windows doesn’t support single quotes.)
- Don’t use backslashes ( \ ) to separate lines. (This is for readability only and doesn’t affect the call on Macs.)
- By adding -k in the curl command, you can bypass curl’s security certificate, which may or may not be necessary.
Источник
Using cURL with HTTP/2 on Mac OS X
cURL is one of the most powerful tool for testing HTTP requests and responses. Most developers use curl to interact with HTTP APIs or to test a website.
Starting from version 7.43.0 cURL (and libcurl ) supports HTTP/2. You can perform a request using the HTTP/2 protocol passing the —http2 flag:
However, in order to support HTTP/2, cURL must be linked to nghttp and the default cURL version shipped with Mac OS X does not. As a result, if you try to pass the —http2 flag you’ll receive the following error:
To solve the issue and use cURL with HTTP/2 in Mac OS X your need to recompile cURL. This is a very easy task if you use Homebrew. Thanks to this PR you can reinstall cURL via Homebrew and pass the —with-nghttp2 flag to add the HTTP/2 support along with the necessary dependencies.
Almost done. By default, Homebrew will not replace the curl binary shipped with Mac OS X, therefore you need to explicitly «link» it if you want to use the new version without specifying the entire path to the binary (which by the way is /usr/local/Cellar/curl/7.46.0/bin/curl ):
Close/reopen the shell and the curl location should now be:
You can also confirm the version and the custom flag using the command brew info curl :
If it’s still /usr/bin/curl then make sure cURL was properly installed via Homebrew and you restarted your shell.
Instructions
To recap, here’s the list of commands to compile and install cURL with HTTP/2 support in Mac OS X using Homebrew:
A special thanks to Daniel Stenberg for cURL, and to @felixbuenemann for the Homebrew patch that made it possible to install cURL with HTTP/2 with zero effort.
Источник
Learn how to install & run cURL on Windows/MacOSX/Linux
What is cURL?
cURL is a command-line tool that lets you transfer data to/from a server using various protocols. In this case, the curl command will establish a communication to POST or GET data to/from Ubidots Server over HTTP and HTTPS.
Below you will find the step-by-step to installing cURL in Windows, MacOSX and Linux.
Step-by-Step
1. Windows Installation
1. Enter and access the URL https://curl.haxx.se/ to download the curl executable wizard.
2. Select «curl executable» as Type of Package.
3. Then, on the «Select Operating System» section, select Windows. Then, continue selecting the parameters required based on your version of Windows.
4. Once you’ve finished the on-screen steps, download the zip file generated. To download it, simply press «Download«.
5. Next, open the .zip file and enter to the folder called «src*». Inside the src folder you will find the curl executable file. At this point, you need to copy the executable file and paste it inside a local folder on your PC to be able to run the curl.
NOTE: To get a better understanding of the following steps, let’s assume the executable file is located inside a folder named «programs«.
6. From the Command Prompt, enter to the location where the executable file was pasted. To enter to the folder you need to use the cd command following the location of the folder which contains the executable file as you can see below.
Expected location to be shown
7. To verify if you are able to run curl commands with the command prompt, test functionality by executing the command below:
At this point, you should receive the all the help info related to the curl command.
[Troubleshooting] If you experience errors in the downloading process, please refer to this video for additional troubleshooting.
Now you are able to use cURL from your Windows pc!
2. MacOSX Installation
1. Enter to the computer’s terminal.
2. Run the command below in the terminal:
3. If a password is required after running the command, please enter your Mac’s user password to continue. Then, wait until the installation finish.
4. Run the command below in the terminal:
Now you are able to use cURL from your Mac pc!
3. Linux installation
1. Enter to the computer’s terminal.
2. Run the command below in the terminal:
3. If a password is required after ran the command, please enter your computers’ user password to continue. Then, wait until the installation finishes.
Now you are able to use cURL from your Linux pc!
Источник
cURL for Mac
Review
Free Download
specifications
An open source command-line utility for macOS designed to help you transfer files from or onto a server, by using different protocols
What’s new in cURL 7.79.1:
- Bugfixes:
- Curl_http2_setup: don’t change connection data on repeat invokes
- curl_multi_fdset: make FD_SET() not operate on sockets out of range
Read the full changelog
cURL is an open source project that offers you the possibility to quickly transfer data to and from a server via command line. Most of the transfer related capabilities are powered by the libcurl library.
Compile, build and install cURL
cURL does not come as a binary which means that you must use the files included in the archive to compile and build the app. To get started, open the Terminal.app and navigate to the cURL folder (will be generated when you open the archive).
The next step is to use the “./configure —with-darwinssl” command (cURL is able to use the Apple SSL / TLS implementation), wait until cURL puts everything in place, and then run the “make” command. If everything does smoothly, you will now be able to use the cURL command in your Terminal.
To learn more about all the possibilities and tools provided by cURL you can use the “cURL — h” command and view all the usage options. Note that the cURL archive also includes detailed installation and usage documentation.
Supports multiple transfer protocols
cURL is able to work with a wide range of transfer protocols, such as FTP, FTPS, HTTP, HTTPS, IMAP, IMAPS, TELNET, TFTP, DICT, FILE, GOPHER, LDAP, LDAPS, POP3, POP3S, SMTP, SMTPS, SFTP, SCP, RTMP, and RTSP.
Useful transfer tools
cURL includes basic file transfer capabilities, such as the fact that it is able to use proxies, SSL connections, cookies, file transfer resumes, or metalinks.
However, the command line utility also provides useful tricks designed to improve your experience: cURL tries to guess the correct protocol if not provided, to re-use server connections to improve speed, allows you to adjust the progress display and more.
Powerful file transfer solution for the command line
cURL proposes simple yet efficient tools for quickly transferring data to and from a server by using the command line. In addition, the app includes several tricks that can help you improve the transfer rate and more.
Источник