gitbook/products/api-sdk-developers/getting-started.md
2024-06-07 20:42:20 +00:00

2.5 KiB

description
Your API key to the most comprehensive blockchain data in crypto for analysts, developers, and data scientists.

Your first API call in < 2 min

Run your first query in under 2 minutes

1. 🔑 Get Your Key

Go to the Flipside Data Studio and click "API" to generate your API key. Every account comes with 5000 free query seconds per month.

2. 🛠 Pick Your SDK and Install It

{% tabs %} {% tab title="Python SDK" %}

pip install flipside

{% endtab %}

{% tab title="JS/TS/Node SDK" %}

yarn add @flipsidecrypto/sdk

or

npm install @flipsidecrypto/sdk

{% endtab %}

{% tab title="R SDK" %}

install.packages("shroomDK") # from CRAN

{% endtab %} {% endtabs %}

3. 🏃‍♀️Execute your First Query

{% tabs %} {% tab title="Python SDK" %}

from flipside import Flipside

# Initialize `Flipside` with your API Key and API Url
flipside = Flipside("<YOUR_API_KEY>", "https://api-v2.flipsidecrypto.xyz")

sql = """
SELECT 
  date_trunc('hour', block_timestamp) as hour,
  count(distinct tx_hash) as tx_count
FROM ethereum.core.fact_transactions 
WHERE block_timestamp >= GETDATE() - interval'7 days'
GROUP BY 1
"""

# Run the query against Flipside's query engine and await the results
query_result_set = flipside.query(sql)

{% endtab %}

{% tab title="JS/TS/Node SDK" %}

const { Flipside } = require("@flipsidecrypto/sdk");

// Initialize `Flipside` with your API key
const flipside = new Flipside(
  "<YOUR_API_KEY>",
  "https://api-v2.flipsidecrypto.xyz"
);

const sql = `
SELECT 
  date_trunc('hour', block_timestamp) as hour,
  count(distinct tx_hash) as tx_count
FROM ethereum.core.fact_transactions 
WHERE block_timestamp >= GETDATE() - interval'7 days'
GROUP BY 1
`

// Send the `Query` to Flipside's query engine and await the results
const queryResultSet = await flipside.query.run({sql: sql});

{% endtab %}

{% tab title="R SDK" %}

library(shroomDK)

api_key = readLines("api_key.txt") # always gitignore your API keys!

query <- { 
"
SELECT 
  date_trunc('hour', block_timestamp) as hour,
  count(distinct tx_hash) as tx_count
FROM ethereum.core.fact_transactions 
WHERE block_timestamp >= GETDATE() - interval'7 days'
GROUP BY 1
"
 }

pull_data <- auto_paginate_query(
query = query,
api_key = api_key
)

{% endtab %} {% endtabs %}