diff --git a/README.md b/README.md index ecfa1bc..fb3d364 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Flipside Crypto's Analytics Team has curated dozens of blockchain data sets with ## 🗝 Want access? Genrate an API Key for Free -Get your [free API key here](https://flipsidecrypto.xyz/account/api-keys) +Get your [free API key here](https://flipsidecrypto.xyz/api-keys)
## SDKs diff --git a/examples/python/notebooks/intro.ipynb b/examples/python/notebooks/intro.ipynb index dff3f97..aece441 100644 --- a/examples/python/notebooks/intro.ipynb +++ b/examples/python/notebooks/intro.ipynb @@ -1,126 +1,126 @@ { - "cells": [ - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Intro to Flipside SDK/API: Getting Started\n", - "\n", - "install Flipside with pip
\n", - "`pip install flipside`" - ] + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Intro to Flipside SDK/API: Getting Started\n", + "\n", + "install Flipside with pip
\n", + "`pip install flipside`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Import the package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from flipside import Flipside" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Run your first query
\n", + "Remember to copy/paste your API Key from https://flipsidecrypto.xyz/api-keys below." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "YOUR_API_KEY = os.environ.get(\"FLIPSIDE_API_KEY\")\n", + "\n", + "# Invoke the ShroomDK class to create an instance of the SDK\n", + "sdk = Flipside(YOUR_API_KEY)\n", + "\n", + "# Run a query\n", + "query_result_set = sdk.query(\"\"\"\n", + " SELECT * FROM ethereum.core.ez_eth_transfers \n", + " WHERE \n", + " block_timestamp > GETDATE() - interval'90 days'\n", + " AND \n", + " (eth_from_address = lower('0xc2f41b3a1ff28fd2a6eee76ee12e51482fcfd11f')\n", + " OR eth_to_address = lower('0xc2f41b3a1ff28fd2a6eee76ee12e51482fcfd11f'))\n", + "\"\"\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Query Result Set\n", + "\n", + "```python\n", + "class QueryResultSet(BaseModel):\n", + " query_id: Union[str, None] = Field(None, description=\"The server id of the query\")\n", + " status: str = Field(False, description=\"The status of the query (`PENDING`, `FINISHED`, `ERROR`)\")\n", + " columns: Union[List[str], None] = Field(None, description=\"The names of the columns in the result set\")\n", + " column_types: Union[List[str], None] = Field(None, description=\"The type of the columns in the result set\")\n", + " rows: Union[List[Any], None] = Field(None, description=\"The results of the query\")\n", + " run_stats: Union[QueryRunStats, None] = Field(\n", + " None,\n", + " description=\"Summary stats on the query run (i.e. the number of rows returned, the elapsed time, etc)\",\n", + " )\n", + " records: Union[List[Any], None] = Field(None, description=\"The results of the query transformed as an array of objects\")\n", + " error: Any\n", + "\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "## Explore the result set object\n", + "\n", + "records = query_result_set.records\n", + "\n", + "print(records[0])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.1 64-bit", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.1" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1" + } + } }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Import the package" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from flipside import Flipside" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Run your first query
\n", - "Remember to copy/paste your API Key from https://flipsidecrypto.xyz/account/api-keys below." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "YOUR_API_KEY = os.environ.get(\"FLIPSIDE_API_KEY\")\n", - "\n", - "# Invoke the ShroomDK class to create an instance of the SDK\n", - "sdk = Flipside(YOUR_API_KEY)\n", - "\n", - "# Run a query\n", - "query_result_set = sdk.query(\"\"\"\n", - " SELECT * FROM ethereum.core.ez_eth_transfers \n", - " WHERE \n", - " block_timestamp > GETDATE() - interval'90 days'\n", - " AND \n", - " (eth_from_address = lower('0xc2f41b3a1ff28fd2a6eee76ee12e51482fcfd11f')\n", - " OR eth_to_address = lower('0xc2f41b3a1ff28fd2a6eee76ee12e51482fcfd11f'))\n", - "\"\"\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Query Result Set\n", - "\n", - "```python\n", - "class QueryResultSet(BaseModel):\n", - " query_id: Union[str, None] = Field(None, description=\"The server id of the query\")\n", - " status: str = Field(False, description=\"The status of the query (`PENDING`, `FINISHED`, `ERROR`)\")\n", - " columns: Union[List[str], None] = Field(None, description=\"The names of the columns in the result set\")\n", - " column_types: Union[List[str], None] = Field(None, description=\"The type of the columns in the result set\")\n", - " rows: Union[List[Any], None] = Field(None, description=\"The results of the query\")\n", - " run_stats: Union[QueryRunStats, None] = Field(\n", - " None,\n", - " description=\"Summary stats on the query run (i.e. the number of rows returned, the elapsed time, etc)\",\n", - " )\n", - " records: Union[List[Any], None] = Field(None, description=\"The results of the query transformed as an array of objects\")\n", - " error: Any\n", - "\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "## Explore the result set object\n", - "\n", - "records = query_result_set.records\n", - "\n", - "print(records[0])" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.10.1 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.1" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 + "nbformat": 4, + "nbformat_minor": 2 } diff --git a/examples/python/notebooks/mdao-intro.ipynb b/examples/python/notebooks/mdao-intro.ipynb index 9142793..2190463 100644 --- a/examples/python/notebooks/mdao-intro.ipynb +++ b/examples/python/notebooks/mdao-intro.ipynb @@ -1,290 +1,290 @@ { - "cells": [ - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Intro to Flipside API/SDK: Getting Started\n", - "\n", - "install Flipside with pip
\n", - "`pip install flipside`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Import the package" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from flipside import Flipside" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Run your first query
\n", - "Remember to copy/paste your API Key from https://flipsidecrypto.xyz/account/api-keys below." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "YOUR_API_KEY = os.environ.get(\"FLIPSIDE_API_KEY\")\n", - "\n", - "# Invoke the ShroomDK class to create an instance of the SDK\n", - "sdk = Flipside(YOUR_API_KEY)\n", - "\n", - "# Run a query\n", - "xMETRIC_contract_address = '0x15848C9672e99be386807b9101f83A16EB017bb5'\n", - "\n", - "query_result_set = sdk.query(f\"\"\"\n", - " SELECT count(distinct to_address) as recipient_count\n", - " FROM polygon.core.fact_token_transfers\n", - " WHERE block_timestamp > '2022-07-10T00:00:00'\n", - " AND contract_address = lower('{xMETRIC_contract_address}')\n", - " AND to_address != lower('0x4b8923746a1D9943bbd408F477572762801efE4d')\n", - "\"\"\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Query Result Set\n", - "\n", - "```python\n", - "class QueryResultSet(BaseModel):\n", - " query_id: Union[str, None] = Field(None, description=\"The server id of the query\")\n", - " status: str = Field(False, description=\"The status of the query (`PENDING`, `FINISHED`, `ERROR`)\")\n", - " columns: Union[List[str], None] = Field(None, description=\"The names of the columns in the result set\")\n", - " column_types: Union[List[str], None] = Field(None, description=\"The type of the columns in the result set\")\n", - " rows: Union[List[Any], None] = Field(None, description=\"The results of the query\")\n", - " run_stats: Union[QueryRunStats, None] = Field(\n", - " None,\n", - " description=\"Summary stats on the query run (i.e. the number of rows returned, the elapsed time, etc)\",\n", - " )\n", - " records: Union[List[Any], None] = Field(None, description=\"The results of the query transformed as an array of objects\")\n", - " error: Any\n", - "\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "## Explore the result set object\n", - "\n", - "records = query_result_set.records\n", - "\n", - "print(records[0])\n", - "\n", - "print(f\"There are {records[0]['recipient_count']} unique recipients of xMETRIC tokens.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### xMETRIC Leaderboard\n", - "Retrieve the balance of every xMETRIC holder" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "sql" + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Intro to Flipside API/SDK: Getting Started\n", + "\n", + "install Flipside with pip
\n", + "`pip install flipside`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Import the package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from flipside import Flipside" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Run your first query
\n", + "Remember to copy/paste your API Key from https://flipsidecrypto.xyz/api-keys below." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "YOUR_API_KEY = os.environ.get(\"FLIPSIDE_API_KEY\")\n", + "\n", + "# Invoke the ShroomDK class to create an instance of the SDK\n", + "sdk = Flipside(YOUR_API_KEY)\n", + "\n", + "# Run a query\n", + "xMETRIC_contract_address = '0x15848C9672e99be386807b9101f83A16EB017bb5'\n", + "\n", + "query_result_set = sdk.query(f\"\"\"\n", + " SELECT count(distinct to_address) as recipient_count\n", + " FROM polygon.core.fact_token_transfers\n", + " WHERE block_timestamp > '2022-07-10T00:00:00'\n", + " AND contract_address = lower('{xMETRIC_contract_address}')\n", + " AND to_address != lower('0x4b8923746a1D9943bbd408F477572762801efE4d')\n", + "\"\"\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Query Result Set\n", + "\n", + "```python\n", + "class QueryResultSet(BaseModel):\n", + " query_id: Union[str, None] = Field(None, description=\"The server id of the query\")\n", + " status: str = Field(False, description=\"The status of the query (`PENDING`, `FINISHED`, `ERROR`)\")\n", + " columns: Union[List[str], None] = Field(None, description=\"The names of the columns in the result set\")\n", + " column_types: Union[List[str], None] = Field(None, description=\"The type of the columns in the result set\")\n", + " rows: Union[List[Any], None] = Field(None, description=\"The results of the query\")\n", + " run_stats: Union[QueryRunStats, None] = Field(\n", + " None,\n", + " description=\"Summary stats on the query run (i.e. the number of rows returned, the elapsed time, etc)\",\n", + " )\n", + " records: Union[List[Any], None] = Field(None, description=\"The results of the query transformed as an array of objects\")\n", + " error: Any\n", + "\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "## Explore the result set object\n", + "\n", + "records = query_result_set.records\n", + "\n", + "print(records[0])\n", + "\n", + "print(f\"There are {records[0]['recipient_count']} unique recipients of xMETRIC tokens.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### xMETRIC Leaderboard\n", + "Retrieve the balance of every xMETRIC holder" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "sql" + } + }, + "outputs": [], + "source": [ + "WITH sent_tokens AS (\n", + " SELECT \n", + " to_address as Participant,\n", + " sum(raw_amount/pow(10,18)) as xMETRIC\n", + " FROM polygon.core.fact_token_transfers\n", + " WHERE\n", + " block_timestamp::date > '2022-07-10'::date \n", + " AND contract_address = lower('0x15848C9672e99be386807b9101f83A16EB017bb5')\n", + " AND to_address != lower('0x4b8923746a1D9943bbd408F477572762801efE4d')\n", + " GROUP BY 1\n", + "),\n", + "burnt_tokens AS (\n", + " SELECT\n", + " to_address as Participant,\n", + " sum(raw_amount/pow(10,18)) as xMETRIC\n", + " FROM polygon.core.fact_token_transfers\n", + " WHERE\n", + " block_timestamp::date > '2022-07-10'::date \n", + " AND contract_address = lower('0x15848C9672e99be386807b9101f83A16EB017bb5')\n", + " AND to_address = lower('0x0000000000000000000000000000000000000000')\n", + " GROUP BY 1\n", + ")\n", + "SELECT\n", + " sent_tokens.Participant as \"participant_addr\",\n", + " coalesce(sent_tokens.xmetric,0) - coalesce(burnt_tokens.xMETRIC,0) as \"balance\"\n", + "FROM sent_tokens \n", + "LEFT JOIN burnt_tokens ON sent_tokens.Participant = burnt_tokens.Participant\n", + "ORDER BY 2 DESC" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Load the sql query from a file\n", + "leaderboard_sql_query = open(\"./sql/xmetric_leaderboard.sql\", 'r').read()\n", + "\n", + "# Run the query with pagination\n", + "\n", + "page_number = 1\n", + "page_size = 10\n", + "\n", + "leaderboard_result_set = sdk.query(\n", + " leaderboard_sql_query, \n", + " page_size=page_size,\n", + " page_number=page_number)\n", + "\n", + "for record in leaderboard_result_set.records:\n", + " print(record)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot the xMETRIC LeaderBoard Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "full_leaderboard_result_set = sdk.query(leaderboard_sql_query)\n", + "\n", + "import pandas as pd\n", + "import plotly.express as px\n", + "\n", + "df = pd.DataFrame(full_leaderboard_result_set.records)\n", + "\n", + "fig = px.histogram(df, x=\"balance\", marginal=\"box\", hover_data=df.columns, nbins=200)\n", + "\n", + "fig.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Cross Chain xMETRIC User Exploration" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "sql" + } + }, + "outputs": [], + "source": [ + "WITH xmetric_holders AS (\n", + " SELECT to_address as holder_addr\n", + " FROM polygon.core.fact_token_transfers\n", + " WHERE block_timestamp > '2022-07-10T00:00:00'\n", + " AND contract_address = lower('0x15848C9672e99be386807b9101f83A16EB017bb5')\n", + " AND to_address != lower('0x4b8923746a1D9943bbd408F477572762801efE4d')\n", + ")\n", + "SELECT\n", + " token_name,\n", + " symbol,\n", + " count(distinct user_address) as num_holders,\n", + " median(usd_value_now) as median_usd_holdings\n", + "FROM ethereum.core.ez_current_balances\n", + "INNER JOIN xmetric_holders \n", + " ON ethereum.core.ez_current_balances.user_address = xmetric_holders.holder_addr\n", + "WHERE ethereum.core.ez_current_balances.usd_value_now > 0\n", + "GROUP BY 1, 2\n", + "ORDER BY 3 DESC\n", + "LIMIT 25" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Load the sql query from a file\n", + "xmetric_eth_holdings_sql_query = open(\"./sql/xmetric_eth_holdings.sql\", 'r').read()\n", + "\n", + "# Run the query\n", + "xmetric_eth_holdings_results = sdk.query(xmetric_eth_holdings_sql_query)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Plot the results\n", + "df = pd.DataFrame(xmetric_eth_holdings_results.records)\n", + "\n", + "fig = px.bar(df, x=\"token_name\", y=\"num_holders\", hover_data=df.columns)\n", + "\n", + "fig.show()" + ] } - }, - "outputs": [], - "source": [ - "WITH sent_tokens AS (\n", - " SELECT \n", - " to_address as Participant,\n", - " sum(raw_amount/pow(10,18)) as xMETRIC\n", - " FROM polygon.core.fact_token_transfers\n", - " WHERE\n", - " block_timestamp::date > '2022-07-10'::date \n", - " AND contract_address = lower('0x15848C9672e99be386807b9101f83A16EB017bb5')\n", - " AND to_address != lower('0x4b8923746a1D9943bbd408F477572762801efE4d')\n", - " GROUP BY 1\n", - "),\n", - "burnt_tokens AS (\n", - " SELECT\n", - " to_address as Participant,\n", - " sum(raw_amount/pow(10,18)) as xMETRIC\n", - " FROM polygon.core.fact_token_transfers\n", - " WHERE\n", - " block_timestamp::date > '2022-07-10'::date \n", - " AND contract_address = lower('0x15848C9672e99be386807b9101f83A16EB017bb5')\n", - " AND to_address = lower('0x0000000000000000000000000000000000000000')\n", - " GROUP BY 1\n", - ")\n", - "SELECT\n", - " sent_tokens.Participant as \"participant_addr\",\n", - " coalesce(sent_tokens.xmetric,0) - coalesce(burnt_tokens.xMETRIC,0) as \"balance\"\n", - "FROM sent_tokens \n", - "LEFT JOIN burnt_tokens ON sent_tokens.Participant = burnt_tokens.Participant\n", - "ORDER BY 2 DESC" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Load the sql query from a file\n", - "leaderboard_sql_query = open(\"./sql/xmetric_leaderboard.sql\", 'r').read()\n", - "\n", - "# Run the query with pagination\n", - "\n", - "page_number = 1\n", - "page_size = 10\n", - "\n", - "leaderboard_result_set = sdk.query(\n", - " leaderboard_sql_query, \n", - " page_size=page_size,\n", - " page_number=page_number)\n", - "\n", - "for record in leaderboard_result_set.records:\n", - " print(record)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot the xMETRIC LeaderBoard Results" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "full_leaderboard_result_set = sdk.query(leaderboard_sql_query)\n", - "\n", - "import pandas as pd\n", - "import plotly.express as px\n", - "\n", - "df = pd.DataFrame(full_leaderboard_result_set.records)\n", - "\n", - "fig = px.histogram(df, x=\"balance\", marginal=\"box\", hover_data=df.columns, nbins=200)\n", - "\n", - "fig.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Cross Chain xMETRIC User Exploration" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.1 64-bit", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.1" + }, + "orig_nbformat": 4, "vscode": { - "languageId": "sql" + "interpreter": { + "hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1" + } } - }, - "outputs": [], - "source": [ - "WITH xmetric_holders AS (\n", - " SELECT to_address as holder_addr\n", - " FROM polygon.core.fact_token_transfers\n", - " WHERE block_timestamp > '2022-07-10T00:00:00'\n", - " AND contract_address = lower('0x15848C9672e99be386807b9101f83A16EB017bb5')\n", - " AND to_address != lower('0x4b8923746a1D9943bbd408F477572762801efE4d')\n", - ")\n", - "SELECT\n", - " token_name,\n", - " symbol,\n", - " count(distinct user_address) as num_holders,\n", - " median(usd_value_now) as median_usd_holdings\n", - "FROM ethereum.core.ez_current_balances\n", - "INNER JOIN xmetric_holders \n", - " ON ethereum.core.ez_current_balances.user_address = xmetric_holders.holder_addr\n", - "WHERE ethereum.core.ez_current_balances.usd_value_now > 0\n", - "GROUP BY 1, 2\n", - "ORDER BY 3 DESC\n", - "LIMIT 25" - ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Load the sql query from a file\n", - "xmetric_eth_holdings_sql_query = open(\"./sql/xmetric_eth_holdings.sql\", 'r').read()\n", - "\n", - "# Run the query\n", - "xmetric_eth_holdings_results = sdk.query(xmetric_eth_holdings_sql_query)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Plot the results\n", - "df = pd.DataFrame(xmetric_eth_holdings_results.records)\n", - "\n", - "fig = px.bar(df, x=\"token_name\", y=\"num_holders\", hover_data=df.columns)\n", - "\n", - "fig.show()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.10.1 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.1" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 + "nbformat": 4, + "nbformat_minor": 2 } diff --git a/js/README.md b/js/README.md index 55b78a4..65671d2 100644 --- a/js/README.md +++ b/js/README.md @@ -7,7 +7,7 @@ Programmatic access to the most comprehensive blockchain data in Web3 🥳. ![tests](https://github.com/flipsidecrypto/sdk/actions/workflows/ci_js.yml/badge.svg)

