Skip to content

Commit

Permalink
Feat/new faqs (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
MMenchero authored Mar 15, 2024
2 parents 2af94d4 + d290ff6 commit 4ca9418
Show file tree
Hide file tree
Showing 4 changed files with 406 additions and 365 deletions.
10 changes: 9 additions & 1 deletion nbs/docs/getting-started/1_getting_started_short.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"id": "8e7cea32-ade9-4b23-be93-9a4fbea7c6b2",
"metadata": {},
"source": [
"You can test the validate of your token calling the `validate_token` method:"
"Check your token status with the `validate_token` method."
]
},
{
Expand Down Expand Up @@ -198,6 +198,14 @@
"timegpt.validate_token()"
]
},
{
"cell_type": "markdown",
"id": "a2597400",
"metadata": {},
"source": [
"To learn more about how to set up your token, please refer to the [Setting Up your Authentication Token](https://nixtlaverse.nixtla.io/nixtla/docs/getting-started/setting_up_your_authentication_token.html) tutorial. "
]
},
{
"cell_type": "markdown",
"id": "8ca0d1f7-9730-4146-b6f3-596099ce6e3b",
Expand Down
224 changes: 224 additions & 0 deletions nbs/docs/getting-started/2_setting_up_your_authentication_token.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
{
"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 `TimeGPT` class by directly pasting your token into the code, as shown below:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nixtlats import TimeGPT \n",
"timegpt = TimeGPT(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 `TIMEGPT_TOKEN`. This can be done for a session or permanently, depending on your preference.\n",
"- **Step 2:** When you instantiate the `TimeGPT` class, the SDK will automatically look for the `TIMEGPT_TOKEN` 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 TimeGPT\n",
"timegpt = TimeGPT()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"::: {.callout-important}\n",
"The environment variable must be named exactly `TIMEGPT_TOKEN`, 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 `TIMEGPT_TOKEN`. \n",
"\n",
"``` bash\n",
"export TIMEGPT_TOKEN=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",
"TIMEGPT_TOKEN=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 `TimeGPT` class."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"\n",
"from nixtlats import TimeGPT\n",
"timegpt = TimeGPT()"
]
},
{
"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_token` method](https://nixtlaverse.nixtla.io/nixtla/timegpt.html#timegpt-validate-token) of the `TimeGPT` 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.timegpt:Happy Forecasting! :), If you have questions or need support, please email [email protected]\n"
]
},
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"timegpt.validate_token()"
]
},
{
"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": 2
}
Loading

0 comments on commit 4ca9418

Please sign in to comment.