From 1635867d39a3426579852db25e49b37a0e5b11c8 Mon Sep 17 00:00:00 2001 From: MMenchero Date: Mon, 8 Apr 2024 17:04:39 -0600 Subject: [PATCH] Deleted old file --- ...setting_up_your_authentication_token.ipynb | 233 ------------------ 1 file changed, 233 deletions(-) delete mode 100644 nbs/docs/getting-started/2_setting_up_your_authentication_token.ipynb diff --git a/nbs/docs/getting-started/2_setting_up_your_authentication_token.ipynb b/nbs/docs/getting-started/2_setting_up_your_authentication_token.ipynb deleted file mode 100644 index b1aa7883..00000000 --- a/nbs/docs/getting-started/2_setting_up_your_authentication_token.ipynb +++ /dev/null @@ -1,233 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Setting Up Your Authentication Token " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "A **token**, also known as an **API Key**, is a unique string of characters that serves as a key to authenticate your requests to `TimeGTP`. This tutorial will explain how to set up your token when using the Nixtla SDK. \n", - "\n", - "Upon [registration](https://dashboard.nixtla.io/), you will recibe an email asking you to confirm your signup. After confirming, you will receive access to your dashboard. There, under `API Keys`, you will find your token. To integrate your token into your development workflow with the Nixtla SDK, you have two methods. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Direct copy and paste \n", - "\n", - "- **Step 1**: Copy the token found in the `API Keys` of your [dashboard]((https://dashboard.nixtla.io/)). \n", - "- **Step 2**: Instantiate the `NixtlaClient` class by directly pasting your token into the code, as shown below:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/marcopeix/miniconda3/envs/nixtlats/lib/python3.10/site-packages/nixtlats/nixtla_client.py:56: FutureWarning: `'token'` is deprecated; use `'api_key'` instead.\n", - " warnings.warn(\n" - ] - } - ], - "source": [ - "from nixtlats import NixtlaClient \n", - "nixtla_client = NixtlaClient(token = 'your token here')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This approach is straightforward and best for quick tests or scripts that won’t be shared." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. Using an environment variable" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Step 1:** Store your token in an environment variable named `NIXTLA_API_KEY`. This can be done for a session or permanently, depending on your preference.\n", - "- **Step 2:** When you instantiate the `NixtlaClient` class, the SDK will automatically look for the `NIXTLA_API_KEY` environment variable and use it to authenticate your requests." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#| hide\n", - "from dotenv import load_dotenv\n", - "load_dotenv()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from nixtlats import NixtlaClient\n", - "nixtla_client = NixtlaClient()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "::: {.callout-important}\n", - "The environment variable must be named exactly `NIXTLA_API_KEY`, with all capital letters and no deviations in spelling, for the SDK to recognize it.\n", - "::: " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There are several ways to set an environment variable. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### a. From the Terminal\n", - "Use the `export` command to set `NIXTLA_API_KEY`. \n", - "\n", - "``` bash\n", - "export NIXTLA_API_KEY=your_token\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### b. Using a `.env` file\n", - "\n", - "For a more persistent solution that can be version-controlled if private, or for ease of use across different projects, place your token in a `.env` file.\n", - "\n", - "``` bash\n", - "# Inside a file named .env\n", - "NIXTLA_API_KEY=your_token\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Within Python:** If using a `.env` file, you can load the environment variable within your Python script. Use the `dotenv` package to load the `.env` file and then instantiate the `NIXTLA_API_KEY` class." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from dotenv import load_dotenv\n", - "load_dotenv()\n", - "\n", - "from nixtlats import NixtlaClient\n", - "nixtla_client = NixtlaClient()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This approach is more secure and suitable for applications that will be deployed or shared, as it keeps tokens out of the source code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "::: {.callout-important}\n", - "Remember, your token is like a password - keep it secret, keep it safe!\n", - "::: " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Validate your token\n", - "\n", - "You can always find your token in the `API Keys` section of your dashboard. To check the status of your token, use the `validate_api_key` method of the `Nixtla` class. This method will return `True` if the token is valid and `False` otherwise. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:nixtlats.nixtla_client:Happy Forecasting! :), If you have questions or need support, please email ops@nixtla.io\n" - ] - }, - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "nixtla_client.validate_api_key()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You don't need to validate your token every time you use `TimeGPT`. This function is provided for your convenience to ensure its validity. For full access to `TimeGPT`'s functionalities, in addition to a valid token, you also need sufficient credits in your account. You can check your credits in the `Usage` section of your [dashboard]((https://dashboard.nixtla.io/)). " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "python3", - "language": "python", - "name": "python3" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -}