# eth_getFilterLogs

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://pharos-mainnet.g.alchemy.com/v2/{apiKey}

Returns an array of all logs matching the filter with the given ID (created using `eth_newFilter`).

Reference: https://www.alchemy.com/docs/chains/pharos/pharos-api-endpoints/eth-get-filter-logs

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Filter identifier | string | Yes | The ID of the filter to retrieve logs for. |

## Result

**Log objects** (string[] or object[]): An array of all log objects matching the filter since its creation.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getFilterLogs",
  "params": [
    "0x01"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": [
    {
      "logIndex": "0x0",
      "removed": false,
      "blockNumber": "0x233",
      "blockHash": "0xfc139f5e2edee9e9c888d8df9a2d2226133a9bd87c88ccbd9c930d3d4c9f9ef5",
      "transactionHash": "0x66e7a140c8fa27fe98fde923defea7562c3ca2d6bb89798aabec65782c08f63d",
      "transactionIndex": "0x0",
      "address": "0x42699a7612a82f1d9c36148af9c77354759b210b",
      "data": "0x0000000000000000000000000000000000000000000000000000000000000004",
      "topics": [
        "0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3"
      ]
    },
    {
      "logIndex": "0x0",
      "removed": false,
      "blockNumber": "0x238",
      "blockHash": "0x98b0ec0f9fea0018a644959accbe69cd046a8582e89402e1ab0ada91cad644ed",
      "transactionHash": "0xdb17aa1c2ce609132f599155d384c0bc5334c988a6c368056d7e167e23eee058",
      "transactionIndex": "0x0",
      "address": "0x42699a7612a82f1d9c36148af9c77354759b210b",
      "data": "0x0000000000000000000000000000000000000000000000000000000000000007",
      "topics": [
        "0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3"
      ]
    }
  ],
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://pharos-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getFilterLogs",
  "params": [
    "0x01"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'eth_getFilterLogs', params: ['0x01']})
};

fetch('https://pharos-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://pharos-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_getFilterLogs",
    "params": ["0x01"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://pharos-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getFilterLogs\",\n  \"params\": [\n    \"0x01\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://pharos-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getFilterLogs\",\n  \"params\": [\n    \"0x01\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://pharos-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"eth_getFilterLogs\",\n  \"params\": [\n    \"0x01\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: eth_getFilterLogs
description: Returns an array of all logs matching the filter with the given ID (created using `eth_newFilter`).
params:
  - name: Filter identifier
    required: true
    description: The ID of the filter to retrieve logs for.
    schema:
      title: hex encoded unsigned integer
      type: string
      pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
result:
  name: Log objects
  description: An array of all log objects matching the filter since its creation.
  schema:
    title: Filter results
    oneOf:
      - title: new block or transaction hashes
        type: array
        items:
          title: 32 byte hex value
          type: string
          pattern: ^0x[0-9a-f]{64}$
      - title: new logs
        type: array
        items:
          title: log
          type: object
          required:
            - transactionHash
          additionalProperties: false
          properties:
            removed:
              title: removed
              type: boolean
            logIndex:
              title: log index
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            transactionIndex:
              title: transaction index
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            transactionHash:
              title: transaction hash
              type: string
              pattern: ^0x[0-9a-f]{64}$
            blockHash:
              title: block hash
              type: string
              pattern: ^0x[0-9a-f]{64}$
            blockNumber:
              title: block number
              type: string
              pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
            address:
              title: address
              type: string
              pattern: ^0x[0-9a-fA-F]{40}$
            data:
              title: data
              type: string
              pattern: ^0x[0-9a-f]*$
            topics:
              title: topics
              type: array
              items:
                title: 32 hex encoded bytes
                type: string
                pattern: ^0x[0-9a-f]{64}$
examples:
  - name: eth_getFilterLogs example
    params:
      - name: Filter identifier
        value: '0x01'
    result:
      name: Log objects
      value:
        - logIndex: '0x0'
          removed: false
          blockNumber: '0x233'
          blockHash: '0xfc139f5e2edee9e9c888d8df9a2d2226133a9bd87c88ccbd9c930d3d4c9f9ef5'
          transactionHash: '0x66e7a140c8fa27fe98fde923defea7562c3ca2d6bb89798aabec65782c08f63d'
          transactionIndex: '0x0'
          address: '0x42699a7612a82f1d9c36148af9c77354759b210b'
          data: '0x0000000000000000000000000000000000000000000000000000000000000004'
          topics:
            - '0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3'
        - logIndex: '0x0'
          removed: false
          blockNumber: '0x238'
          blockHash: '0x98b0ec0f9fea0018a644959accbe69cd046a8582e89402e1ab0ada91cad644ed'
          transactionHash: '0xdb17aa1c2ce609132f599155d384c0bc5334c988a6c368056d7e167e23eee058'
          transactionIndex: '0x0'
          address: '0x42699a7612a82f1d9c36148af9c77354759b210b'
          data: '0x0000000000000000000000000000000000000000000000000000000000000007'
          topics:
            - '0x04474795f5b996ff80cb47c148d4c5ccdbe09ef27551820caa9c2f8ed149cce3'
```
