Data Types

Timestamps

Unless otherwise specified, all timestamps from the API are returned as milliseconds in UNIX Epoch time, and all timestamps are expressed in UTC.


Values

Unless otherwise specified, all values and balances returned will be in the lowest denomination of the blockchain. For instance, with the Ethereum blockchain all values will be in wei.

There is a field throughout the different endpoints called timestampNanoseconds, which we've added in preparation for blockchains with faster block times. None of the Ethereum blockchains have nanoseconds or even microsecond granularity, which is why it's always returned "0". For Centralized Exchange's, if the exchange offers it, it will be displayed. If not, it will return "0".


Records

A response may return a records field which contains an array of objects. The totalRecords field will indicate the total number of objects that exist. The number of objects returned in the records array by default is 100. The maximum number of results that can be returned at a time is 1000. To get the next 100 or 1000 records use the page query parameter to request the next page.


Transactions

Transaction types:
0 - Unknown
1 - Contract creation by a contract
2 - Contract creation by an EOA
3 - Contract to contract
4 - Contract to EOA
5 - EOA to contract
6 - EOA to EOA


CSV

By default, all data retrieved via REST API will return in JSON format. However, you can use various programming languages and libraries to easily convert JSON to CSV format. Here is a step-by-step guide using Python as an example because it is a commonly used language for data manipulation and transformation tasks.

  1. Pull JSON Data from the API:

    1. Use your preferred method (e.g., Python's requests library) to make an API request and retrieve the JSON data. Store the JSON data in a Python variable.

    2. import requests
      
      # Make an API request to retrieve JSON data
      url = "https://web3api.io/api/v2/market/spot/tickers/btc_usd/latest"
      
      headers = {
          "accept": "application/json",
          "x-api-key": "API-KEY-HERE"
      }
      
      response = requests.get(url, headers=headers)
      data_json = response.json()
      
  2. Parse JSON Data:

    1. Parse the JSON data into a Python data structure, typically a list of dictionaries or a list of lists, depending on the JSON structure.
    2. # Assuming the JSON data is a list of dictionaries
      data_list = data_json
      
  3. Import the CSV Library:

    1. Import the csv library in Python to handle CSV operations.
    2. import csv
      
  4. Specify the CSV File Path:

    1. Specify the file path where you want to save the CSV file.
    2. csv_file_path = 'output.csv'
      
  5. Write Data to CSV File:

    1. Use Python's csv library to open the CSV file for writing and write the JSON data to it.

    2. # Open the CSV file for writing
      with open(csv_file_path, 'w', newline='') as csv_file:
          # Create a CSV writer object
          csv_writer = csv.writer(csv_file)
      
          # Write the header row if needed (based on your data structure)
          header = data_list[0].keys()  # Assuming the first item in the list contains keys
          csv_writer.writerow(header)
      
          # Write the data rows
          for item in data_list:
              csv_writer.writerow(item.values())
      
  6. CSV File Creation:
    After running the script, a CSV file named output.csv will be created in the specified file path. It will contain the data from the JSON in a tabular format.

This example assumes that the JSON data can be easily transformed into a flat table structure. Some endpoints return JSON data that is more complex (e.g., nested JSON), in which case you may need to perform additional data transformations to flatten it before writing it to the CSV file.

Remember to customize the code to match the structure of the JSON data (differs depending on the endpoint) and any specific requirements you may have for the CSV format.