-You've found yourself at the Flipside Crypto JS/typescript sdk. +You've found yourself at the Flipside Crypto JS/typescript SDK.

@@ -23,6 +23,10 @@ or if using npm npm install @flipsidecrypto/sdk ``` +## 🗝 Genrate an API Key for Free + +Get your [free API key here](https://flipsidecrypto.xyz/api-keys) + ## 🦾 Getting Started ```typescript @@ -39,7 +43,7 @@ const myAddress = "0x...."; // Create a query object for the `query.run` function to execute const query: Query = { - sql: `select nft_address, mint_price_eth, mint_price_usd from flipside_prod_db.ethereum_core.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, + sql: `select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, maxAgeMinutes: 30, }; @@ -48,10 +52,10 @@ const result: QueryResultSet = await flipside.query.run(query); // Iterate over the results result.records.map((record) => { - const nftAddress = record.nft_address - const mintPriceEth = record.mint_price_eth - const mintPriceUSD = = record.mint_price_usd - console.log(`address ${nftAddress} minted at a price of ${mintPrice} ETH or $${mintPriceUSD} USD`); + const nftAddress = record.nft_address; + const mintPriceEth = record.mint_price_eth; + const mintPriceUSD = = record.mint_price_usd; + console.log(`address ${nftAddress} minted at a price of ${mintPriceEth} ETH or $${mintPriceUSD} USD`); }); ``` @@ -99,7 +103,7 @@ Let's create a query to retrieve all NFTs minted by an address: const yourAddress = ""; const query: Query = { - sql: `select nft_address, mint_price_eth, mint_price_usd from flipside_prod_db.ethereum_core.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, + sql: `select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, maxAgeMinutes: 5, cached: true, timeoutMinutes: 15, @@ -298,7 +302,7 @@ Set `maxAgeMinutes` to 30: ```typescript const query: Query = { - sql: `select nft_address, mint_price_eth, mint_price_usd from flipside_prod_db.ethereum_core.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, + sql: `select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, maxAgeMinutes: 30 }; ``` @@ -309,13 +313,13 @@ If you would like to force a cache bust and re-execute the query. You have two o ```typescript const query: Query = { - sql: `select nft_address, mint_price_eth, mint_price_usd from flipside_prod_db.ethereum_core.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, + sql: `select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, maxAgeMinutes: 0 }; // or: const query: Query = { - sql: `select nft_address, mint_price_eth, mint_price_usd from flipside_prod_db.ethereum_core.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, + sql: `select nft_address, mint_price_eth, mint_price_usd from ethereum.nft.ez_nft_mints where nft_to_address = LOWER('${myAddress}')`, maxAgeMinutes: 30, cache: false }; @@ -358,4 +362,4 @@ Flipside does NOT charge for the number of bytes/records returned. ### Client Side Request Requirements -All API Keys correspond to a list of hostnames. Client-side requests that do not originate from the corresponding hostname will fail. You may configure hostnames [here](https://flipsidecrypto.xyz/account/api-keys). +All API Keys correspond to a list of hostnames. Client-side requests that do not originate from the corresponding hostname will fail. You may configure hostnames [here](https://flipsidecrypto.xyz/api-keys).