---
# System prepended metadata

title: zkSync API Reference

---

# zkSync API Reference
## Overview
This is a version 2 of the Users - Transaction API provided by Matter Labs

## API Basics
The API gives you access to features and allows you to extend them for use in your application. It strives to be RESTful and is organized around the main resources you would interact with.

> *Note:* Before you do anything ensure you have obtained your secret keys.

### Authentication
Authenticate your API calls by including your secret key in the Authorization header of every request you make. This is achieved by using the **api_secret_key**, which would be added to the request on send.

### Headers
The accepted headers for this endpoint includes:

| Key | value |
|--------|-------------|
| `Content-type` | `application/json` |
| `api_secret_key` | `xxxx-xxxx-xxxx` |


## Get Users Transaction 
This endpoint returns the list of transactions carried out by the users.
### Request 

```bash
# cUrl Version
curl --location 
  --request GET 'https://zksync2-testnet.zksync.dev/v2/users/transactions?module=account&address=0x0614BB23D91625E60c24AAD6a2E6e2c03461ebC5&startblock=0&endblock=100000&page=1&offset=5&sort=desc' \
  --header 'Content-Type: application/json' \
```

```js
// JavaScript Fetch API Version
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
};

fetch("https://zksync2-testnet.zksync.dev/v2/users/transactions?module=account&address=0x0614BB23D91625E60c24AAD6a2E6e2c03461ebC5&startblock=0&endblock=100000&page=1&offset=5&sort=desc", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```
#### Query Params

| Params | Description |
|--------|-------------|
| startblock | The **integer** block number to start searching for transactions. |
| endblock | The **integer** block number to stop searching for transactions. |
| address | The **string** represents the addresses to check for the balance. |
| offset | The number of transactions displayed per page. |
| sort | For the sorting preference, use **asc** to sort by ascending and **desc** to sort by descending. |
| page | The **integer** page number if pagination is enabled. |

### Response
#### Ok
```json
{
   "status":"success",
   "message":"OK",
   "result": [
      {
         "blockNumber":"2535368",
         "timeStamp":"1477837690",
         "hash":"0x8a1a9989bda84f80143181a68bc137ecefa64d0d4ebde45dd94fc0cf49e70cb6",
         "from":"0x20d42f2e99a421147acf198d775395cac2e8b03d",
         "to":"",
         "value":"0",
         "contractAddress":"0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3",
         "input":"",
         "type":"create",
         "gas":"254791",
         "gasUsed":"46750",
         "traceId":"0",
         "isError":"0",
         "errCode":""
      },
      ...
   ]
}
```
| Parameter | Description |
|-----------|-------------|
| blockNumber | This is the block identifier |
| timeStamp | This is the time the block was created |

#### Error
```json
{
  "status": "failed",
  "result": { /* response */ },
  "error": {
    "errorType": "authentication_failed",
    "code": 401,
    "message": "Invalid Secret Keys"
  }
}
```
```json
{
    "status": "failed",
    "result": {
        "code": 500,
        "message": "server error"
    }
}
```
```json
{
    "status": "failed",
    "result": {
        "code": 422,
        "errorType": "validation_error",
        "errors" : [
            {
                "message": "invalid enum for field 'module' ",
                "field": "module"
            }
            ]
    }
}
```

```json
{
    "status": "failed",
    "result": {
        "code": 400,
        "errorType": "unprocessable entity",
        "message": "invalid transaction user"
    }
}
```
```
| Parameter | Description |
|-----------|-------------|
| errorType | This provides more descriptive information about the error type |
| code | The **code** may include `400`, `500`, `401` |
| message | This is the error message from the endpoint |