January 7, 2026

#1 - GoRest CRUD APIs with curl

api-testingcurlhttp

Basics of HTTP and REST APIs

  1. RFC 9110: HTTP Semantics
  2. RFC 9112: HTTP/1.1
  3. Introduction To API
  4. Introduction to REST API

What is cURL?

cURL stands for Client URL. It is an open-source project focused on building reliable internet data-transfer tools and libraries.

curl — the command-line HTTP client

A powerful CLI tool used to:

  • Send HTTP requests (GET, POST, PUT, DELETE, etc.)
  • Work with headers, cookies, authentication, and payloads
  • Debug APIs and automate API testing

Command line options

  • --request or -X → HTTP method
  • --location or -L → follow redirects
  • --header or -H → add header
  • --dump-header or -D → dump response header
  • --include or -i → include headers in output
  • --output or -o → write body to file
  • --write-out or -w → write metadata
    • %{http_code}
    • %{time_total}
  • --data or -d → send request body
  • --json → JSON shortcut equivalent to -H "Content-Type: application/json" -d '{...}'
  • --silent or -s → silent mode
  • --show-error or -S → show error only
  • --verbose or -v → verbose output
  • --fail or -f → fail on HTTP error (exits with non-zero status on 4xx/5xx)
  • --retry → retries on transient failures (network errors or timeout)
    • --retry-delay → sleep duration in seconds before retry
  • --max-time → terminates request after N seconds

GoRest CRUD APIs

GoRest APIs

  1. GoRest — https://gorest.co.in/
  2. Get your access token from https://gorest.co.in/my-account/access-tokens

Setup

export API_TOKEN="<<gorest-access-token>>"
BASE_URI="https://gorest.co.in/public/v2"

List Users

Curl command

curl --location \
--request GET --silent --dump-header headers.txt --output response.json --write-out "Status Code: %{http_code}\n" --url "$BASE_URI/users"

Making GET request

GET request screenshot

Response headers

Response headers screenshot

Response body

Response body screenshot

Display user ids

User IDs display screenshot

Create User

Curl command — ensure that email id is unique

curl --location \
--request POST \
--header "Authorization: Bearer $API_TOKEN" \
--silent \
--dump-header headers.txt \
--output response.json \
--write-out "Status Code: %{http_code}\n" \
--url "$BASE_URI/users" \
--json '{
    "name": "Test User",
    "email": "test_user2@testing.example",
    "gender": "male",
    "status": "inactive"
}'

Create user request screenshot

Create user response screenshot

Create user response body screenshot

Get User

Curl command — update user id

curl --location \
--request GET \
--header "Authorization: Bearer $API_TOKEN" \
--silent \
--dump-header headers.txt \
--output response.json \
--write-out "Status Code: %{http_code}\n" \
--url "$BASE_URI/users/userId"

Get user request screenshot

Get user response screenshot

Get user response body screenshot

Update User

Curl command — update user id

curl --location \
--request PUT \
--header "Authorization: Bearer $API_TOKEN" \
--silent \
--dump-header headers.txt \
--output response.json \
--write-out "Status Code: %{http_code}\n" \
--url "$BASE_URI/users/userId" \
--json '{
    "status": "active"
}'

Update user request screenshot

Update user response screenshot

Update user response body screenshot

Delete User

Curl command — update user id

curl --location \
--request DELETE \
--header "Authorization: Bearer $API_TOKEN" \
--silent \
--dump-header headers.txt \
--output response.json \
--write-out "Status Code: %{http_code}\n" \
--url "$BASE_URI/users/userId"

Delete user request screenshot

Delete user response screenshot

Why start with cURL?

cURL forces you to understand the raw HTTP contract — endpoint structure, HTTP methods, headers, request payloads, response headers/body, and status codes. If you don't understand APIs at this level, automation will only hide problems, not solve them.

Limitations of cURL for API testing

cURL excels for manual exploration, debugging, and learning HTTP. However, it has significant constraints:

  • No built-in assertions (requires visual inspection)
  • Lacks test structure and organization
  • No reuse mechanism for tokens and base URLs
  • No automated reporting capabilities
  • Difficult CI/CD integration

These challenges break down fast once testing scales beyond basic use cases.

What's next in this series

Upcoming parts move from cURL to automated testing:

  • Migrate cURL logic to the Python requests library
  • Introduce the pytest test framework
  • Implement assertions on response structure and data
  • Refactor configuration (tokens, base URIs) into fixtures
  • Develop a maintainable API test framework

Originally published on Hashnode.