{"componentChunkName":"component---src-templates-blog-list-template-js","path":"/engineering/26","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"excerpt":"What is data enrichment? and its importance Data enrichment is the process of combining first-party data from internal sources with…","fields":{"slug":"/engineering/full-data-science-pipeline-implementation/"},"html":"<h2 id=\"what-is-data-enrichment-and-its-importance\" style=\"position:relative;\"><a href=\"#what-is-data-enrichment-and-its-importance\" aria-label=\"what is data enrichment and its importance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is data enrichment? and its importance</h2>\n<p>Data enrichment is the process of combining first-party data from internal sources with disparate data from other internal systems or third-party data from external sources.</p>\n<p>Usually, the data available from clients or stakeholders are not enough to solve the given problem statement, like if a client comes with a problem statement to build a recommendation engine for his mutual fund industry, the usual data they have is old purchase data but that's not enough as client behaviour changes with time and is impacted by the present market condition, oil prices, etc. which needs to be incorporated in the model to make it efficient.</p>\n<p>Codes for this tutorial is at <a href=\"https://github.com/LoginRadius/engineering-blog-samples/tree/master/Data_Science/Full_DataScience_Pipeline_Implementation\">Link</a></p>\n<p><strong>The whole process id divided into four steps:</strong></p>\n<p>I have implemented a full pipeline of data science from scrapping data from web to implementing ml and NLP classification.</p>\n<ul>\n<li>Phase I:</li>\n</ul>\n<p>Here I have scraped data from IMDB website (imdb.py)</p>\n<ul>\n<li>Phase II:</li>\n</ul>\n<p>I have tried to implement simple ML regression on the data (ml_imdb.py)</p>\n<ul>\n<li>Phase III:</li>\n</ul>\n<p>I have prepared the data for NLP classification (multilabel_prep.py)</p>\n<ul>\n<li>Phase IV:</li>\n</ul>\n<p>I have implemented multilabel NLP classifier using various techniques like chain classifier etc. (multilabel<em>nlp</em>classifier.ipynb)</p>\n<h2 id=\"what-is-web-scraping\" style=\"position:relative;\"><a href=\"#what-is-web-scraping\" aria-label=\"what is web scraping permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is web scraping?</h2>\n<p>Web scraping is the process of extracting and parsing raw data from the web. Web scraping is a technique which helps data scientist to make their data-rich and is an efficient technique of data collection.</p>\n<p>This world is full of data, but unfortunately, most of them are not in the form to be used. Data is like crude oil, or we say it is in unstructured form. For a data scientist or engineer, our first challenge is to make the data model consumption ready, which takes the majority of the time, and this whole process is collectively known as data preprocessing.</p>\n<p>HTML  is a form of primary markup language and the base framework of mostly all websites. For performing web scraping its necessary to know it</p>\n<p>Here we will start with requesting the web page using python package requests.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> requests </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> get</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  url = </span><span class=\"mtk8\">&#39;http://www.imdb.com/search/title?release_date=2017&sort=num_votes,desc&page=1&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  response = get(url)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk11\">len</span><span class=\"mtk1\">(response.text))</span></span></code></pre>\n<p>The whole web page is now stored in the variable object response.\nThen we parse the web page using beautifulsoup package.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> bs4 </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> BeautifulSoup</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  html_soup = BeautifulSoup(response.text, </span><span class=\"mtk8\">&#39;html.parser&#39;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk10\">type</span><span class=\"mtk1\">(html_soup)</span></span></code></pre>\n<p>Then I will store all the div with the class named lister-item mode-advanced in variable movie_containers.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">movie_containers = html_soup.find_all(</span><span class=\"mtk8\">&#39;div&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">class_</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&#39;lister-item mode-advanced&#39;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>Then I iterate through this object and store the information in lists to make my final DataFrame, using simple for loops.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\"># Lists to store the scraped data in</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">names = []</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">years = []</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">imdb_ratings = []</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">metascores = []</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">votes = []</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\">#gross=[] #many movies have no record</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">movie_description=[]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">movie_duration=[]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">movie_genre=[]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Extract data from individual movie container</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> container </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> movie_containers:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># If the movie has Metascore, then extract:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> container.find(</span><span class=\"mtk8\">&#39;div&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">class_</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&#39;ratings-metascore&#39;</span><span class=\"mtk1\">) </span><span class=\"mtk4\">is</span><span class=\"mtk1\"> </span><span class=\"mtk4\">not</span><span class=\"mtk1\"> </span><span class=\"mtk4\">None</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># The name</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        name = container.h3.a.text</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        names.append(name)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># The year</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        year = container.h3.find(</span><span class=\"mtk8\">&#39;span&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">class_</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&#39;lister-item-year&#39;</span><span class=\"mtk1\">).text</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        years.append(year)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># The IMDB rating</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        imdb = </span><span class=\"mtk10\">float</span><span class=\"mtk1\">(container.strong.text)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        imdb_ratings.append(imdb)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># The Metascore</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        m_score = container.find(</span><span class=\"mtk8\">&#39;span&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">class_</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&#39;metascore&#39;</span><span class=\"mtk1\">).text</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        metascores.append(</span><span class=\"mtk10\">int</span><span class=\"mtk1\">(m_score))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># The number of votes</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        vote = container.find(</span><span class=\"mtk8\">&#39;span&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">attrs</span><span class=\"mtk1\"> = {</span><span class=\"mtk8\">&#39;name&#39;</span><span class=\"mtk1\">:</span><span class=\"mtk8\">&#39;nv&#39;</span><span class=\"mtk1\">})[</span><span class=\"mtk8\">&#39;data-value&#39;</span><span class=\"mtk1\">]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        votes.append(</span><span class=\"mtk10\">int</span><span class=\"mtk1\">(vote))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Gross income of movie</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk3\">#gross_inc =container.find_all(&#39;span&#39;, attrs = {&#39;name&#39;:&#39;nv&#39;})[1][&#39;data-value&#39;]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk3\">#gross.append(gross_inc)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># movie description</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_desc=container.find_all(</span><span class=\"mtk8\">&#39;p&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">class_</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&#39;text-muted&#39;</span><span class=\"mtk1\">)[</span><span class=\"mtk7\">1</span><span class=\"mtk1\">].text</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_description.append(movie_desc)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_det=container.find_all(</span><span class=\"mtk8\">&#39;p&#39;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">class_</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&#39;text-muted&#39;</span><span class=\"mtk1\">)[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">]</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Movie duration</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_dur=movie_det.find(</span><span class=\"mtk8\">&#39;span&#39;</span><span class=\"mtk1\">,</span><span class=\"mtk12\">class_</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&#39;runtime&#39;</span><span class=\"mtk1\">).text</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_duration.append(movie_dur)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Movie genre</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_gen=movie_det.find(</span><span class=\"mtk8\">&#39;span&#39;</span><span class=\"mtk1\">,</span><span class=\"mtk12\">class_</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&#39;genre&#39;</span><span class=\"mtk1\">).text</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        movie_genre.append(movie_gen)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> pandas </span><span class=\"mtk15\">as</span><span class=\"mtk1\"> pd</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">one_df = pd.DataFrame({</span><span class=\"mtk8\">&#39;movie&#39;</span><span class=\"mtk1\">: names,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;year&#39;</span><span class=\"mtk1\">: years,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;imdb&#39;</span><span class=\"mtk1\">: imdb_ratings,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;metascore&#39;</span><span class=\"mtk1\">: metascores,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;votes&#39;</span><span class=\"mtk1\">: votes,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\">#&#39;gross&#39;:gross,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;movie decription&#39;</span><span class=\"mtk1\">:movie_description,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;movie duration&#39;</span><span class=\"mtk1\">:movie_duration,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">&#39;movie genre&#39;</span><span class=\"mtk1\">:movie_genre</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">})</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(one_df.info())</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">one_df.to_csv(</span><span class=\"mtk8\">&#39;50_movie_details.csv&#39;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>But this was only for one page which has data for 50 movies only which is not enough to build a model.</p>\n<p>Please refer my code to understand how I use simple for loops to iterate through all the movies and downloading data for 20 years(approx).</p>\n<h2 id=\"implementing-simple-linear-algorithms-in-numerical-data-we-just-scrapped\" style=\"position:relative;\"><a href=\"#implementing-simple-linear-algorithms-in-numerical-data-we-just-scrapped\" aria-label=\"implementing simple linear algorithms in numerical data we just scrapped permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Implementing simple linear algorithms in numerical data we just scrapped</h2>\n<p>Whats is linear regression??</p>\n<p>It is one of the most popular and used statistical techniques\n• Used to understand the relationship between variables</p>\n<p>  • Can also be used to predict a value of interest for new observations</p>\n<p>  • The aim is to predict the value of a continuous numeric variable of interest (known as the response or dependent or target variable)</p>\n<p>  • The values of one or more predictor (or independent) variables are used to make the prediction</p>\n<p>  • One predictor = simple regression</p>\n<p>  • More predictors = multiple regression</p>\n<p>Here I just tried to use metascore of movies firstly to predict IMDB ratings and secondly I wanted to enhance it by using metascore and votes to predict IMDB rating. </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">## ML model</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">X = data.loc[:, </span><span class=\"mtk8\">&#39;metascore&#39;</span><span class=\"mtk1\">].values</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">y = data.loc[:, </span><span class=\"mtk8\">&#39;imdb&#39;</span><span class=\"mtk1\">].values</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Splitting the dataset into the Training set and Test set</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.cross_validation </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> train_test_split</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">X_train, X_test, y_train, y_test = train_test_split(X, y, </span><span class=\"mtk12\">test_size</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">0.33</span><span class=\"mtk1\">, </span><span class=\"mtk12\">random_state</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">0</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.linear_model </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> LinearRegression</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">regressor = LinearRegression()</span><span class=\"mtk3\">#making object for reg package</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">regressor.fit(X_train.reshape(-</span><span class=\"mtk7\">1</span><span class=\"mtk1\">,</span><span class=\"mtk7\">1</span><span class=\"mtk1\">), y_train.reshape(-</span><span class=\"mtk7\">1</span><span class=\"mtk1\">,</span><span class=\"mtk7\">1</span><span class=\"mtk1\">))</span><span class=\"mtk3\">#to fit the regressor to our training data</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\">#predict the test results</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">y_pred =regressor.predict(X_test.reshape(-</span><span class=\"mtk7\">1</span><span class=\"mtk1\">,</span><span class=\"mtk7\">1</span><span class=\"mtk1\">))</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.metrics </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> mean_squared_error</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">mean_squared_error(y_test, y_pred)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># 0.18041462828221905</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">## Let try with imdb and votes</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">X1 = data.loc[:, [</span><span class=\"mtk8\">&#39;metascore&#39;</span><span class=\"mtk1\">,</span><span class=\"mtk8\">&#39;votes&#39;</span><span class=\"mtk1\">]].values</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">y1 = data.loc[:, </span><span class=\"mtk8\">&#39;imdb&#39;</span><span class=\"mtk1\">].values</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Splitting the dataset into the Training set and Test set</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.cross_validation </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> train_test_split</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">X_train, X_test, y_train, y_test = train_test_split(X1, y1, </span><span class=\"mtk12\">test_size</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">0.33</span><span class=\"mtk1\">, </span><span class=\"mtk12\">random_state</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">0</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.linear_model </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> LinearRegression</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">regressor = LinearRegression()</span><span class=\"mtk3\">#making object for reg package</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">regressor.fit(X_train, y_train)</span><span class=\"mtk3\">#to fit the regressor to our training data</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\">#predict the test results</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">y_pred =regressor.predict(X_test)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.metrics </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> mean_squared_error</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">mean_squared_error(y_test, y_pred)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># 0.15729132122310804 good score</span></span></code></pre>\n<p>I tried to scrape data from the IMDB site and then applied ML regression techniques on it. Later I found that the movies listed are multi-class like Logan belongs to Action, Drama, Sci-Fi, which led me to think about how to implement the classifier model in the multilabel data. Usually, the data we get in real-world is mostly multi labelled like chatbot data; the intent is many and like these movies which are multi-class.</p>\n<p>Here we will first see how we prep our data for multilabel classification.</p>\n<p>Here we have all tags in one single column which is not usable while we do classification, so we have to make separate columns for all labels, and if the row doesn't belong to that category, it will be filled by 0 else 1.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> os</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">os.chdir(</span><span class=\"mtk8\">&#39;Desktop/web_scraping/imdb scrapper_ml/&#39;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> pandas </span><span class=\"mtk15\">as</span><span class=\"mtk1\"> pd</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">data=pd.read_csv(</span><span class=\"mtk8\">&#39;multilabel_nlp_classification.csv&#39;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">movie_list=[x </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> data[</span><span class=\"mtk8\">&#39;movie genre&#39;</span><span class=\"mtk1\">]]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">movie_list1=</span><span class=\"mtk8\">&#39;&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> data[</span><span class=\"mtk8\">&#39;movie genre&#39;</span><span class=\"mtk1\">]:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    movie_list1+=</span><span class=\"mtk8\">&#39;,&#39;</span><span class=\"mtk1\">+x</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">li_m=movie_list1.split(</span><span class=\"mtk8\">&#39;,&#39;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">li=[x.strip() </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> li_m]</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">list_s=</span><span class=\"mtk10\">list</span><span class=\"mtk1\">(</span><span class=\"mtk10\">set</span><span class=\"mtk1\">(li))</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> list_s:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    data[x]=</span><span class=\"mtk7\">0</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">data[</span><span class=\"mtk8\">&#39;movie_genre&#39;</span><span class=\"mtk1\">]=[x.strip().split(</span><span class=\"mtk8\">&#39;,&#39;</span><span class=\"mtk1\">) </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> data[</span><span class=\"mtk8\">&#39;movie genre&#39;</span><span class=\"mtk1\">]]</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">de=data.copy()</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\">#data.loc[0,&#39;Action&#39;]=1</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">de[</span><span class=\"mtk8\">&#39;id&#39;</span><span class=\"mtk1\">]=</span><span class=\"mtk11\">range</span><span class=\"mtk1\">(</span><span class=\"mtk7\">0</span><span class=\"mtk1\">,</span><span class=\"mtk7\">6116</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\">#print(de.loc[de[&#39;id&#39;]==0,&#39;Action&#39;])</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> i </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> </span><span class=\"mtk11\">range</span><span class=\"mtk1\">(</span><span class=\"mtk7\">0</span><span class=\"mtk1\">,</span><span class=\"mtk7\">6116</span><span class=\"mtk1\">):</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> x </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> de.loc[de[</span><span class=\"mtk8\">&#39;id&#39;</span><span class=\"mtk1\">]==i,</span><span class=\"mtk8\">&#39;movie_genre&#39;</span><span class=\"mtk1\">]:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> y </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> x:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">            y=y.strip()</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">            de.loc[de[</span><span class=\"mtk8\">&#39;id&#39;</span><span class=\"mtk1\">]==i,y]=</span><span class=\"mtk7\">1</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">de.to_csv(</span><span class=\"mtk8\">&#39;multilabel_nlp_classification.csv&#39;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>Now, as our data is ready, we can start with NLP implementation.</p>\n<p>For multilabel classification, I used techniques like classifier chain, label powerset, etc.</p>\n<p>Here the problem statement is that using the movie description our model has to guess which genre the movie belongs to. It is a popular use case. Take an example of ecommerce product description data; now instead of manually assigning the labels to it, we can use a model which will find relevant labels or genre for it and make the content relevant to the type it belongs.</p>\n<p>I start with Exploratory data analysis and then data cleaning, which is the most crucial step as if all the description has some very 30-50 common words it will simply make the data-heavy and model slow and inefficient.</p>\n<p>Then we go on to make the data model ready as ML models don't understand text data we have to feed numbers in it. For that purpose, we use TfidfVectorizer.</p>\n<h3 id=\"what-is-tfidfvectorizer\" style=\"position:relative;\"><a href=\"#what-is-tfidfvectorizer\" aria-label=\"what is tfidfvectorizer permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is TfidfVectorizer?</h3>\n<p>TfidfVectorizer - Transforms text to feature vectors that can be used as input to the estimator.</p>\n<p>Then simply diving the data in train and test split. </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">x_train = vectorizer.transform(train_text)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">y_train = train.drop(</span><span class=\"mtk12\">labels</span><span class=\"mtk1\"> = [</span><span class=\"mtk8\">&#39;id&#39;</span><span class=\"mtk1\">,</span><span class=\"mtk8\">&#39;movie decription&#39;</span><span class=\"mtk1\">], </span><span class=\"mtk12\">axis</span><span class=\"mtk1\">=</span><span class=\"mtk7\">1</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">x_test = vectorizer.transform(test_text)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">y_test = test.drop(</span><span class=\"mtk12\">labels</span><span class=\"mtk1\"> = [</span><span class=\"mtk8\">&#39;id&#39;</span><span class=\"mtk1\">,</span><span class=\"mtk8\">&#39;movie decription&#39;</span><span class=\"mtk1\">], </span><span class=\"mtk12\">axis</span><span class=\"mtk1\">=</span><span class=\"mtk7\">1</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>I tried first with applying logistic regression and one vs rest classifier.</p>\n<h3 id=\"what-is-onevsrestclassifier\" style=\"position:relative;\"><a href=\"#what-is-onevsrestclassifier\" aria-label=\"what is onevsrestclassifier permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is OneVsRestClassifier??</h3>\n<p>OneVsRestClassifier strategy splits a multi-class classification into one binary classification problem per class.\nOneVsRestClassifier is when we want to do multi-class or multilabel classification, and its strategy consists of fitting one classifier per class. For each classifier, the class is fitted against all the other classes. </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\"># Using pipeline for applying logistic regression and one vs rest classifier</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">LogReg_pipeline = Pipeline([</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">                (</span><span class=\"mtk8\">&#39;clf&#39;</span><span class=\"mtk1\">, OneVsRestClassifier(LogisticRegression(</span><span class=\"mtk12\">solver</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&#39;sag&#39;</span><span class=\"mtk1\">), </span><span class=\"mtk12\">n_jobs</span><span class=\"mtk1\">=-</span><span class=\"mtk7\">1</span><span class=\"mtk1\">)),</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">            ])</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> category </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> categories:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    printmd(</span><span class=\"mtk8\">&#39;**Processing </span><span class=\"mtk4\">{}</span><span class=\"mtk8\"> comments...**&#39;</span><span class=\"mtk1\">.format(category))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk3\"># Training logistic regression model on train data</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    LogReg_pipeline.fit(x_train, train[category])</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk3\"># calculating test accuracy</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    prediction = LogReg_pipeline.predict(x_test)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;Test accuracy is </span><span class=\"mtk4\">{}</span><span class=\"mtk8\">&#39;</span><span class=\"mtk1\">.format(accuracy_score(test[category], prediction)))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\n</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>Next, I tried with BinaryRelevance</p>\n<h3 id=\"what-is-binaryrelevance\" style=\"position:relative;\"><a href=\"#what-is-binaryrelevance\" aria-label=\"what is binaryrelevance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is BinaryRelevance?</h3>\n<p>It is a simple technique which treats each label as a separate single class classification problem.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\"># using binary relevance</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> skmultilearn.problem_transform </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> BinaryRelevance</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.naive_bayes </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> GaussianNB</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># initialize binary relevance multi-label classifier</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># with a gaussian naive bayes base classifier</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">classifier = BinaryRelevance(GaussianNB())</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># train</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">classifier.fit(x_train, y_train)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># predict</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">predictions = classifier.predict(x_test)</span></span></code></pre>\n<p>Next, I tried using ClassifierChain.</p>\n<h3 id=\"what-is-classifierchain\" style=\"position:relative;\"><a href=\"#what-is-classifierchain\" aria-label=\"what is classifierchain permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is ClassifierChain?</h3>\n<p>It is almost similar to BinaryRelevance, here the first classifier is trained just on the input data, and then each next classifier is trained on the input space and all the previous classifiers in the chain.  </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> skmultilearn.problem_transform </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> ClassifierChain</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> sklearn.linear_model </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> LogisticRegression</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># initialize classifier chains multi-label classifier</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">classifier = ClassifierChain(LogisticRegression())</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># Training logistic regression model on train data</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">classifier.fit(x_train, y_train)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># predict</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">predictions = classifier.predict(x_test)</span></span></code></pre>\n<p>Next, I tried using Label Powerset.</p>\n<h3 id=\"what-is-labelpowerset\" style=\"position:relative;\"><a href=\"#what-is-labelpowerset\" aria-label=\"what is labelpowerset permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is LabelPowerset?</h3>\n<p>Here we transform the problem into a multi-class problem with one multi-class classifier is trained on all unique label combinations found in the training data.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"11\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">from</span><span class=\"mtk1\"> skmultilearn.problem_transform </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> LabelPowerset</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># initialize label powerset multi-label classifier</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">classifier = LabelPowerset(LogisticRegression())</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># train</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">classifier.fit(x_train, y_train)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># predict</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">predictions = classifier.predict(x_test)</span></span></code></pre>\n<p>Please refer my notebook multilabel<em>nlp</em>classifier.ipynb from my repo for more details.</p>\n<h2 id=\"improvement\" style=\"position:relative;\"><a href=\"#improvement\" aria-label=\"improvement permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Improvement:</h2>\n<ol>\n<li>More feature engineering and data to avoid this overfitting and make more efficient pipeline</li>\n<li>If we collect more data, deep learning and state of the art algorithms like BERT can help us to leverage the efficiency of the model.</li>\n</ol>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary:</h2>\n<ul>\n<li>We have learnt how to collect data by web scraping and tools to perform the same.</li>\n<li>We completed the modelling techniques on in numerical data</li>\n<li>We prepared the label data to be model fed ready</li>\n<li>We learnt how different ML techniques could be applied to text data and build a multilabel classifier.</li>\n</ul>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n  .dark-default-dark .mtk6 { color: #D7BA7D; }\n</style>","frontmatter":{"date":"October 09, 2020","updated_date":null,"description":"Learn how to implement the full data science pipeline right from collecting the data to implementing ML algorithms.","title":" Full data science pipeline implementation","tags":["DataScience","Python","Web scraping","NLP","Machine learning"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/5a2492e69b5cbb1c2f5bb0a3d4ca9fc2/58556/ds.webp","srcSet":"/static/5a2492e69b5cbb1c2f5bb0a3d4ca9fc2/61e93/ds.webp 200w,\n/static/5a2492e69b5cbb1c2f5bb0a3d4ca9fc2/1f5c5/ds.webp 400w,\n/static/5a2492e69b5cbb1c2f5bb0a3d4ca9fc2/58556/ds.webp 800w,\n/static/5a2492e69b5cbb1c2f5bb0a3d4ca9fc2/df6a9/ds.webp 1125w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Rinki Nag","github":"eaglewarrior","avatar":null}}}},{"node":{"excerpt":"The two types of email you can send and receive are plain text emails (any email that contains just plain old text with no formatting) and…","fields":{"slug":"/engineering/html-email-concept/"},"html":"<p>The two types of email you can send and receive are plain text emails (any email that contains just plain old text with no formatting) and HTML emails, these are formatted and styled using HTML and inline CSS.\nHTML email is the use of HTML to provide formatting and semantic markup capabilities in an email that are not available in plain text.</p>\n<p>An HTML email is designed just like a website with the help of graphics, table columns, colors and links. A non-programmer can also create it since email marketing services provide flexible campaign builders. Email client vendors have not been as developing as web browser vendors in adopting new standards. </p>\n<p><strong>Definition</strong></p>\n<p>Emails which are formatted using Hypertext Markup Language(HTML), as opposed to plain text email.</p>\n<p><strong>How to Create an HTML Email</strong></p>\n<p>Many tools that create and send an email will offer pre-formatted, already built HTML templates that allow you to design emails without knowing or accessing any code of back-end.</p>\n<p>The best way to understand any process is to do it yourself, from level zero. We make any changes in the email editor; those changes will be automatically coded into the final result. This email building tool is the best option if you don't have an email designer, but you still want to send any professional marketing emails.</p>\n<p>If you want more control over the code of your emails and you are comfortable with HTML(that is just basic and easy), most email tools will allow you to import HTML files directly for using it as custom email templates. They have a wide variety of free HTML email templates available on the internet, and if you are familiar with HTML, it is a straightforward process to use that template in the email building tool of your own choice.</p>\n<p>To create an HTML email from scratch, you will need to have advanced knowledge of HTML. Because creating an HTML email from scratch can be quite tricky, we recommend you to work with a developer for this process, or you may go with a template for an easy process.</p>\n<p><strong>If you choose to code your HTML email by hand, these are the necessary steps you need to use while creating HTML email:</strong></p>\n<ol>\n<li>The perfect email template size should have 600-700 max-width.</li>\n<li>If the design has animation, then use .gif animated file because interactive elements like Flash, JavaScript, or HTML forms won't work in most email inboxes.</li>\n<li>Try to use HTML tables (HTML tables present tabular data in a semantic and structurally appropriate manner) for your presentation.</li>\n<li>To improve the presentation of Web, use inline CSS within your HTML email.</li>\n<li>CSS style should be either in a separate CSS file or below the body tag and not under the head tag.</li>\n<li>To save yourself from trouble, avoid the use of CSS shorthand code.</li>\n<li>The most genuine way of coding background colors is to use six-digit hexadecimal code for color (like #000000, i.e. for black).</li>\n<li>Be sure always to use \"display: block;\" for your image tags (either inline or embedded CSS) because this takes the baseline out of the equation and keeps everything arranged neatly and in order.</li>\n<li>If you wish to have padding on columns, it might be more cross-browser, so you can always create spacer DIVs in between the columns (or between rows).</li>\n<li>You need to use absolute paths for your images.</li>\n<li>Try adding a line-height and font-size of 1 under \"<TD>\" (or the desired size).</li>\n<li>Inline styles to <TD> and tables are the right way to go for Html email.</li>\n<li>In an HTML table, you can set the cell padding and cell spacing to zero to eliminate the unwanted spacing in your layout.</li>\n</ol>\n<p><strong>How to send  HTML emails through Outlook?</strong></p>\n<ol>\n<li>Select more commands to customize your quick access toolbar(suggestion).</li>\n<li>Choose \"attach\" function and then \"add\" it to the toolbar.</li>\n<li>Open \"attach a file\" window from the quick access toolbar.</li>\n<li>Select HTML file you need to import BUT do not click to INSERT yet.</li>\n<li>Switch \"insert\" button with the \"insert as a text\" button and click.</li>\n<li>Now, you can send it to your audience.</li>\n</ol>\n<p><strong>You can check HTML Email Template here:</strong></p>\n<p><a href=\"https://github.com/designmodo/html-email-templates\">HTML Email Templates</a></p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"October 09, 2020","updated_date":null,"description":"If you choose to code your HTML email by hand, there are many different things you need to use while creating HTML email.","title":"HTML Email Concept","tags":["Html","Email"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.7699115044247788,"src":"/static/67ac86643dbb14dedfd4fe52ff7e659c/58556/email_picture.webp","srcSet":"/static/67ac86643dbb14dedfd4fe52ff7e659c/61e93/email_picture.webp 200w,\n/static/67ac86643dbb14dedfd4fe52ff7e659c/1f5c5/email_picture.webp 400w,\n/static/67ac86643dbb14dedfd4fe52ff7e659c/58556/email_picture.webp 800w,\n/static/67ac86643dbb14dedfd4fe52ff7e659c/54d25/email_picture.webp 1080w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Nivedita Singh","github":"Nivedita967","avatar":null}}}},{"node":{"excerpt":"These days we have all come across one of the coolest buzzwords in the IT industry: \"The Blockchain\". It might seem to be a new magic word…","fields":{"slug":"/engineering/blockchain-the-new-technology-of-security-trust/"},"html":"<p>These days we have all come across one of the coolest buzzwords in the IT industry: <strong>\"The Blockchain\"</strong>. It might seem to be a new magic word in the market that companies spell interest in their businesses. However, the complexity of it is incredibly far-reaching. Blockchain integrates the openness and flexibility of the internet with the security of cryptography to come out with a safer, faster way of verification of information and most importantly establishes trust in this open world.</p>\n<p>Blockchain was first developed by an anonymous programmer or group of programmers known by a name 'Santoshi Nakamoto'.It was an underlying technology for the Bitcoin, which is used for peer-to-peer transactions. Blockchain at its heart is a list of transactions like a distributed ledger open to all in the network. It stores the data in such a way that it seems virtually impossible to add, update or remove any information stored without the notice of other users in a peer-to-peer network.</p>\n<h2 id=\"how-does-blockchain-work\" style=\"position:relative;\"><a href=\"#how-does-blockchain-work\" aria-label=\"how does blockchain work permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How does blockchain work?</h2>\n<p>Blockchain mainly performs two tasks: collect and order data in blocks- similar to the traditional computer database and then chain them securely using cryptography.</p>\n<p>Let us take a closer look at each block in this enormous chain –</p>\n<ul>\n<li>FILLING  IN THE BLOCK\nData: This is the information which depends on the blockchain if it is a bitcoin block, then it contains information about the sender, receiver of the amount and the amount value.</li>\n<li>SECURING THE CHAIN\nHash: It is quite similar to human fingerprint and is unique to each block, once the information of the block changes, the hash changes and the block no longer remain the same as the previous one.</li>\n<li>LOCKING THE BLOCKS DOWN\nHash of the previous block-the hash of one block gives the data for the next block, and this new block uses this hash function and traces of it is woven into the new hash this continues to build an enormous chain.</li>\n</ul>\n<p><img src=\"/b84871cea75ab42c2a7a93163787f5e5/block.webp\" alt=\"Blockchain\"></p>\n<h2 id=\"establishing-the-trust\" style=\"position:relative;\"><a href=\"#establishing-the-trust\" aria-label=\"establishing the trust permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Establishing the trust</h2>\n<p>The copy of the complete blockchain is with all the participants so that they can detect tampering if the hash matches across the chain then everyone knows that it is trustworthy.\nBlockchain is an emerging technology but has been evolving ever since its innovation. This technology has the unlimited potential to bring about an upheaval in the way everyone- organisations, governments, individuals work together. It promises a simple, secure, paperless path to establish trust for virtual transactions of money, products and other confidential information worldwide.</p>\n<h2 id=\"blockchain-in-action\" style=\"position:relative;\"><a href=\"#blockchain-in-action\" aria-label=\"blockchain in action permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Blockchain in action</h2>\n<p>Blockchain is one of the technologies that has gained popularity from its very birth, and now it is being used in many fields.</p>\n<h2 id=\"financial-market\" style=\"position:relative;\"><a href=\"#financial-market\" aria-label=\"financial market permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Financial market</h2>\n<p>In financial markets, trade is very dynamic where there is the exchange of money, assets involving multiple banks; this may lead to unexpected errors. To reduce this bottleneck blockchain came up with the idea of smart contracts which is a small computer program that describes the transactions step by step combining multiple blockchains, multiple assets and executes the transactions securely.</p>\n<h2 id=\"digital-id\" style=\"position:relative;\"><a href=\"#digital-id\" aria-label=\"digital id permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Digital ID</h2>\n<p>Blockchain can keep track of many commercial transactions and efficiently hold sensitive information. A digital id via blockchain secures the data stored and can be used worldwide in your fingertips.</p>\n<h2 id=\"supply-chain\" style=\"position:relative;\"><a href=\"#supply-chain\" aria-label=\"supply chain permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Supply chain</h2>\n<p>Blockchain can be very handy in monitoring the supply chain in food and manufacturing industries by removing paper-based trails and also removing intermediaries between producers to customers. Not just the above applications it is used in many more places and has changed, is going to change the world around us.</p>\n<h2 id=\"blockchain-the-next-gen-technology\" style=\"position:relative;\"><a href=\"#blockchain-the-next-gen-technology\" aria-label=\"blockchain the next gen technology permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Blockchain the next-gen technology</h2>\n<p>Though it is a new technology, it has an enormous ability to transform everything existing now. As a coin has its two faces, blockchain technology also has some glitches as it can destroy the middlemen in many of the industries.\nBlockchain has already spread its root firmly in soils of the new world, and the swarm of transformation has already begun. It is the responsibility of all the young generation to make complete usage of this technology as it matures and make it to become a huge money plant.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"October 08, 2020","updated_date":null,"description":"Learn about Blockchain technology and how it works.","title":"Blockchain: The new technology of trust","tags":["Blockchain","Cyber Security"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.6666666666666667,"src":"/static/01f18fbf0dec445fa25aa3b13483883e/58556/CoverPage.webp","srcSet":"/static/01f18fbf0dec445fa25aa3b13483883e/61e93/CoverPage.webp 200w,\n/static/01f18fbf0dec445fa25aa3b13483883e/1f5c5/CoverPage.webp 400w,\n/static/01f18fbf0dec445fa25aa3b13483883e/58556/CoverPage.webp 800w,\n/static/01f18fbf0dec445fa25aa3b13483883e/1fb14/CoverPage.webp 960w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Shraddha V Prasad","github":"shraddhavp","avatar":null}}}},{"node":{"excerpt":"The acronym for Vim is Vi IMproved. Written by Bram Moolenaar, it is a free and open-source text editor. It was first released for UNIX…","fields":{"slug":"/engineering/vim-getting-started/"},"html":"<p>The acronym for Vim is Vi IMproved. Written by <a href=\"https://en.wikipedia.org/wiki/Bram_Moolenaar\">Bram Moolenaar</a>, it is a free and open-source text editor. It was first released for UNIX variants in 1991, and its primary purpose was to develop the Vi editor, which was released back in 1976.</p>\n<p>Vim is Vi's newest and most popular reincarnation that supports both text and graphical interfaces and is supported on any known platform.</p>\n<p>The issue with learning Vim is not that it's challenging to do. It's that you have to continue to do it. This guide aims to break the loop so that for the last time, you can learn it.</p>\n<p>The purpose of this tutorial is to take you through every step of progress from understanding the philosophy of Vim. In short, in a way that sticks with you for a lifetime, we're going to master Vim.</p>\n<p>Let's start off!</p>\n<h2 id=\"what-is-vim\" style=\"position:relative;\"><a href=\"#what-is-vim\" aria-label=\"what is vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Vim?</h2>\n<p>Vim is a text editor for Unix that comes with Linux, BSD, and macOS. It is known to be fast and powerful, partly because it is a small program that can run in a terminal (although it has a graphical interface). It is mainly because it can be managed entirely without menus or a mouse with a keyboard.</p>\n<p>For the following five reasons, I feel people should use Vim:</p>\n<ol>\n<li>It's omnipresent. You don't have to think about learning about several boxes with a new editor.</li>\n<li>It is highly scalable. You can use it only to edit configuration files or become your entire forum for writing.</li>\n<li>It has a shallow memory footprint.</li>\n<li>It's command-centered. With a few commands, you can perform complex text-related tasks.</li>\n<li>It is highly configurable and uses simple text files to store its settings.</li>\n</ol>\n<h2 id=\"why-use-vim\" style=\"position:relative;\"><a href=\"#why-use-vim\" aria-label=\"why use vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Use Vim?</h2>\n<p>In all POSIX systems, Vim is the default fallback editor. Vim is sure to be open, whether you have just installed the operating system, or you have booted into a minimal system repair environment, or you are unable to access any other editor. While you can switch out other tiny editors on your systems, such as GNU Nano or Jove, it's Vim that's all but guaranteed to be on every other system in the world.</p>\n<p>In short, I think competence with Vim should be considered the way you view competence with your native language, or simple maths, etc. In technology, so much begins with understanding your editor.</p>\n<p>Also, It is <strong>extremely customizable</strong> and you can adapt it to your way of coding and your way of doing things.\nTo give you a taste of vim , below are a few commands frequently used to code at lightning speed:</p>\n<ul>\n<li>hjkl : move the cursor around to left, down, up, and right respectively.</li>\n<li>7j : move 7 lines down.</li>\n<li>w : move a word forward</li>\n<li>ctrl + f : move down a page</li>\n<li>ctrl + b : move up a page</li>\n<li>gg : move to the top of the document</li>\n<li>G : move to the bottomost of the document</li>\n<li>dw : delete a word</li>\n<li>d6w : delete 6 words</li>\n<li>dt> : delete till  <code>></code></li>\n<li>di] : delete everything inside <code>[ ]</code></li>\n<li>dd : delete whole line</li>\n<li>4dd : delete 4 lines</li>\n<li>yy : yank a line ( yank is copy )</li>\n<li>cc : change a line ( change is delete and go in insert mode )</li>\n<li>cap : change a paragraph</li>\n<li><code>.</code> : repeat last command</li>\n<li>f' : find first occurance of <code>'</code></li>\n<li>f'ci'hello : _find the next  <code>'</code> then change everything inside <code>'</code> for <code>hello</code></li>\n</ul>\n<p>The list goes on and on... </p>\n<p>Basically we have standard keybindings like d for delete, c for change, f for find etc. and we can pair them with numbers to repeat that action n number of times. Moreover doubling a command like so <code>yy</code> makes the command operate on the entire line.</p>\n<p>So to sum up,</p>\n<blockquote>\n<p>Vim is for <strong>programmers who want to raise their game</strong>. In the hands of an expert, It shreds text at the speed of thought.</p>\n</blockquote>\n<h4 id=\"how-to-use-vim\" style=\"position:relative;\"><a href=\"#how-to-use-vim\" aria-label=\"how to use vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to use Vim</h4>\n<p> Well, there is a learning curve, but it's worth it. Although this steep curve is exaggerated in the online world and the <strong>quitting vim joke</strong> is getting very old (It's:q btw).</p>\n<p> Install Vim <code>sudo apt-get vim or pacman -S vim</code> for Linux user and type <code>vim &#x3C;filename></code> in your terminal. Press <code>i</code> to go to insert mode. Type some gibberish. Press <code>:wq</code> to save and quit . <code>:q!</code> to quit without saving.</p>\n<p> First of all, don't get disheartened when you see VIM for the first time, it's known to make a <strong>horrible first impression.</strong> We'll learn to customize it later in the blog.</p>\n<p> <img src=\"/30e4bc97b173caff9cce44962cb4a78b/BadVim.webp\" alt=\"BadVim\"></p>\n<p> To get started, get your hands dirty on <strong>vimtutor</strong> . It's a 20-30 minute vim tutorial which teaches you all the basics. Just type <code>vimtutor</code> in your terminal (in a machine where you have vim installed) to open it.</p>\n<p><strong>Try  <a href=\"https://vim-adventures.com/\">Vim Adventures</a></strong>. An interactive game that teaches you vim skills in a step by step manner and lets you unlock new abilities after you've proved your worth with the previous ones.</p>\n<p> Just get started with it . <strong>Learn as you go</strong> . You can always refer to the <a href=\"https://vim.rtorr.com/\">Vim CheatSheet</a> to get better. Practice makes a man perfect. Watch screencasts if that's helpful (was helpful to me).</p>\n<h2 id=\"how-do-i-configure-my-vim-\" style=\"position:relative;\"><a href=\"#how-do-i-configure-my-vim-\" aria-label=\"how do i configure my vim  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How do I configure my Vim ?</h2>\n<p>The best way to configure your Vim is through <code>.vimrc</code> file, which is hidden inside your home directory. Open a terminal and type <code>vim ~/.vimrc</code> to open your vimrc file using vim. Cool huh? Using vim to configure vim ..no? Nevermind!\nHere you can define your keybindings, set themes, install plugins etc.</p>\n<p>Here is an example of a custom keybinding\n<code>map &#x3C;C-n> :NERDTreeToggle&#x3C;CR></code>\nYou can check out this <a href=\"https://hea-www.harvard.edu/~fine/Tech/vi.html\">article</a> on keybindings and how to use them.</p>\n<p>The easiest way to download and manage plugins for vim is by using a plugin manager. There are quite a few <a href=\"https://github.com/tpope/vim-pathogen\">vim-pathogen</a> , <a href=\"https://github.com/VundleVim/Vundle.vim\">Vundle.vim</a> , <a href=\"https://github.com/junegunn/vim-plug\">Vim-plug</a> etc.\nVim-plug being my favourite. Installations and usage for each plugin manager can be found in their respective repositories.</p>\n<p>I personally like to call all my plugins in a separate file and link that file to my vimrc. Paste this line in your vimrc at the top if you want to do the same <code>source ~/.vim/plugin/plugins.vim</code>\nIn your plugins.vim file you can install different plugins like this:-</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">call plug#begin(&#39;~/.vim/plugged&#39;)</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">Plug &#39;scrooloose/nerdtree&#39;</span>\n<span class=\"grvsc-line\">Plug &#39;moll/vim-node&#39;</span>\n<span class=\"grvsc-line\">Plug &#39;yegappan/mru&#39;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">call plug#end()</span></code></pre>\n<p>The first and last lines are for vim-plug to know what plugins are to be installed. The lines beginning with <code>Plug</code> is to install that particular plugin.</p>\n<p>Now just reload .vimrc (or quit vim and re-enter) and <code>:PlugInstall</code> to install plugins.</p>\n<h2 id=\"what-are-some-good-plugins-for-vim\" style=\"position:relative;\"><a href=\"#what-are-some-good-plugins-for-vim\" aria-label=\"what are some good plugins for vim permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What are some good plugins for Vim?</h2>\n<p>Glad you asked because Vim is no fun without plugins made by the awesome open source community.\nHere are some good plugins you should definitely install. Just search these on GitHub in case you wanna know more about them or their usage.</p>\n<ul>\n<li>scrooloose/nerdtree</li>\n<li>alvan/vim-closetag</li>\n<li>vim-scripts/vim-auto-save</li>\n<li>airblade/vim-gitgutter</li>\n<li>ervandew/supertab</li>\n<li>vim-airline/vim-airline</li>\n<li>SirVer/ultisnips</li>\n<li>honza/vim-snippets</li>\n<li>dense-analysis/ale</li>\n<li>tpope/vim-repeat</li>\n<li>ap/vim-css-color</li>\n<li>jiangmiao/auto-pairs</li>\n<li>tmhedberg/matchit</li>\n<li>kana/vim-textobj-user</li>\n<li>vim-scripts/tComment</li>\n<li>Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }</li>\n<li>prettier/vim-prettier', { 'do': 'yarn install' }</li>\n<li>jeffkreeftmeijer/vim-numbertoggle</li>\n<li>elzr/vim-json</li>\n<li>tpope/vim-markdown</li>\n<li>pangloss/vim-javascript</li>\n<li>mxw/vim-jsx</li>\n<li>jparise/vim-graphql</li>\n<li>leafgarland/typescript-vim</li>\n<li>vim-syntastic/syntastic</li>\n<li>ntpeters/vim-better-whitespace</li>\n</ul>\n<p>Pheww!!..\nSo you see there's a plugin for anything and everything. These plugins are more than enough to make vim a full-blown IDE.</p>\n<h3 id=\"summing-up\" style=\"position:relative;\"><a href=\"#summing-up\" aria-label=\"summing up permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summing up!!</h3>\n<p>VIM makes you write code at the speed of thoughts. Just get started, and the rest will follow. Steal your friend's vimrc or find one on the internet (there are tons of them) if you don't want to make one of your own.</p>\n<p>If you want to slowly blend in into the world of vim then use some vim plugin for your text editor. All popular text editors have a vim plugin ( <a href=\"https://marketplace.visualstudio.com/items?itemName=vscodevim.vim\">Here's one for VsCode </a>)\nHere you go, best of both worlds! When you're comfortable enough, go for that complete switch.</p>\n<p><img src=\"/83a1cd4054ef50dc629a6846d30d87b3/vscodevim.webp\" alt=\"vscodevim\"></p>\n<p>Here's how my vim setup looks.</p>\n<p><img src=\"/aa9e337b13aca7c3043c49bba3b61a23/Vim.webp\" alt=\"Vim\"></p>\n<p>Now go give it a try. I wish you luck!!</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"date":"October 08, 2020","updated_date":null,"description":"Vim is Vi's newest and most common reincarnation that is supported on every known platform, check out the article to learn about what is ViM, and why to use it.","title":"Vim: What is it and Why to use it?","tags":["Vim","Text Editor"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/aa9e337b13aca7c3043c49bba3b61a23/58556/Vim.webp","srcSet":"/static/aa9e337b13aca7c3043c49bba3b61a23/61e93/Vim.webp 200w,\n/static/aa9e337b13aca7c3043c49bba3b61a23/1f5c5/Vim.webp 400w,\n/static/aa9e337b13aca7c3043c49bba3b61a23/58556/Vim.webp 800w,\n/static/aa9e337b13aca7c3043c49bba3b61a23/99238/Vim.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Shubhankar Khare","github":"iamshubhankarkhare","avatar":null}}}},{"node":{"excerpt":"Generally, MIM attacks are breaking to believe the traditional encryption technologies and targeting the intermediate nodes between the…","fields":{"slug":"/engineering/learn-about-vdn-for-cybersecurity/"},"html":"<p>Generally, MIM attacks are breaking to believe the traditional encryption technologies and targeting the intermediate nodes between the sender and receiver.</p>\n<h2 id=\"what-is-a-mim-attack\" style=\"position:relative;\"><a href=\"#what-is-a-mim-attack\" aria-label=\"what is a mim attack permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is a MIM attack?</h2>\n<p>MIM stands for man-in-the-middle. In the World of Cybersecurity, a man-in-the-middle attack (MIM) is an attack where the attacker breaks into the middle of the network pathway silently such that the sender and receiver are not able to intercept and they believe they are directly communicating with each other. One such example of a MIM attack is active eavesdropping. In this example, an attacker can be sitting with a piece of software somewhere in the network path and capturing all the relevant network traffic for later analysis. The attacker can intercept all relevant messages passing between the two victims and by smartly monitor and alter old ones or inject new ones. It can become complicated and arise problems for the organization.</p>\n<h2 id=\"does-the-question-arise-how-about-using-ssl-and-virtual-private-networks\" style=\"position:relative;\"><a href=\"#does-the-question-arise-how-about-using-ssl-and-virtual-private-networks\" aria-label=\"does the question arise how about using ssl and virtual private networks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Does the question arise how about using SSL and Virtual Private Networks?</h2>\n<p>SSL and Virtual Private Networks do not always protect messages as they travel across intermediary pathways. So, that where virtual dispersive networking comes into the picture.</p>\n<p>VDN follows the approaches or methods of traditional military radio spread spectrum security. Radios rotate through the frequencies randomly, and communications are divided or split into multiple pieces (or streams). So now, only one receiving radios are programmed to reassemble these pieces into their original form.\nVDN divides the original message into some multiple parts, and it will encrypt each component separately and routes them over many servers, computers, and even mobile phones. The data also move out dynamically to optimum paths — both randomizing the paths the messages take while simultaneously taking into the server congestion or other network issues.\nWhen it comes to the role of Hackers, they are left scrambling to find out data parts as they go through like data centers, Cloud, Internet, and so on. </p>\n<h2 id=\"why-virtual-dispersive-networking\" style=\"position:relative;\"><a href=\"#why-virtual-dispersive-networking\" aria-label=\"why virtual dispersive networking permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Virtual Dispersive Networking?</h2>\n<ol>\n<li>Unparalleled Security: Dispersing the data over multiple different paths, eliminates the Man-in-the-Middle threat. Hackers can only obtain a small chunk of the original data on any given pathway, rendering any data obtained meaningless and nearly impossible to decrypt.</li>\n<li>Network Resilience: Suppose a connection is lost on any of the several pathways due to network failure,\ndata packets are then rerouted to an already existing path, or an additional path is established which leads us resulting in negligible network downtime.</li>\n<li>Speed / Performance: Since the data-flow is from multiple independent paths using unique methods, it increases available bandwidth and optimizes data flow on individual pathways. Therefore, speed and performance are improved.</li>\n</ol>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>Today, Dispersive Technologies' business is largely government-centric, with initial forays into commercial industries with high-value targets like banks and utilities. There are many opportunities for Dispersive technology in the cloud computing world. The cloud can host the redirects at the center of their methodology without much of a stretch. However, cloud conditions can use Dispersive to set up secure communications between clouds or between on-premise information. These hybrid cloud situations regularly rely on VPNs, which will, in general, be flaky and moderate. Dispersive Technologies have become replacement of VPNs, thereby improving the security, performance, and manageability of hybrid clouds as well as virtual private clouds. </p>\n<p>As with any industry, change can be frightening (especially when sensitive data is part of the equation), but if the organization is aware of the new developments, they can begin implementing some of these security technologies into their existing IT infrastructure and enjoy some peace of mind without worrying about future threats.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"October 07, 2020","updated_date":null,"description":"Learn About VDN for CyberSecurity","title":"Virtual Dispersive Networking","tags":["VDN","Cyber Security"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/d2e724f66a1588268845362a0ddec71b/58556/MIM.webp","srcSet":"/static/d2e724f66a1588268845362a0ddec71b/61e93/MIM.webp 200w,\n/static/d2e724f66a1588268845362a0ddec71b/1f5c5/MIM.webp 400w,\n/static/d2e724f66a1588268845362a0ddec71b/58556/MIM.webp 800w,\n/static/d2e724f66a1588268845362a0ddec71b/210c1/MIM.webp 900w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Binay Agarwal","github":"agarwalBinay18","avatar":null}}}},{"node":{"excerpt":"React context API, In this article you will explore what is Context API, what is react context API and how to use it in your React project…","fields":{"slug":"/engineering/react-context-api/"},"html":"<p>React context API, In this article you will explore what is Context API, what is react context API and how to use it in your React project. The Context API is a React structure that enables you to exchange unique details and assists in solving prop-drilling from all levels of your application.</p>\n<h2 id=\"what-is-context-api\" style=\"position:relative;\"><a href=\"#what-is-context-api\" aria-label=\"what is context api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Context API?</h2>\n<p>The React Context API is a way for a React app to effectively produce global variables that can be passed around. This is the alternative to \"prop drilling\" or moving props from grandparent to child to parent, and so on. Context is also touted as an easier, lighter approach to state management using Redux.</p>\n<p>Talking about the Context APIs, they’re a (kind of) new feature added in version 16.3 of React that allows one to share state across the entire app (or part of it) lightly and with ease.</p>\n<h2 id=\"react-context-api-how-it-works\" style=\"position:relative;\"><a href=\"#react-context-api-how-it-works\" aria-label=\"react context api how it works permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>React context API: How it works?</h2>\n<p>React.createContext() is all you need. It returns a consumer and a provider. <strong>Provider</strong> is a component that as it's names suggests provides the state to its children. It will hold the \"store\" and be the parent of all the components that might need that store. Apart from the react context <strong>Provider</strong>, <strong>Consumer</strong> as it so happens is a component that consumes and uses the state. More information can be found on <a href=\"https://reactjs.org/docs/context.html\">React's documentation page</a></p>\n<h2 id=\"context-api-will-replace-redux\" style=\"position:relative;\"><a href=\"#context-api-will-replace-redux\" aria-label=\"context api will replace redux permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Context API will replace redux?</h2>\n<p>No. Well, not entirely.  </p>\n<p>Redux is great and came perfectly to answer the need for state management. Actually, it answered this need so well that it came to be known that you can't be a \"true\" React developer if you don't know your way around Redux.\nHowever, Redux has its disadvantages, and that's why it's important to know what Context API gives us that Redux doesn't:</p>\n<ul>\n<li>\n<p>Simplicity - When using redux people tend to manage almost all of their state in redux and it causes 2 problems:  </p>\n<ol>\n<li>Overhead - Why should I create/update 3 files just to add one tiny feature? </li>\n<li>One of the significant advantages of React's one-way data binding is that it's easy to understand - A component passes state to its children. Using Redux takes it away from us.</li>\n</ol>\n</li>\n<li>Using Context API we can define several unrelated contexts (stores) and use each in its proper place in the app.  </li>\n</ul>\n<h3 id=\"important-note\" style=\"position:relative;\"><a href=\"#important-note\" aria-label=\"important note permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Important Note</h3>\n<p>Redux is just a concept. If you are comfortable with using reducers and actions and don't find hindering than you may also create reducers and actions that wrap Context API as the store as Redux's author <strong>Dan Abramov</strong> explained in <a href=\"https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367\">his medium article about whether Redux is always required</a></p>\n<h2 id=\"how-to-use-context-api\" style=\"position:relative;\"><a href=\"#how-to-use-context-api\" aria-label=\"how to use context api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to use Context API?</h2>\n<p>You might think to yourself: \"Well, I'm convinced. How do I implement Context API in react for my app?\" First, make sure you need it. Sometimes people use shared state across nested components instead of just passing it as props. And if you do need it you should follow these very few steps:</p>\n<ol>\n<li>Create a folder under your app root named contexts (not required. just a convention)</li>\n<li>Create a file named &#x3C;your context name>Context.js, e.g. userContext.js</li>\n<li>import and create a context like so:</li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">React</span><span class=\"mtk1\">, { </span><span class=\"mtk12\">createContext</span><span class=\"mtk1\"> } </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;react&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk12\">UserContext</span><span class=\"mtk1\"> = </span><span class=\"mtk11\">createContext</span><span class=\"mtk1\">();</span></span></code></pre>\n<ol start=\"4\">\n<li>Create a component that will wrap the provider named <your context name>Provider e.g. UserProvider<br>\nExample using React Hooks:</li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk11\">UserProvider</span><span class=\"mtk1\"> = ({ </span><span class=\"mtk12\">children</span><span class=\"mtk1\"> }) </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> [</span><span class=\"mtk12\">name</span><span class=\"mtk1\">, </span><span class=\"mtk12\">setName</span><span class=\"mtk1\">] = </span><span class=\"mtk11\">useState</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;John Doe&quot;</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> [</span><span class=\"mtk12\">age</span><span class=\"mtk1\">, </span><span class=\"mtk12\">setAge</span><span class=\"mtk1\">] = </span><span class=\"mtk11\">useState</span><span class=\"mtk1\">(</span><span class=\"mtk7\">1</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk11\">happyBirthday</span><span class=\"mtk1\"> = () </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> </span><span class=\"mtk11\">setAge</span><span class=\"mtk1\">(</span><span class=\"mtk12\">age</span><span class=\"mtk1\"> + </span><span class=\"mtk7\">1</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">UserContext.Provider</span><span class=\"mtk1\"> </span><span class=\"mtk12\">value</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk1\">{ </span><span class=\"mtk12\">name</span><span class=\"mtk1\">, </span><span class=\"mtk12\">age</span><span class=\"mtk1\">, </span><span class=\"mtk12\">happyBirthday</span><span class=\"mtk1\"> }</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk4\">{</span><span class=\"mtk12\">children</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">UserContext.Provider</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">};</span></span></code></pre>\n<ol start=\"5\">\n<li>Create a higher order component to consume the context named: with<your context name> e.g. withUser<br>\nExample using React Hooks:</li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk11\">withUser</span><span class=\"mtk1\"> = (</span><span class=\"mtk12\">Child</span><span class=\"mtk1\">) </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">props</span><span class=\"mtk1\">) </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">UserContext.Consumer</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">{</span><span class=\"mtk1\">(</span><span class=\"mtk12\">context</span><span class=\"mtk1\">) </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Child</span><span class=\"mtk1\"> </span><span class=\"mtk4\">{</span><span class=\"mtk1\">...</span><span class=\"mtk12\">props</span><span class=\"mtk4\">}</span><span class=\"mtk1\"> </span><span class=\"mtk4\">{</span><span class=\"mtk1\">...</span><span class=\"mtk12\">context</span><span class=\"mtk4\">}</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">{</span><span class=\"mtk3\">/* Another option is:  {context =&gt; &lt;Child {...props} context={context}/&gt;}*/</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">UserContext.Consumer</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">);</span></span></code></pre>\n<p>The difference between the two options above is if you want the context to be a single nested property by this name, to explode it to its properties (which in my opinion is more convenient).</p>\n<ol start=\"6\">\n<li>Finally export them</li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> { </span><span class=\"mtk12\">UserProvider</span><span class=\"mtk1\">, </span><span class=\"mtk12\">withUser</span><span class=\"mtk1\"> };</span></span></code></pre>\n<ol start=\"7\">\n<li>And use them however you like<br>\nFor example:</li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk12\">ReactDOM</span><span class=\"mtk1\">.</span><span class=\"mtk11\">render</span><span class=\"mtk1\">(</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">UserProvider</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">App</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">UserProvider</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk12\">document</span><span class=\"mtk1\">.</span><span class=\"mtk11\">getElementById</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;root&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">);</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk11\">withUser</span><span class=\"mtk1\">(</span><span class=\"mtk12\">LoginForm</span><span class=\"mtk1\">);</span></span></code></pre>\n<p>You'll also be able to notice I used the new \"<a href=\"https://www.loginradius.com/blog/engineering/react-hooks-guide/\">Hooks</a>\" feature that is shipped with React since version 16.8 to make it even neater and easier to create contexts.</p>\n<h3 id=\"final-piece-of-advice\" style=\"position:relative;\"><a href=\"#final-piece-of-advice\" aria-label=\"final piece of advice permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Final piece of advice</h3>\n<p>I mentioned how people overuse Redux, and it also applies to Context API. Use it only when you need to share state between lot's of components with a lot of nesting.\nMost of the time, the data you have in one component will only be relevant to its children, so passing it in props is more indicative and nicer.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n  .dark-default-dark .mtk17 { color: #808080; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n</style>","frontmatter":{"date":"October 07, 2020","updated_date":null,"description":"Context API is a (kind of) new feature added in version 16.3 of React that allows one to share state across the entire app (or part of it) lightly and with ease. Let's see how to use it.","title":"React Context API: What is it and How it works?","tags":["React","Redux","Hooks"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5151515151515151,"src":"/static/6fc42d03576ecaa3bcc58404bdc7afc5/58556/react.webp","srcSet":"/static/6fc42d03576ecaa3bcc58404bdc7afc5/61e93/react.webp 200w,\n/static/6fc42d03576ecaa3bcc58404bdc7afc5/1f5c5/react.webp 400w,\n/static/6fc42d03576ecaa3bcc58404bdc7afc5/58556/react.webp 800w,\n/static/6fc42d03576ecaa3bcc58404bdc7afc5/99238/react.webp 1200w,\n/static/6fc42d03576ecaa3bcc58404bdc7afc5/ce765/react.webp 1499w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Eylon Ronen","github":"eylonronen","avatar":null}}}}]},"markdownRemark":{"excerpt":"Introduction Ever wondered how apps like Spotify, Netflix, or Slack manage seamless login experiences across devices? Many of them use JWT…","fields":{"slug":"/engineering/how-to-integrate-jwt/"},"html":"<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>Ever wondered how apps like Spotify, Netflix, or Slack manage seamless login experiences across devices? Many of them use JWT, or JSON Web Tokens, a compact, stateless method for securely transmitting user identity and session data across services.</p>\n<p>With JWT token authentication, identity information is embedded in a signed token, allowing you to maintain user sessions without server-side storage. This approach is highly scalable and ideal for modern architectures like SPAs, mobile apps, and microservices.</p>\n<p>In this blog, we’ll walk you through what is JWT, why use it, and how to implement JWT authentication using LoginRadius. </p>\n<p>You’ll learn what JWT is, why it’s effective, and how it works in real-world applications. We'll cover both integration methods (IDX and Direct API), generating your signing key, managing sessions, storing the JWT token securely, and applying best practices throughout.</p>\n<p>Whether you're a developer, product manager, or IAM architect, this guide offers a complete foundation for implementing JWT token authentication into your application stack.</p>\n<h2 id=\"what-is-jwt\" style=\"position:relative;\"><a href=\"#what-is-jwt\" aria-label=\"what is jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is JWT?</h2>\n<p><a href=\"https://www.loginradius.com/blog/engineering/jwt/\">JSON Web Token (JWT)</a> is an open standard (RFC 7519) used to transmit information securely between parties as a JSON object. It’s compact, self-contained, and digitally signed, making it a reliable format for authentication and authorization across modern applications.</p>\n<p>A JWT consists of three parts:</p>\n<ol>\n<li><strong>Header –</strong> Contains metadata like the type of token and signing algorithm (e.g., HS256).</li>\n<li><strong>Payload –</strong> Stores the actual data or “claims,” such as user ID, roles, and token expiry.</li>\n<li><strong>Signature –</strong> A cryptographic hash that ensures the token hasn’t been tampered with.</li>\n</ol>\n<p><em>Example of a token structure:</em></p>\n<p>&#x3C;base64Header>.&#x3C;base64Payload>.&#x3C;signature></p>\n<h2 id=\"why-use-jwt\" style=\"position:relative;\"><a href=\"#why-use-jwt\" aria-label=\"why use jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Use JWT?</h2>\n<ul>\n<li><strong>Stateless Authentication</strong>: No server-side session storage is needed — the token holds all necessary user info. </li>\n<li><strong>Portable</strong>: Works seamlessly across domains, services, and APIs. </li>\n<li><strong>Scalable</strong>: Ideal for microservices, SPAs, mobile apps, and serverless functions. </li>\n<li><strong>Interoperable</strong>: JWTs are supported across many languages and frameworks.</li>\n</ul>\n<h2 id=\"how-jwt-works\" style=\"position:relative;\"><a href=\"#how-jwt-works\" aria-label=\"how jwt works permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How JWT Works?</h2>\n<p><img src=\"/f29edbf2978577390c7ffa02e9bc4dda/lr-JWT-authentication.webp\" alt=\"Flowchart illustrating LoginRadius JWT authentication via Identity Provider (IDP), showing user redirection from login icon to login page, authentication with IDP, JWT token validation, and subsequent redirection to the customer&#x27;s website or error page based on validation results.\"></p>\n<ol>\n<li>A user logs in with credentials. </li>\n<li>Your app (or identity provider like LoginRadius) issues a signed JWT. </li>\n<li>The client stores the token and sends it with each request (usually in the Authorization header). </li>\n<li>The server validates the token’s signature and claims. </li>\n<li>If valid, access is granted — without any session stored on the backend.</li>\n</ol>\n<p>JWT simplifies identity verification, especially when you're building apps that talk to APIs or need to scale without centralized session storage.</p>\n<h2 id=\"jwt-authentication-with-loginradius-overview\" style=\"position:relative;\"><a href=\"#jwt-authentication-with-loginradius-overview\" aria-label=\"jwt authentication with loginradius overview permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JWT Authentication with LoginRadius: Overview</h2>\n<p>LoginRadius provides robust support for JWT (JSON Web Token) authentication, which allows for flexible and secure access control across different digital platforms. Whether you're building a fully custom identity flow or using a pre-built interface, the platform supports various integration approaches depending on your architecture.</p>\n<p>If you're looking to understand how to implement JWT token authentication effectively, LoginRadius offers two primary implementation models that cater to different levels of customization and control:</p>\n<h3 id=\"1-idx-implementation--jwt-through-a-hosted-login-page\" style=\"position:relative;\"><a href=\"#1-idx-implementation--jwt-through-a-hosted-login-page\" aria-label=\"1 idx implementation  jwt through a hosted login page permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. IDX Implementation – JWT through a Hosted Login Page</h3>\n<p>The IDX-hosted login approach enables secure, standards-compliant, JWT-based authentication without requiring you to build a custom login interface. This is a strategic option for fast, compliant, and user-friendly deployments.</p>\n<ul>\n<li>The Identity Experience Framework (IDX) comes with a fully custom branded hosted login page.</li>\n<li>Once the user logs in and gets enrolled, the user’s JWTs are automatically generated and issued. These tokens can be utilized for managing user sessions and accessing the APIs.</li>\n<li>This approach simplifies deployment without compromising on user experience and security standards.</li>\n</ul>\n<h3 id=\"configuration-steps\" style=\"position:relative;\"><a href=\"#configuration-steps\" aria-label=\"configuration steps permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Configuration Steps:</strong></h3>\n<ol>\n<li>Enable JWT Login</li>\n<li>Go to <a href=\"https://console.loginradius.com/authentication/authentication-configuration\">authentication configuration settings</a> and enable JWT Login in the Admin Console.</li>\n</ol>\n<p><img src=\"/9fb19dd9c88c7916aeebd03ab6e661b7/lr-admin-console.webp\" alt=\"Screenshot of LoginRadius Admin Console showing JWT Custom IDP configuration interface with options for provider name, algorithm (HS256), key entry, clock skew, and expiration time settings.\"></p>\n<ol start=\"2\">\n<li>Specify your signing algorithm and expiry policy, and define your JWT Secret Key.</li>\n<li>Input a secure JWT signing key.</li>\n<li>Specify token expiry duration (e.g., 15–60 minutes)</li>\n<li>Select the desired algorithm —HS256 for symmetric signing (same key signs and verifies)</li>\n<li>RS256 for asymmetric signing, where LoginRadius securely stores the private key used to sign the JWT.</li>\n<li>Your app or backend service uses the public key to validate the token signature.</li>\n<li>LoginRadius provides a JWKS (JSON Web Key Set) endpoint to dynamically fetch and rotate public keys, ensuring trust without key exposure.</li>\n<li>Update IDX Template for Callback</li>\n<li>Modify your IDX login page template to retrieve the JWT post-login. You can access the token via redirect URL parameters or secure JavaScript callbacks.</li>\n</ol>\n<h3 id=\"example-response\" style=\"position:relative;\"><a href=\"#example-response\" aria-label=\"example response permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example Response:</h3>\n<p>{</p>\n<p>  \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR...\",</p>\n<p>  \"expires_in\": 1800</p>\n<p>}</p>\n<p>This integration approach works best for all teams that want effective identity workflows without the complexity of building proprietary login screens, something that is crucial for customer portals, onboarding of mobile applications, and even managing access for business partners.</p>\n<h3 id=\"2-direct-api-implementation--self-managed-login\" style=\"position:relative;\"><a href=\"#2-direct-api-implementation--self-managed-login\" aria-label=\"2 direct api implementation  self managed login permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Direct API Implementation – Self Managed Login</h3>\n<p>If you’re building a custom login UI or working in a headless environment, LoginRadius lets you generate and handle JWTs directly through its <a href=\"https://www.loginradius.com/docs/api/v2/customer-identity-api/\">Authentication APIs</a>. Here’s how you can programmatically perform token authentication using the classic method:</p>\n<ul>\n<li>For custom front-end applications, LR offers an API to authenticate users and issue JWT tokens.</li>\n<li>In response to the login request, the developers are provided with signed tokens that can be validated on the client’s side or by downstream services.</li>\n<li>This method is best fit for enterprise applications that have complex custom workflows or are designed to be embedded into other applications.</li>\n</ul>\n<h3 id=\"configuration-steps-1\" style=\"position:relative;\"><a href=\"#configuration-steps-1\" aria-label=\"configuration steps 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Configuration Steps:</strong></h3>\n<h4 id=\"step-1-authenticate-via-api\" style=\"position:relative;\"><a href=\"#step-1-authenticate-via-api\" aria-label=\"step 1 authenticate via api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 1: Authenticate via API:</h4>\n<ul>\n<li>\n<p>Send a POST login request to the LR Authentication URL: </p>\n<p>POST /identity/v2/auth/login</p>\n</li>\n</ul>\n<p>Include the user’s credentials (email + password) in the request body.</p>\n<h4 id=\"step-2-get-jwt-in-response\" style=\"position:relative;\"><a href=\"#step-2-get-jwt-in-response\" aria-label=\"step 2 get jwt in response permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 2: Get JWT in Response</h4>\n<ul>\n<li>If the user credentials are authentic, then the JWT token will be available in response.</li>\n</ul>\n<p>{</p>\n<p> \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",</p>\n<p> \"expires_in\": 3600</p>\n<p>}</p>\n<h4 id=\"step-3-jwt-decoding-and-validation\" style=\"position:relative;\"><a href=\"#step-3-jwt-decoding-and-validation\" aria-label=\"step 3 jwt decoding and validation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 3: JWT Decoding and Validation</h4>\n<ul>\n<li>Use any JWT library (e.g., jsonwebtoken for Node.js or pyjwt for Python) to decode the token.</li>\n<li>Validate the signature using your configured secret key.</li>\n<li>Confirm claims like exp, iat, aud, and iss.</li>\n</ul>\n<h4 id=\"step-4-set-custom-claims-optional\" style=\"position:relative;\"><a href=\"#step-4-set-custom-claims-optional\" aria-label=\"step 4 set custom claims optional permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step 4: Set Custom Claims (Optional)</h4>\n<p>With LoginRadius, it is possible to customize the payload to include user roles and/or any additional metadata. You can set custom JWT claims on the Admin Console.</p>\n<p>With this method, you have complete customization over login flows while using LoginRadius to issue signed JWTs for user session management.</p>\n<p><strong>NOTE-</strong> With either method, LoginRadius ensures that JWTs are securely signed, optionally short-lived, and compatible with standard token validation libraries, making integration seamless for everyone.</p>\n<p>To get started with JWT implementation, you can<a href=\"https://www.loginradius.com/docs/single-sign-on/federated-sso/jwt-login/jwt-implementation-guide/\"> read our complete developer documentation</a>. </p>\n<h2 id=\"hosted-login-vs-direct-api\" style=\"position:relative;\"><a href=\"#hosted-login-vs-direct-api\" aria-label=\"hosted login vs direct api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Hosted Login vs Direct API</h2>\n<p><img src=\"/15ec02ac98d24a9f1f28e5d0f06b9174/IDX-vs-Direct-API-JWT.webp\" alt=\"Illustration showing IDX vs Direct API JWT flow diagram comparing LoginRadius JWT authentication methods via Hosted Login Page (IDX) and Custom Login UI using Direct API, illustrating user login, JWT issuance, and token return process.\"></p>\n<h2 id=\"what-is-session-management-and-how-it-works-with-jwt\" style=\"position:relative;\"><a href=\"#what-is-session-management-and-how-it-works-with-jwt\" aria-label=\"what is session management and how it works with jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Session Management and How It Works with JWT</h2>\n<p><a href=\"https://www.loginradius.com/blog/identity/user-session-management/\">Session management </a>is how your app keeps track of a user after they log in so they don’t have to prove who they are with every request.</p>\n<p>In traditional apps, sessions are stored on the server using session IDs. Every time a request comes in, the server checks that session ID to verify the user.</p>\n<p>In modern apps, especially SPAs and APIs, JWTs are used to manage sessions without needing server-side storage; this is called stateless session management. The token itself carries the user’s identity, roles, and expiration details. As long as the token is valid, the user stays logged in.</p>\n<p>Good session management ensures:</p>\n<ul>\n<li>Security against session hijacking</li>\n<li>Fast user validation without hitting a database</li>\n<li>Smooth experiences with token refresh strategies</li>\n</ul>\n<h2 id=\"how-loginradius-handles-session-management-with-jwt\" style=\"position:relative;\"><a href=\"#how-loginradius-handles-session-management-with-jwt\" aria-label=\"how loginradius handles session management with jwt permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How LoginRadius Handles Session Management with JWT:</h2>\n<ol>\n<li>\n<p>User Logs In </p>\n<ul>\n<li>LoginRadius returns an access token (JWT) and, optionally, a refresh token.</li>\n</ul>\n</li>\n<li>\n<p>Client Stores the Token </p>\n<ul>\n<li>Access tokens are stored in memory, sessionStorage, or secure cookies. </li>\n<li>They’re sent on every request via the Authorization: Bearer header. </li>\n</ul>\n</li>\n<li>\n<p>Access Token Expiry </p>\n<ul>\n<li>These tokens are short-lived by design (e.g., 15–30 minutes). </li>\n<li>Once expired, the client can use the refresh token to request a new access token. </li>\n</ul>\n</li>\n<li>\n<p>Token Renewal </p>\n<ul>\n<li>LoginRadius validates the refresh token and issues a new JWT, i.e., no user re-authentication is needed. </li>\n<li>Refresh tokens can be revoked at any time.</li>\n</ul>\n</li>\n<li>Logout and Token Revocation Strategy</li>\n</ol>\n<p>When the user logs out, both the access token and refresh token should be cleared from client storage.</p>\n<ul>\n<li>The refresh token can be explicitly revoked via the LoginRadius API, terminating the ability to renew sessions. </li>\n<li>\n<p>However, access tokens are stateless and cannot be revoked mid-lifecycle unless: </p>\n<ul>\n<li>You maintain a blacklist of token IDs (jti claims) and check them on each request. </li>\n<li>You use short-lived access tokens to limit exposure naturally. </li>\n<li>Or, you rotate your JWT signing key, invalidating all previously issued tokens. </li>\n</ul>\n</li>\n</ul>\n<p>Combining these strategies gives you greater control over token misuse and enables a robust, enterprise-grade logout flow. </p>\n<p><a href=\"https://www.loginradius.com/resource/whitepaper/secure-api-using-oauth2\"><img src=\"/e55ae4bbc8ce62e13f03e46e29ebe7cc/api-economy.webp\" alt=\"illustration showing LoginRadius free downloadable resource named API economy is transforming digitization: how to secure it using oauth 2.0.\"></a></p>\n<h2 id=\"how-to-store-jwt-tokens\" style=\"position:relative;\"><a href=\"#how-to-store-jwt-tokens\" aria-label=\"how to store jwt tokens permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to Store JWT Tokens?</h2>\n<p>When you implement JWT-based authentication, the client (browser or mobile app) needs a way to store the access token and, optionally, the refresh token after they are issued by the authentication server. This stored token is then attached to every subsequent request to prove the user's identity.</p>\n<p>Choosing where to store the JWT is a crucial security decision. The most common storage options are:</p>\n<ul>\n<li>localStorage</li>\n<li>sessionStorage</li>\n<li>HTTP-only cookies</li>\n</ul>\n<p>Each option has trade-offs between security, accessibility, and persistence, and the right choice depends on your application's architecture and threat model.</p>\n<h4 id=\"recommended-storage-strategy\" style=\"position:relative;\"><a href=\"#recommended-storage-strategy\" aria-label=\"recommended storage strategy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Recommended Storage Strategy</h4>\n<ul>\n<li>\n<p>Access Tokens </p>\n<ul>\n<li>For SPAs: store in memory or sessionStorage for short-term access </li>\n<li>If stored in the browser, protect against XSS </li>\n</ul>\n</li>\n<li>\n<p>Refresh Tokens</p>\n<ul>\n<li>Always store the JWT refresh token in HTTP-only secure cookies to prevent JavaScript access. This adds a critical layer of protection against XSS attacks.</li>\n<li>Combine with SameSite=Strict or SameSite=Lax attributes to mitigate CSRF risks and ensure the JWT refresh token is only sent in intended contexts.</li>\n</ul>\n</li>\n</ul>\n<h2 id=\"best-practices-for-storing-jwts\" style=\"position:relative;\"><a href=\"#best-practices-for-storing-jwts\" aria-label=\"best practices for storing jwts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Best Practices for Storing JWTs</h2>\n<ol>\n<li>Never store sensitive tokens (like refresh tokens) in localStorage or sessionStorage.</li>\n<li>Use Secure and HttpOnly flags with cookies to prevent JavaScript access and ensure transmission only over HTTPS.</li>\n<li>Set the SameSite=Strict or Lax attribute on cookies to protect against CSRF.</li>\n<li>Use short-lived access tokens and rotate refresh tokens regularly.</li>\n<li>Implement CSP (Content Security Policy) to reduce XSS risk.</li>\n<li>Avoid storing any tokens in frontend code (e.g., hardcoded in JS files).</li>\n</ol>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>JWT authentication with LoginRadius offers a modern, stateless approach to managing sessions across distributed systems. The IDX integration is ideal for rapid deployment, while the Direct API model is best for organizations needing deep customization and integration flexibility.</p>\n<p>With robust token signing, refresh capabilities, and centralized control, LoginRadius provides a future-ready foundation for secure, scalable identity architecture. <a href=\"https://www.loginradius.com/contact-us?utm_source=blog&#x26;utm_medium=web&#x26;utm_campaign=how-to-integrate-jwt\">Contact us</a> to know more about JWT authentication and implementation guide. </p>\n<h2 id=\"faqs\" style=\"position:relative;\"><a href=\"#faqs\" aria-label=\"faqs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>FAQs</h2>\n<h3 id=\"1-what-is-jwt-authentication-used-for\" style=\"position:relative;\"><a href=\"#1-what-is-jwt-authentication-used-for\" aria-label=\"1 what is jwt authentication used for permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. What is JWT authentication used for?</h3>\n<p><strong>A:</strong> JWT authentication securely verifies user identities, enabling stateless session management across web, mobile apps, and microservices without server-side session storage.</p>\n<h3 id=\"2-how-does-loginradius-simplify-jwt-integration\" style=\"position:relative;\"><a href=\"#2-how-does-loginradius-simplify-jwt-integration\" aria-label=\"2 how does loginradius simplify jwt integration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. How does LoginRadius simplify JWT integration?</h3>\n<p><strong>A:</strong> LoginRadius simplifies JWT integration by offering hosted <a href=\"https://www.loginradius.com/docs/single-sign-on/federated-sso/jwt-login/jwt-implementation-guide/\">IDX login pages </a>and direct API-based authentication methods, enabling rapid deployment and deep customization.</p>\n<h3 id=\"3-is-jwt-authentication-secure\" style=\"position:relative;\"><a href=\"#3-is-jwt-authentication-secure\" aria-label=\"3 is jwt authentication secure permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. Is JWT authentication secure?</h3>\n<p><strong>A:</strong> Yes, JWT authentication is secure when implemented with best practices like short-lived tokens, secure storage methods, signature validation, and refresh token rotation.</p>\n<h3 id=\"4-can-jwt-tokens-be-revoked-with-loginradius\" style=\"position:relative;\"><a href=\"#4-can-jwt-tokens-be-revoked-with-loginradius\" aria-label=\"4 can jwt tokens be revoked with loginradius permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. Can JWT tokens be revoked with LoginRadius?</h3>\n<p><strong>A:</strong> Yes, LoginRadius allows<a href=\"https://www.loginradius.com/docs/api/v2/customer-identity-api/refresh-token/revoke-refresh-token/?q=revoke+jwt\"> revocation of JWT</a> refresh tokens explicitly, and supports strategies like short-lived tokens and key rotation to manage token lifecycles securely.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"April 15, 2025","updated_date":null,"description":"Discover JWT (JSON Web Token) authentication, its advantages, and how to integrate it seamlessly using LoginRadius' hosted IDX and Direct API methods for secure, scalable identity management.","title":"JWT Authentication with LoginRadius: Quick Integration Guide","tags":["JWT","JSON Web Token","Authentication","Authorization"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":0.7782101167315175,"src":"/static/4cedb7829f98208cbc6d5a9aea4e983d/58556/how-to-integrate-jwt.webp","srcSet":"/static/4cedb7829f98208cbc6d5a9aea4e983d/61e93/how-to-integrate-jwt.webp 200w,\n/static/4cedb7829f98208cbc6d5a9aea4e983d/1f5c5/how-to-integrate-jwt.webp 400w,\n/static/4cedb7829f98208cbc6d5a9aea4e983d/58556/how-to-integrate-jwt.webp 800w,\n/static/4cedb7829f98208cbc6d5a9aea4e983d/1cc9f/how-to-integrate-jwt.webp 896w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Kundan Singh","github":null,"avatar":null}}}},"pageContext":{"limit":6,"skip":150,"currentPage":26,"type":"//engineering//","numPages":53,"pinned":"5c425581-f474-5ae9-abe7-cf5342db2aaa"}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}