# curl

The [Client Uniform Resource Locator (curl)](https://curl.se/) command line tool sends API requests via URLs and returns responses.&#x20;

Requests to Paralinker APIs commonly use curl.&#x20;

{% hint style="info" %}
We recommend the resource [*Everything curl*](https://everything.curl.dev).
{% endhint %}

### Install curl

Your operating system may include curl, or you may need to download and install it.

Check the ["Get curl" chapter of *Everything curl*](https://everything.curl.dev/get) for the best way to install curl for your operating system.

### curl commands

Many Paralinker requests take the form:

```bash
curl https://eth-mainnet.paralinker.com/api/v1/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}'
```

The code snippet above is an API call to Ethereum mainnet endpoint.&#x20;

It requests the latest block number using the method `eth_blockNumber`.

### curl analysis

Let's step through each line of the code snippet to understand what's happening.&#x20;

The first line uses the `curl` command to send a request to the URL `https://eth-mainnet.paralinker.com/v1/`YOUR-API-KEY.&#x20;

#### curl command

```bash
curl https://eth-mainnet.paralinker.com/api/v1/YOUR-API-KEY \
```

{% hint style="info" %}
Replace `YOUR-API-KEY` with a specific Web3 [API key](https://paralinker.gitbook.io/paralinker-docs/learn/broken-reference).
{% endhint %}

#### -X flag

The `-X` flag specifies a common [HTTP method](https://www.w3schools.com/tags/ref_httpmethods.asp).&#x20;

```bash
-X POST \
```

#### -H flag

The `-H` or `--header` flag specifies [header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) information.&#x20;

The example specifies the `Content-Type` to be `application/json` which means the requested resource is a JavaScript Object Notation (JSON) object.

```bash
-H "Content-Type: application/json" \
```

#### -d flag

The `-d` or `--data` flag specifies more information sent along with the curl request.

In the example, the data object is a list of key value pairs in JSON format. This follows the [JSON RPC 2.0 specification ](https://www.jsonrpc.org/specification)which requires the four specific keys seen here.&#x20;

The `method` , `params` , and `id` values are modifiable.&#x20;

The `jsonrpc` value is required by the specification.

```bash
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params": [],"id":1}'
```

#### Running curl

Enter curl code in a terminal window, or a command line tool from your computer's operating system and click return.

#### Output

curl returns a response object if the request is successful.

```bash
{"jsonrpc":"2.0","id":3,"result":"0xe0a763"}
```

{% hint style="info" %}
For more information, *Everything curl* has a [useful cheat sheet on curl and HTTP](https://everything.curl.dev/http/cheatsheet).
{% endhint %}
