🍕
Spot
  • 🍕Spot
  • 🔥Sub
  • 🌊Stream
  • 🏦Vault
  • ⚡Spot
  • 👻GhostTag
    • GhostTag
    • API
  • Contracts
    • Contracts
    • Stream and Sub
    • Vault
  • Page
Powered by GitBook
On this page
  1. GhostTag

API

Detailed Developer Guide for Using api.ghosttag.xyz/v1/getTransactions

Endpoint Overview

The api.spot.pizza/v1/getTransactions endpoint allows developers to fetch Ethereum transaction tag data filtered by various parameters.

Base URL

https://api.ghosttag.xyz/v1/getTransactions

Supported Query Parameters

  • address: Filter by transactions involving this address (either sender or receiver).

  • fromBlock: Filter by transactions starting from this block number.

  • toBlock: Filter by transactions up to this block number.

  • txHash: Filter by a specific transaction hash.

  • fromTime: Filter by transactions from this timestamp (seconds since Unix epoch).

  • toTime: Filter by transactions up to this timestamp (seconds since Unix epoch).

  • chainId: Filter by chain ID (e.g., 1 for Ethereum mainnet).

  • dataHex: Filter by transactions containing this hexadecimal data.

  • dataString: Filter by transactions containing this string data.

  • key: Filter by transactions containing this specific key in the parsed data.

  • fromAddress: Filter by transactions from this address.

  • toAddress: Filter by transactions to this address.

  • tag: Filter by transactions containing this tag in the string data.

Making Requests

Using axios in Node.js

First, install axios if you haven't already:

bashCopy codenpm install axios

Create a script to fetch transactions:

const axios = require('axios');

async function fetchTransactions() {
    try {
        const response = await axios.get('https://api.spot.pizza/v1/getTransactions', {
            params: {
                address: '0xYourAddress',
                fromBlock: 1000,
                toBlock: 2000,
                chainId: 1,
                fromTime: Math.floor(new Date('2023-01-01').getTime() / 1000),
                toTime: Math.floor(new Date('2023-01-31').getTime() / 1000),
                dataString: 'yourDataString'
            }
        });
        console.log(response.data);
    } catch (error) {
        console.error('Error fetching transactions:', error);
    }
}

fetchTransactions();

Using Fetch API in Browser

javascriptCopy codeasync function fetchTransactions() {
    const url = new URL('https://api.spot.pizza/v1/getTransactions');
    const params = {
        address: '0xYourAddress',
        fromBlock: 1000,
        toBlock: 2000,
        chainId: 1,
        fromTime: Math.floor(new Date('2023-01-01').getTime() / 1000),
        toTime: Math.floor(new Date('2023-01-31').getTime() / 1000),
        dataString: 'yourDataString'
    };

    Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));

    try {
        const response = await fetch(url);
        const data = await response.json();
        console.log(data);
    } catch (error) {
        console.error('Error fetching transactions:', error);
    }
}

fetchTransactions();

Example Response

A successful response from the API will return a JSON array of transactions that match the specified filters. Each transaction object may contain the following fields:

  • chainId: The ID of the blockchain network.

  • blockNumber: The block number of the transaction.

  • hash: The transaction hash.

  • from: The sender's address.

  • to: The receiver's address.

  • value: The value transferred in the transaction (in ETH).

  • timestamp: The timestamp of the transaction.

  • dataHex: The transaction data in hexadecimal format.

  • dataString: The transaction data in string format.

  • dataParsed: The parsed data from the transaction.

Example:

[
  {
    "timestampAdded": "2024-06-16T17:18:58.000Z",
    "chainId": 8453,
    "blockNumber": 15884494,
    "hash": "0x627735e5dfee8539cbd1a29e3fe89a59839f3ab3ae4f630ba0711f6816339eb3",
    "from": "0x14b214ca36249b516b59401b3b221cb87483b53c",
    "to": "0xdd528829749d6a4656d84cddbdc65e7dc5b350a7",
    "value": 0,
    "timestamp": "2024-06-16T17:18:55.000Z",
    "dataHex": "0x1337",
    "dataString": "\u00137",
    "dataParsed": "{}"
  },
  {
    "timestampAdded": "2024-06-16T17:18:34.000Z",
    "chainId": 8453,
    "blockNumber": 15884482,
    "hash": "0xba5f4f70d3cab08142fb8ff352d1ee82f96a0a91f0c90f3dd9e4aa4308a64510",
    "from": "0x14b214ca36249b516b59401b3b221cb87483b53c",
    "to": "0xdd528829749d6a4656d84cddbdc65e7dc5b350a7",
    "value": 0,
    "timestamp": "2024-06-16T17:18:31.000Z",
    "dataHex": "0x6c6f6c",
    "dataString": "lol",
    "dataParsed": "{}"
  },
  {
    "timestampAdded": "2024-06-16T17:17:33.000Z",
    "chainId": 8453,
    "blockNumber": 15884451,
    "hash": "0x7e02a6aef33120974ae95e8079983b3b48f575e15d6318eedcb5f5bf5d4bef8e",
    "from": "0x14b214ca36249b516b59401b3b221cb87483b53c",
    "to": "0xdd528829749d6a4656d84cddbdc65e7dc5b350a7",
    "value": 0,
    "timestamp": "2024-06-16T17:17:29.000Z",
    "dataHex": "0x7b2274616731223a226273222c2274616732223a226c6f6c227d",
    "dataString": "{\"tag1\":\"bs\",\"tag2\":\"lol\"}",
    "dataParsed": "{\"tag1\": \"bs\", \"tag2\": \"lol\"}"
  }
]

Error Handling

If the request fails, the API will return an error response. Common error codes include:

  • 400 Bad Request: Invalid query parameters.

  • 404 Not Found: No transactions match the specified filters.

  • 500 Internal Server Error: An unexpected server error occurred.

Conclusion

Using the getTransactions endpoint of the api.spot.pizza service, developers can fetch and filter Ethereum transactions based on various parameters. This guide provides the necessary information to make successful requests and handle responses.

PreviousGhostTagNextContracts

Last updated 10 months ago

👻