Curl GET Request Examples

Copy and modify these curl commands for your API testing needs

Just click any example to copy it to your clipboard, then paste and customize for your use case

Basic GET Request

Simple GET request to fetch articles

curl "https://example.com/articles"

JSON:API with Accept Header

Request JSON:API format data with proper content type

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles"

GET with Authorization

Authenticated request to protected JSON:API endpoint

curl -H "Accept: application/vnd.api+json" \
     -H "Authorization: Bearer your-api-token" \
     "https://api.example.com/articles"

GET Specific Resource

Fetch a single article by ID

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles/1"

GET Related Resources

Fetch related author data for an article

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles/1/author"

GET with Pagination

Request paginated results with offset

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles?page[offset]=2&page[limit]=10"

GET with Filtering & Sorting

Filter articles by author and sort by date

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles?filter[author]=john&sort=-created"

GET with Include Parameter

Include related resources in response

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles?include=author,comments"

GET Relationship Endpoints

Fetch relationship data between resources

curl -H "Accept: application/vnd.api+json" \
     "https://example.com/articles/1/relationships/comments"

GitHub API Example

Real-world GitHub API request with authentication

curl -H "Accept: application/vnd.github.v3+json" \
     -H "Authorization: token your-github-token" \
     "https://api.github.com/user/repos"

How to Use Curl for API Testing

curl is an essential command-line tool for developers to transfer data and test network endpoints. It allows you to simulate requests that a browser or application would make to a server, making it perfect for debugging APIs or fetching data directly from the terminal.

You can test connections to specific servers, inspect HTTP headers, and verify API responses without writing any code. Understanding how to target servers is fundamental, which often involves knowing about IP address classes and network configurations. Our examples provide a practical starting point for any GET request you need to make.

Essential Curl Options

Content Types

application/vnd.api+jsonJSON:API
application/jsonStandard JSON
application/vnd.github.v3+jsonGitHub API

Authentication

-u user:passBasic auth
-H "Authorization: Bearer token"Bearer
-H "X-API-Key: key"API key

Options

-vVerbose output
-iInclude headers
-LFollow redirects
--max-time 30Timeout

JSON:API Standard: The application/vnd.api+json media type is the official JSON:API specification from jsonapi.org - use it for standardized API responses with relationships, pagination, and filtering.

Common GET Request Patterns

JSON:API Testing

Test JSON:API compliant endpoints with proper media type:

curl -H "Accept: application/vnd.api+json" "https://example.com/articles"

Resource Relationships

Fetch related resources with JSON:API include parameter:

curl -H "Accept: application/vnd.api+json" "https://example.com/articles?include=author,comments"

Pagination & Filtering

Use JSON:API pagination and filtering patterns:

curl -H "Accept: application/vnd.api+json" "https://example.com/articles?page[offset]=2&filter[author]=john"

Frequently Asked Questions

What's the simplest curl GET request?

Just curl "https://example.com". Curl defaults to GET requests, so no flags needed.

Where can I find curl examples online?

Our curl example generator provides ready-to-use commands for JSON:API, authentication, pagination, and more. Copy any example and modify for your needs.

How do I add headers to curl requests?

Use -H "Header: Value" for each header. Multiple -H flags are allowed for different headers.

Can I test curl commands online?

Yes! Use our online curl generator to build and test commands. Copy examples for JSON:API, authentication, and debugging - perfect for testing APIs without installing curl locally.

What are the best curl examples for beginners?

Start with basic GET requests, then add headers for APIs. Our examples cover authentication, JSON:API pagination, and debugging - perfect for learning curl step by step.

How do I debug failed curl requests?

Add -v for verbose output, or -i to see response headers and status codes.

What curl online tools are available?

Online curl generators help build commands without memorizing syntax. Our tool provides copy-paste examples for JSON:API, authentication, and common use cases.

How do I handle authentication with curl?

Use -u user:pass for basic auth, -H "Authorization: Bearer token" for API tokens.

What are common curl GET request examples?

Most common examples include API testing with headers, authentication, pagination, and fetching JSON data. Our examples cover real-world patterns developers use daily.

Why use quotes around URLs in curl?

URLs often contain special characters like & or ? that shells interpret. Quotes prevent this interpretation and ensure the URL is passed correctly to curl.

Should I follow redirects with curl?

Usually yes - add -L to follow redirects automatically. Most web services expect this for proper API responses.

How do I use curl for API testing?

Set proper headers like Accept: application/json, add authentication, and use -i to see response headers and status codes.