Access Keys:
Skip to content (Access Key - 0)

Using cURL to Interact with APIs

What is cURL?

cURL is a command-line utility (on Linux or Mac OS X) for interacting with URLs. It is useful for requesting data from APIs, which can then be processed programmatically. It can be invoked like this:

curl -X [REQUEST] -H '[HEADER]:[VALUE]' [URL]

where

  • [hd:REQUEST] is the HTTP request type (e.g. GET)
  • [hd:HEADER] and [hd:VALUE] are the name of a header (e.g. Authorization) and the content of that header (e.g. bearer 12345678). If you need to specify multiple headers, you may pass as many -H options as you need. (e.g. curl -X GET -H 'Thing:One' -H 'Fish:Red' ...)
  • URL is the url which you wish to access.

cURL Options

curl -s
  • “Silent mode” (normally, it prints out how many files it downloaded, and how fast)
curl -I
  • Display info (headers) only about a URL
  • Useful for examining HTTP status codes
curl -X [REQUEST]
  • Issue a [hd:REQUEST] method (POST, PUT, DELETE) instead of a GET
curl -H '[HEADER]:[VALUE]'
  • Attach a header to the request
  • Can be used multiple times to include multiple headers
curl -d “field=value”
  • Issue a POST request with this form data (repeat multiple times for multiple fields)

IS&T Contributions

Documentation and information provided by IS&T staff members


Last Modified:

January 23, 2015

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
Labels:
curl curl Delete
api api Delete
apis apis Delete
api's api's Delete
http http Delete
request request Delete
c-api c-api Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
Feedback
This product/service is:
Easy to use
Average
Difficult to use

This article is:
Helpful
Inaccurate
Obsolete
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki