{"componentChunkName":"component---src-templates-blog-list-template-js","path":"/engineering/20","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"excerpt":"What is PGP? PGP (Pretty Good Privacy) is a cryptographic process used to encrypt and decrypt information. It combines concepts from…","fields":{"slug":"/engineering/using-pgp-encryption-with-nodejs/"},"html":"<h2 id=\"what-is-pgp\" style=\"position:relative;\"><a href=\"#what-is-pgp\" aria-label=\"what is pgp 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 PGP?</h2>\n<p>PGP (Pretty Good Privacy) is a cryptographic process used to encrypt and decrypt information. It combines concepts from symmetric and asymmetric key encryption, maintaining some of the best security and usability aspects of both.</p>\n<p>One way PGP can be used is to protect the confidentiality of information. Once the information is encrypted, nobody will be able to decrypt it unless they have the right key. In practice, PGP is commonly used in sending and receiving emails, sharing information on the Dark Web, and others. This is because both on and off the Internet, there are ways to intercept information being sent, making encryption using PGP or similar critical.</p>\n<p>On a high-level the process between a sender and receiver looks like this:</p>\n<ol>\n<li>The recipient generates public and private keys.</li>\n<li>The recipient sends its public key to the sender.</li>\n<li>The sender encrypts the message using the given public key.</li>\n<li>The sender sends the encrypted message to the recipient.</li>\n<li>The recipient decrypts the message using its private key.</li>\n</ol>\n<h2 id=\"pgp-examples-in-nodejs\" style=\"position:relative;\"><a href=\"#pgp-examples-in-nodejs\" aria-label=\"pgp examples in nodejs 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>PGP Examples in Node.js</h2>\n<p>Now, let's go over some examples in Node.js using the <a href=\"https://www.npmjs.com/package/openpgp\">openpgp library</a>.</p>\n<ul>\n<li>OpenPGP is a protocol that defines the standards for PGP. OpenPGP.js implements the OpenPGP protocol in JavaScript.</li>\n</ul>\n<p>We'll go over some basic examples and show how to encrypt &#x26; decrypt large files using Node.js streams.</p>\n<p>First, set up your Node.js project and install openpgp.js:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">mkdir pgp-tutorial && cd pgp-tutorial && npm init</span>\n<span class=\"grvsc-line\">npm i openpgp --save</span></code></pre>\n<p>Note: examples use openpgp v4.10.8</p>\n<h3 id=\"generating-keys\" style=\"position:relative;\"><a href=\"#generating-keys\" aria-label=\"generating keys 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>Generating keys</h3>\n<p>When generating private and public PGP keys with OpenPGP, you can define which curve to use in Elliptic-curve cryptography. In this example, we use Ed25519 for its performance and small key size. For the full list of curves, you can choose from, refer to OpenPGP.js docs.</p>\n<p>You also need to define a passphrase used to decrypt files and the private key. In practice, this should be a strong, randomized secret generated for a single-use.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">// generate-keys.js</span>\n<span class=\"grvsc-line\">const openpgp = require(&quot;openpgp&quot;);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">generate();</span>\n<span class=\"grvsc-line\">async function generate() {</span>\n<span class=\"grvsc-line\">  const { privateKeyArmored, publicKeyArmored } = await openpgp.generateKey({</span>\n<span class=\"grvsc-line\">    userIds: [{ name: &quot;person&quot;, email: &quot;person@somebody.com&quot; }],</span>\n<span class=\"grvsc-line\">    curve: &quot;ed25519&quot;,</span>\n<span class=\"grvsc-line\">    passphrase: &quot;qwerty&quot;,</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\">  console.log(privateKeyArmored);</span>\n<span class=\"grvsc-line\">  console.log(publicKeyArmored);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Running the above gives us our private key:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">-----BEGIN PGP PRIVATE KEY BLOCK-----</span>\n<span class=\"grvsc-line\">Version: OpenPGP.js v4.10.8</span>\n<span class=\"grvsc-line\">Comment: https://openpgpjs.org</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">xYYEX6iKVxYJKwYBBAHaRw8BAQdANJ6JIXuMMZV3NIlwq0POS7xsF2N7+kAE</span>\n<span class=\"grvsc-line\">7KQjAtfIuqj+CQMI4CUgW9jPsGPgJvQnnCWFf1s7lO/5+D5ZQ9JK25fUtmQo</span>\n<span class=\"grvsc-line\">WyHX0Ja1ryOoFnvq7u+7fUC0+RAzt8S1xv3eDzazfgNuLtEmufwMyR6wMi78</span>\n<span class=\"grvsc-line\">Kc0ccGVyc29uIDxwZXJzb25Ac29tZWJvZHkuY29tPsKPBBAWCgAgBQJfqIpX</span>\n<span class=\"grvsc-line\">BgsJBwgDAgQVCAoCBBYCAQACGQECGwMCHgEAIQkQVrbGpNEnCPUWIQQb8YRJ</span>\n<span class=\"grvsc-line\">hw7DjekU68lWtsak0ScI9UM7AQDv4YRbIdU2ErPf8MobreeLiXXjYZ6fas8E</span>\n<span class=\"grvsc-line\">zW0KoTZWEQD+NHDY2YYByMF1mWusPkdPDpyBzqMJrlMeihMzZ+PE8AfHiwRf</span>\n<span class=\"grvsc-line\">qIpXEgorBgEEAZdVAQUBAQdARY37/Vys4Sj6DvwN6TRjxrIqiMIngxQgvOb6</span>\n<span class=\"grvsc-line\">wi+tQzEDAQgH/gkDCJ2xNZ1OXxv94E8fTLQ3gYHFQuebn/PSijD8CqlvHNB/</span>\n<span class=\"grvsc-line\">/Z9sIxSFt7rzorW+9v6Awfe+pQwXW5iEyJkdiGu3BM91GMwMvMmZ+rBNlBvq</span>\n<span class=\"grvsc-line\">iX7CeAQYFggACQUCX6iKVwIbDAAhCRBWtsak0ScI9RYhBBvxhEmHDsON6RTr</span>\n<span class=\"grvsc-line\">yVa2xqTRJwj17W0BAI5MuCWHrqjSRcdjLTwxa++jYv+Yxq4tODj8oh27T86v</span>\n<span class=\"grvsc-line\">AQCfb3lij9JGlIMNDQgceeougl+Lw4Gb0kQCnsNQRggTDw==</span>\n<span class=\"grvsc-line\">=yzT4</span>\n<span class=\"grvsc-line\">-----END PGP PRIVATE KEY BLOCK-----</span></code></pre>\n<p>And the public key:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">-----BEGIN PGP PUBLIC KEY BLOCK-----</span>\n<span class=\"grvsc-line\">Version: OpenPGP.js v4.10.8</span>\n<span class=\"grvsc-line\">Comment: https://openpgpjs.org</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">xjMEX6iKVxYJKwYBBAHaRw8BAQdANJ6JIXuMMZV3NIlwq0POS7xsF2N7+kAE</span>\n<span class=\"grvsc-line\">7KQjAtfIuqjNHHBlcnNvbiA8cGVyc29uQHNvbWVib2R5LmNvbT7CjwQQFgoA</span>\n<span class=\"grvsc-line\">IAUCX6iKVwYLCQcIAwIEFQgKAgQWAgEAAhkBAhsDAh4BACEJEFa2xqTRJwj1</span>\n<span class=\"grvsc-line\">FiEEG/GESYcOw43pFOvJVrbGpNEnCPVDOwEA7+GEWyHVNhKz3/DKG63ni4l1</span>\n<span class=\"grvsc-line\">42Gen2rPBM1tCqE2VhEA/jRw2NmGAcjBdZlrrD5HTw6cgc6jCa5THooTM2fj</span>\n<span class=\"grvsc-line\">xPAHzjgEX6iKVxIKKwYBBAGXVQEFAQEHQEWN+/1crOEo+g78Dek0Y8ayKojC</span>\n<span class=\"grvsc-line\">J4MUILzm+sIvrUMxAwEIB8J4BBgWCAAJBQJfqIpXAhsMACEJEFa2xqTRJwj1</span>\n<span class=\"grvsc-line\">FiEEG/GESYcOw43pFOvJVrbGpNEnCPXtbQEAjky4JYeuqNJFx2MtPDFr76Ni</span>\n<span class=\"grvsc-line\">/5jGri04OPyiHbtPzq8BAJ9veWKP0kaUgw0NCBx56i6CX4vDgZvSRAKew1BG</span>\n<span class=\"grvsc-line\">CBMP</span>\n<span class=\"grvsc-line\">=C6S6</span>\n<span class=\"grvsc-line\">-----END PGP PUBLIC KEY BLOCK-----</span></code></pre>\n<h3 id=\"file-encryption\" style=\"position:relative;\"><a href=\"#file-encryption\" aria-label=\"file encryption 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>File Encryption</h3>\n<p>Now we can start encrypting information.</p>\n<p>Create a text file:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">echo &#39;This file contains secret information&#39; &gt; secrets.txt</span></code></pre>\n<p>Here, we act as the sender who received a public key from the intended recipient. We use their public key to encrypt the confidential information:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">// encrypt-file.js</span>\n<span class=\"grvsc-line\">const openpgp = require(&quot;openpgp&quot;);</span>\n<span class=\"grvsc-line\">const fs = require(&quot;fs&quot;);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const publicKeyArmored = &lt;PUBLIC KEY GIVEN BY RECIPIENT&gt;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">encrypt();</span>\n<span class=\"grvsc-line\">async function encrypt() {</span>\n<span class=\"grvsc-line\">  const plainData = fs.readFileSync(&quot;secrets.txt&quot;);</span>\n<span class=\"grvsc-line\">  const encrypted = await openpgp.encrypt({</span>\n<span class=\"grvsc-line\">    message: openpgp.message.fromText(plainData),</span>\n<span class=\"grvsc-line\">    publicKeys: (await openpgp.key.readArmored(publicKeyArmored)).keys,</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  fs.writeFileSync(&quot;encrypted-secrets.txt&quot;, encrypted.data);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>In the newly created <code>encrypted-secrets.txt</code> file, we have the contents encrypted like so:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">-----BEGIN PGP MESSAGE-----</span>\n<span class=\"grvsc-line\">Version: OpenPGP.js v4.10.8</span>\n<span class=\"grvsc-line\">Comment: https://openpgpjs.org</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">wV4DUsPKVnc3UHMSAQdAey4TJiEOrZQIrx6q2zBLgmPkbnhPMt1WR+jCWX5x</span>\n<span class=\"grvsc-line\">Gn8wEim8W4OhDVMwfhtgVIClBCGPhvdeZ1zvVUAJGDdl8+S+DUynKhPNcN8m</span>\n<span class=\"grvsc-line\">Kb9TRGYs0sAlAaXcTChBHSS5kDHV/8Hgjcn0OIs6v2mbCkz/bHs/shwf8WMI</span>\n<span class=\"grvsc-line\">ov711iEkgcXnXIX+ZDGyDFnAKftoygzAf0aZy82g7ejAD9SX13wNmO6TK8Gw</span>\n<span class=\"grvsc-line\">wr9Xj8F6XBV0yHvdsm2uzRY9W03tTSqAf0anEs+ZWyVR/ha9ddnZJPFKtUbC</span>\n<span class=\"grvsc-line\">BEF4AMavsIN0CcqpA4q69I3E6GEtkAzgBWfJOOO8mQsNQ1vJWcJocinryBE6</span>\n<span class=\"grvsc-line\">Kbhznoe+R69qmUaJXPpe5scF6tfCYuQtPz4uhOljT+OUP6qss5Nz4zBs4JLq</span>\n<span class=\"grvsc-line\">nUlyynLLSSgdVr4Hvg==</span>\n<span class=\"grvsc-line\">=5tyF</span>\n<span class=\"grvsc-line\">-----END PGP MESSAGE-----</span></code></pre>\n<p>Now, as the sender, we can send the encrypted file to the recipient.</p>\n<h3 id=\"file-decryption\" style=\"position:relative;\"><a href=\"#file-decryption\" aria-label=\"file decryption 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>File Decryption</h3>\n<p>Here, we act as the reciever. To decrypt the <code>encrypted-secrets.txt</code> file, we use our private key and passphrase:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">// decrypt-file.js</span>\n<span class=\"grvsc-line\">const openpgp = require(&quot;openpgp&quot;);</span>\n<span class=\"grvsc-line\">const fs = require(&quot;fs&quot;);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const privateKeyArmored = &lt;PRIVATE KEY&gt;</span>\n<span class=\"grvsc-line\">const passphrase = &lt;PASS PHRASE&gt;;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">decrypt();</span>\n<span class=\"grvsc-line\">async function decrypt() {</span>\n<span class=\"grvsc-line\">  const privateKey = (await openpgp.key.readArmored([privateKeyArmored])).keys[0];</span>\n<span class=\"grvsc-line\">  await privateKey.decrypt(passphrase);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  const encryptedData = fs.readFileSync(&quot;encrypted-secrets.txt&quot;);</span>\n<span class=\"grvsc-line\">  const decrypted = await openpgp.decrypt({</span>\n<span class=\"grvsc-line\">    message: await openpgp.message.readArmored(encryptedData),</span>\n<span class=\"grvsc-line\">    privateKeys: [privateKey],</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  console.log(decrypted.data);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Which logs the decrypted file contents:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">This file contains secret information.</span></code></pre>\n<h3 id=\"using-streams-for-large-files\" style=\"position:relative;\"><a href=\"#using-streams-for-large-files\" aria-label=\"using streams for large files 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>Using Streams for Large Files</h3>\n<p>If you plan on encrypting or decrypting large files, you won't be able to fit the entire file contents in memory. In this case, you can use Node.js streams.</p>\n<p>Here, we encrypt a large file called <code>dataset-1mill.json</code> using streams:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">encrypt();</span>\n<span class=\"grvsc-line\">async function encrypt() {</span>\n<span class=\"grvsc-line\">  const encrypted = await openpgp.encrypt({</span>\n<span class=\"grvsc-line\">    message: openpgp.message.fromText(fs.createReadStream(&quot;dataset-1mill.json&quot;)),</span>\n<span class=\"grvsc-line\">    publicKeys: (await openpgp.key.readArmored(publicKeyArmored)).keys,</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  let readStream = encrypted.data;</span>\n<span class=\"grvsc-line\">  let writeStream = fs.createWriteStream(&quot;encrypted-dataset.txt&quot;, { flags: &quot;a&quot; });</span>\n<span class=\"grvsc-line\">  readStream.pipe(writeStream);</span>\n<span class=\"grvsc-line\">  readStream.on(&quot;end&quot;, () =&gt; console.log(&quot;done!&quot;));</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>And then, we decrypt the newly created <code>encrypted-dataset.txt</code> using streams:</p>\n<ul>\n<li>Notice that we set the flag allow<em>unauthenticated</em>stream to true, which allows streaming data before the message integrity has been checked. This is because, in our case, our OpenPGP message only has a single integrity tag at the end. This means the entire message gets loaded into memory, and we get a heap out of memory error since our file is too large to fit into memory at once.</li>\n</ul>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">openpgp.config.allow_unauthenticated_stream = true;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">decrypt();</span>\n<span class=\"grvsc-line\">async function decrypt() {</span>\n<span class=\"grvsc-line\">  const privateKey = (await openpgp.key.readArmored([privateKeyArmored])).keys[0];</span>\n<span class=\"grvsc-line\">  await privateKey.decrypt(passphrase);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  const decrypted = await openpgp.decrypt({</span>\n<span class=\"grvsc-line\">    message: await openpgp.message.readArmored(fs.createReadStream(&quot;encrypted-dataset.txt&quot;)),</span>\n<span class=\"grvsc-line\">    privateKeys: [privateKey],</span>\n<span class=\"grvsc-line\">  });</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  let readStream = decrypted.data;</span>\n<span class=\"grvsc-line\">  let writeStream = fs.createWriteStream(&quot;decrypted-dataset.json&quot;, { flags: &quot;a&quot; });</span>\n<span class=\"grvsc-line\">  readStream.pipe(writeStream);</span>\n<span class=\"grvsc-line\">  readStream.on(&quot;end&quot;, () =&gt; console.log(&quot;done!&quot;));</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Now, <code>decrypted-dataset.json</code> will have the same contents as our original <code>dataset-1mill.json</code> file.</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":"November 10, 2020","updated_date":null,"description":"Starter guide on Pretty Good Privacy(PGP) with Nodejs. PGP, a cryptographic process used to encrypt and decrypt information.","title":"Using PGP Encryption with Nodejs","tags":["Security","NodeJs","Encryption"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.7699115044247788,"src":"/static/a427e4132564cc095bcc9015faa67da4/ee604/cover.png","srcSet":"/static/a427e4132564cc095bcc9015faa67da4/69585/cover.png 200w,\n/static/a427e4132564cc095bcc9015faa67da4/497c6/cover.png 400w,\n/static/a427e4132564cc095bcc9015faa67da4/ee604/cover.png 800w,\n/static/a427e4132564cc095bcc9015faa67da4/05d05/cover.png 1080w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Andy Yeung","github":null,"avatar":null}}}},{"node":{"excerpt":"Python is a general-purpose programming language and has overtaken Java in popularity according to a recent Stackoverflow survey.  People…","fields":{"slug":"/engineering/python-basics-in-minutes/"},"html":"<p>Python is a general-purpose programming language and has overtaken Java in popularity according to a recent Stackoverflow survey. </p>\n<p>People who have never programmed before are tempted to try due to the simplicity to learn and use it. Well, let's get down to business.</p>\n<h2 id=\"before-we-get-started\" style=\"position:relative;\"><a href=\"#before-we-get-started\" aria-label=\"before we get started 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>Before we get started</h2>\n<p>Before we get started, there are a few things you should know about python:</p>\n<ul>\n<li>Python is a high-level programming language, which means it has a strong abstraction from the computer's details (that's why it's so easy and understandable). Because of that, it may be not so efficient as other languages like assembly, C, or C++;</li>\n<li>Python is an interpreted language. Its syntax is read and then executed directly. The interpreter reads each program statement, following the program flow, then decides what to do and does it. That's why you should test all your programs, even if everything seems to be working correctly. If there is an error within a loop, for example, it will only be shown if the loop is executed;</li>\n<li>Python has excellent documentation <a href=\"https://docs.python.org/3/\">that you can access here</a> and an incredible community. Use them.</li>\n</ul>\n<h2 id=\"print-function\" style=\"position:relative;\"><a href=\"#print-function\" aria-label=\"print function 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>Print function</h2>\n<p><em>We are assuming that you have already installed python. If you do not, please click <a href=\"https://www.python.org/downloads/\">here</a>.</em></p>\n<p>To write your first Python code, open your text editor and type: </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">print(&quot;Hello world, this is my first python code&quot;)</span></code></pre>\n<p>Save the file as <code>helloworld.py</code> and put it into the python interpreter to be executed.\nYou also can run your code on the command line:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">C:\\Users\\Your Name&gt;python helloworld.py</span></code></pre>\n<p>If everything went well, you should see something like this:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">&gt; Hello world, this is my first python code</span></code></pre>\n<p>You can also use the print function to show integers, variables, lists, etc. Try it!</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\">#show the sum of two integers</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number1 = </span><span class=\"mtk7\">5</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number2 = </span><span class=\"mtk7\">7</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(number1+number2)</span></span></code></pre>\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\">#dividing two decimals</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number1 = </span><span class=\"mtk10\">float</span><span class=\"mtk1\">(</span><span class=\"mtk7\">12.1</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">number2 = </span><span class=\"mtk10\">float</span><span class=\"mtk1\">(</span><span class=\"mtk7\">4</span><span class=\"mtk1\">)</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\">#concatenating strings</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">name = </span><span class=\"mtk8\">&quot;Python&quot;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">phrase = </span><span class=\"mtk10\">str</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I hate &quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I love &quot;</span><span class=\"mtk1\">, name)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(phrase+name)</span></span></code></pre>\n<h2 id=\"data-types\" style=\"position:relative;\"><a href=\"#data-types\" aria-label=\"data types 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>Data Types</h2>\n<p>Python has the following data types built-in by default, in these categories:</p>\n<ul>\n<li>Text Type:\t<code>str</code> <em>(string)</em></li>\n<li>Numeric Types:\t<code>int</code> <em>(integer)</em>, <code>float</code> <em>(decimal)</em>, <code>complex</code></li>\n<li>Sequence Types:\t<code>list</code>, <code>tuple</code>, <code>range</code></li>\n<li>Mapping Type:\t<code>dict</code></li>\n<li>Set Types:\t<code>set</code>, <code>frozenset</code></li>\n<li>Boolean Type:\t<code>bool</code></li>\n<li>Binary Types:\t<code>bytes</code>, <code>bytearray</code>, <code>memoryview</code></li>\n</ul>\n<blockquote>\n<p><strong>Note:</strong> Variables in Python are interpreted as integers by default. Is a good practice to declare them as another type <em>explicitly</em> (if they aren't integers). You can see the kind of a variable using the function <code>type()</code>.</p>\n</blockquote>\n<h2 id=\"python-operators\" style=\"position:relative;\"><a href=\"#python-operators\" aria-label=\"python operators 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>Python Operators</h2>\n<p>Operators are used to performing operations on variables and values.\nThe main groups are:</p>\n<ul>\n<li>Arithmetic operators</li>\n<li>Comparison operators</li>\n<li>Logical operators</li>\n</ul>\n<h3 id=\"arithmetic-operators\" style=\"position:relative;\"><a href=\"#arithmetic-operators\" aria-label=\"arithmetic operators 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>Arithmetic operators</h3>\n<p><em>Arithmetic operators are used with numeric values to perform common mathematical operations.</em></p>\n<ul>\n<li><strong>Addition</strong>:\t<code>x + y</code></li>\n<li><strong>Subtraction:</strong> <code>x - y</code></li>\n<li><strong>Multiplication:</strong> <code>x * y</code></li>\n<li><strong>Division:</strong> <code>x / y</code></li>\n<li><strong>Modulus:</strong> <code>x % y</code>\t</li>\n<li><strong>Exponentiation:</strong> <code>x ** y</code>\t</li>\n<li><strong>Floor division:</strong> <code>x // y</code></li>\n</ul>\n<h3 id=\"comparison-operators\" style=\"position:relative;\"><a href=\"#comparison-operators\" aria-label=\"comparison operators 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>Comparison operators</h3>\n<p><em>Comparison operators are used to compare two values.</em></p>\n<ul>\n<li><strong>Equal:</strong> <code>x == y</code></li>\n<li><strong>Not equal:</strong> <code>x != y</code></li>\n<li><strong>Greater than:</strong> <code>x > y</code></li>\n<li><strong>Less than:</strong> <code>x &#x3C; y</code>\t</li>\n<li><strong>Greater than or equal to:</strong> <code>x >= y</code></li>\n<li><strong>Less than or equal to:</strong>\t<code>x &#x3C;= y</code></li>\n</ul>\n<h3 id=\"logical-operators\" style=\"position:relative;\"><a href=\"#logical-operators\" aria-label=\"logical operators 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>Logical operators</h3>\n<p><em>Logical operators are used to combine conditional statements.</em></p>\n<ul>\n<li><strong>and</strong> -> Returns True if both statements are true\n<code>x &#x3C; 2 and x &#x3C; 4</code></li>\n<li><strong>or</strong> ->\tReturns True if one of the statements is true\n<code>x &#x3C; 10 or x &#x3C; 9</code></li>\n<li><strong>not</strong> -> Reverse the result, returns False if the result is true\n<code>not(x &#x3C; 2 and x &#x3C; 4)</code></li>\n</ul>\n<h2 id=\"if-statement\" style=\"position:relative;\"><a href=\"#if-statement\" aria-label=\"if statement 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>If statement</h2>\n<p>Look to the code below:</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=\"mtk1\">age = </span><span class=\"mtk7\">18</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">if</span><span class=\"mtk1\"> (age&lt;</span><span class=\"mtk7\">21</span><span class=\"mtk1\">):</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;The student is underage!&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">elif</span><span class=\"mtk1\"> (age==</span><span class=\"mtk7\">21</span><span class=\"mtk1\">):</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;The student is 21!&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">else</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;The student isn&#39;t underage!&quot;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>In programming, we often have to choose what to do depending on the situation. It is essential to know how to use conditional arguments like <code>if</code>and <code>else</code>.\nThe code above print a different message according to a condition.</p>\n<p>Try to write a code that asks for two test scores. If the average is less than 7, the user should see \"I'm sorry, you didn't do well on the tests\". If the average is exactly 7, the user should see \"You did it!\". And if it is greater than 7, the user should see \"Congratulations!! You're a great student.\".</p>\n<blockquote>\n<p><strong>Note:</strong> to request a response from the user, you need to use the <code>input()</code> function. For example:</p>\n</blockquote>\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\">name = </span><span class=\"mtk10\">str</span><span class=\"mtk1\">(</span><span class=\"mtk11\">input</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;What&#39;s your name?&quot;</span><span class=\"mtk1\">))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">age = </span><span class=\"mtk10\">int</span><span class=\"mtk1\">(</span><span class=\"mtk11\">input</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;How old are you? &quot;</span><span class=\"mtk1\">))</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I&#39;m </span><span class=\"mtk4\">%s</span><span class=\"mtk8\"> and I&#39;m </span><span class=\"mtk4\">%d</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">% (name, age))</span></span></code></pre>\n<h2 id=\"loops\" style=\"position:relative;\"><a href=\"#loops\" aria-label=\"loops 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>Loops</h2>\n<p>Python has two primitive loop commands: <code>while</code> and <code>for</code>.</p>\n<h3 id=\"while-loop\" style=\"position:relative;\"><a href=\"#while-loop\" aria-label=\"while loop 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>While loop</h3>\n<p><em>With the while loop, we can execute a set of statements as long as a condition is true.</em></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=\"mtk1\">count = </span><span class=\"mtk7\">0</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">while</span><span class=\"mtk1\"> count &lt; </span><span class=\"mtk7\">10</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(count)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    count += </span><span class=\"mtk7\">1</span><span class=\"mtk1\">    </span><span class=\"mtk3\">#this line is the same as    count = count+1</span></span></code></pre>\n<p>The code above will print count as long as count is less than 10.</p>\n<h3 id=\"for-loop\" style=\"position:relative;\"><a href=\"#for-loop\" aria-label=\"for loop 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>For loop</h3>\n<p>A for loop is used for iterating over a sequence. Using it, we can execute a set of statements, once for each item in a list, tuple, set, string, etc. For example:</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\">#loop through a string</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\"> </span><span class=\"mtk8\">&quot;banana&quot;</span><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(x)</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">#loop through a list of fruits</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">fruits = [</span><span class=\"mtk8\">&quot;apple&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk8\">&quot;banana&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk8\">&quot;melon&quot;</span><span class=\"mtk1\">]</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\"> fruits:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;I like&quot;</span><span class=\"mtk1\">, x)</span></span></code></pre>\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>Did you understand why python became so popular? In a few minutes, you were able to learn the main concepts of this fantastic language.</p>\n<p>Please comment and share this article!</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 .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n</style>","frontmatter":{"date":"November 06, 2020","updated_date":null,"description":"Learn the basics of Python programming lanuage (For Beginners)","title":"Python basics in minutes","tags":["Python"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/c09f9fd01e129e30049747717eaf81ec/ee604/python.png","srcSet":"/static/c09f9fd01e129e30049747717eaf81ec/69585/python.png 200w,\n/static/c09f9fd01e129e30049747717eaf81ec/497c6/python.png 400w,\n/static/c09f9fd01e129e30049747717eaf81ec/ee604/python.png 800w,\n/static/c09f9fd01e129e30049747717eaf81ec/f3583/python.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Sara Lins","github":"saranicoly","avatar":null}}}},{"node":{"excerpt":"What is Rest? Representational State Transfer in short-form as REST defines a set of constraints for creating Web Services.\nRest API is the…","fields":{"slug":"/engineering/rest-api-cucumber-blog/"},"html":"<h2 id=\"what-is-rest\" style=\"position:relative;\"><a href=\"#what-is-rest\" aria-label=\"what is rest 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 Rest?</h2>\n<p>Representational State Transfer in short-form as <strong>REST</strong> defines a set of constraints for creating Web Services.\nRest API is the most-used web service technology nowadays, and it's an almost meaningless description. A REST API is a way to communicate for two computer systems over HTTP, which is similar to web browsers and servers.</p>\n<h2 id=\"what-is-bdd\" style=\"position:relative;\"><a href=\"#what-is-bdd\" aria-label=\"what is bdd 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 BDD?</h2>\n<p>BDD stands for <strong>Behavior Driven Development</strong> (BDD). Nowadays, many Organizations, to get a better advantage of testing, are taking a step forward.  </p>\n<ul>\n<li>BDD allows us to create test scripts from both the developer’s and the customer’s perspective.</li>\n<li>BDD uses human-readable descriptions of software user requirements as the basis for software tests</li>\n</ul>\n<h2 id=\"what-is-cucumber\" style=\"position:relative;\"><a href=\"#what-is-cucumber\" aria-label=\"what is cucumber 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 Cucumber?</h2>\n<p>A cucumber is an approach that supports BDD. It allows you to write tests that anyone can understand, irrespective of their technical knowledge. In BDD, users (business analysts, product owners, developers, etc..). We need to first write scenarios or acceptance tests that describe the system's behavior from the customer's point of view for review and sign-off by the product owners before developers start actual development.</p>\n<h2 id=\"what-are-the-prerequisites-to-test-rest-api-using-cucumber\" style=\"position:relative;\"><a href=\"#what-are-the-prerequisites-to-test-rest-api-using-cucumber\" aria-label=\"what are the prerequisites to test rest api using cucumber 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 the Prerequisites to Test Rest API using Cucumber?</h2>\n<ul>\n<li>Java</li>\n<li>Editor (Eclipse, IntelliJ, etc..)</li>\n<li>Maven</li>\n</ul>\n<h3 id=\"steps-to-install-java\" style=\"position:relative;\"><a href=\"#steps-to-install-java\" aria-label=\"steps to install java 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>Steps to Install Java</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">http://www.oracle.com/technetwork/java/javase/downloads/index.html  </span></code></pre>\n<p>Download JDK from the above link and install it\nSet the Environment Variable on System Properties </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">Right Click on My PC -&gt; Properties -&gt; Advanced System Settings -&gt; Environment Variables -&gt; Create New -&gt; provide path of JDK</span></code></pre>\n<h3 id=\"steps-to-install-eclipse\" style=\"position:relative;\"><a href=\"#steps-to-install-eclipse\" aria-label=\"steps to install eclipse 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>Steps to Install Eclipse</h3>\n<ul>\n<li>Make Sure Java is installed on your PC.</li>\n<li>Use the below link to download Eclipse :\n<a href=\"https://eclipse.org/downloads\">Eclipse Download</a></li>\n<li>Install Eclipse on your PC </li>\n</ul>\n<p><strong>Steps to Install Maven</strong></p>\n<ul>\n<li>Use the below link to download Maven :\n<a href=\"https://maven.apache.org/download.cgi\">Maven Download</a></li>\n<li>Set the environment variable.</li>\n</ul>\n<h3 id=\"configuring-cucumber-with-maven\" style=\"position:relative;\"><a href=\"#configuring-cucumber-with-maven\" aria-label=\"configuring cucumber with maven 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>Configuring Cucumber with Maven</h3>\n<ul>\n<li>\n<p>Create a Maven Project. Use below navigation.</p>\n<p><code>Open Eclipse -> File -> New -> Maven Project</code>\n</p>\n</li>\n<li>\n<p>Provide Group Id and Artifact Id and click on finish. </p>\n<p><strong>Group Id:</strong> This element indicates the organization's unique identifier or group that created the project. The groupId is one of the key identifiers of a project and is typically based on your organization's fully qualified domain name. For example, <code>com.loginradius</code>  is the designated groupId for all Maven plugins.</p>\n<p><strong>Artifact Id:</strong>  it points to the unique base name of the primary artifact generated by this project. The main or primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name.</p>\n</li>\n<li>\n<p>Open pom.xml file to add necessary dependencies </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;io.cucumber&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;cucumber-java&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;6.6.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span>\n<span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;io.cucumber&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;cucumber-testng&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;6.6.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span>\n<span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;io.rest-assured&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;rest-assured&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;4.3.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">\t&lt;scope&gt;test&lt;/scope&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span>\n<span class=\"grvsc-line\">&lt;dependency&gt;</span>\n<span class=\"grvsc-line\">\t&lt;groupId&gt;org.testng&lt;/groupId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;artifactId&gt;testng&lt;/artifactId&gt;</span>\n<span class=\"grvsc-line\">\t&lt;version&gt;7.1.0&lt;/version&gt;</span>\n<span class=\"grvsc-line\">\t&lt;scope&gt;test&lt;/scope&gt;</span>\n<span class=\"grvsc-line\">&lt;/dependency&gt;</span></code></pre>\n</li>\n</ul>\n<p> Now we need three Important files.</p>\n<ul>\n<li>Feature file</li>\n<li>StepDefination file</li>\n<li>Runner file</li>\n</ul>\n<p> <strong>Feature File:</strong>  It's a entry point to the cucumber. We use Gherkins to write the feature file. This is the file where you will describe your descriptive language(Gherkin uses simple English). A feature file can contains a Scenario or List of Scenario. A sample Feature file is below</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">Feature: Login Functionality</span>\n<span class=\"grvsc-line\">@validLogin</span>\n<span class=\"grvsc-line\">Scenario: User Should Login With Valid Credentials </span>\n<span class=\"grvsc-line\">   Given Post Login API</span>\n<span class=\"grvsc-line\">   When Provide Valid Credential</span>\n<span class=\"grvsc-line\">   Then Status_code equals 200    </span>\n<span class=\"grvsc-line\">   And  response contains IsLogin equals &quot;true&quot;</span>\n<span class=\"grvsc-line\">@invalidLogin    </span>\n<span class=\"grvsc-line\">Scenario Outline: Email and Password Validation in Login API </span>\n<span class=\"grvsc-line\">   Given Post Login API</span>\n<span class=\"grvsc-line\">   When Provide different combinations to &quot;&lt;email&gt;&quot;&quot;&lt;password&gt;&quot;</span>\n<span class=\"grvsc-line\">   Then Status_code equals &lt;statuscode&gt;    </span>\n<span class=\"grvsc-line\">   And  response contains message equals &quot;&lt;message&gt;&quot;</span>\n<span class=\"grvsc-line\">   Examples:</span>\n<span class=\"grvsc-line\">   |email     \t\t|password    | statuscode |  message</span>\n<span class=\"grvsc-line\">   |          \t\t|            |   401      | Required email and password</span>\n<span class=\"grvsc-line\">   | abc\t  \t|            |   401      | Email format is incorrect</span>\n<span class=\"grvsc-line\">   | abc@mail7.io  \t|\t     |   401      | Required password</span>\n<span class=\"grvsc-line\">   | abc@mail7.io   \t| password   |   401      | Email and Password combination Incorrect</span></code></pre>\n<p> Save the above code as login.feature </p>\n<ul>\n<li><strong>Feature:</strong> It indicates the name of the feature under the test.</li>\n<li><strong>Description:</strong> It indicates a meaningful description of the feature (Optional).</li>\n<li><strong>scenario:</strong> scenario indicates the steps and expected outcomes for a particular test case.</li>\n<li><strong>Scenario Outline:</strong> Single scenario can be executed for multiple data sets using scenario outlines. The data is provided by a tabular structure separated by (I I).</li>\n<li><strong>Given:</strong> Prerequisite before the test steps get executed.</li>\n<li><strong>When:</strong> Specific condition which should match to execute the next step.</li>\n<li><strong>Then:</strong> What should happen if the condition mentioned in WHEN is satisfied.</li>\n<li><strong>Examples:</strong> Its a tabular format input data to pass to scenario outline.</li>\n<li><strong>&#x3C;>:</strong> anything if you write between is variable. </li>\n</ul>\n<p><strong>StepDefinition:</strong>\nNow you have your feature file ready with test scenarios defined. However, our job is not done yet. Cucumber doesn't know when should execute which part of code. So StepDefinition acts as an intermediate to your runner and feature file. It stores the mapping between each step of the scenario in the Feature file. So when you run the scenario, it will scan the stepDefination file to check matched glue.</p>\n<p><strong>How to write step definition:</strong>\nWe have a chrome extension(Tidy Gherkin) to convert your feature into a step definition.<br>\nCopy your scenario from the feature file and paste it in Tidy Gherkin and click on Java Steps; copy the Java Steps.\nCreate a new file name a StepDefinition.java and paste the Java Steps</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"java\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">package</span><span class=\"mtk1\"> com.loginradius.login</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk14\">import</span><span class=\"mtk1\"> cucumber.api.java.en.</span><span class=\"mtk14\">G</span><span class=\"mtk1\">iven;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.java.en.When;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.java.en.Then;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.java.en.And;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> cucumber.api.junit.Cucumber;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> org.junit.runner.RunWith;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> </span><span class=\"mtk4\">static</span><span class=\"mtk1\"> io.restassured.RestAssured.given;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> </span><span class=\"mtk4\">static</span><span class=\"mtk1\"> org.testng.Assert.assertTrue;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.http.ContentType;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.response.Response;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.specification.RequestSpecification;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.restassured.RestAssured;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk4\">class</span><span class=\"mtk1\"> </span><span class=\"mtk10\">StepDefinition</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span><span class=\"mtk4\">private</span><span class=\"mtk1\">  </span><span class=\"mtk4\">static</span><span class=\"mtk1\">  </span><span class=\"mtk4\">final</span><span class=\"mtk1\">  </span><span class=\"mtk10\">String</span><span class=\"mtk1\">  </span><span class=\"mtk12\">BASE_URL</span><span class=\"mtk1\">  =  </span><span class=\"mtk8\">&quot;https://www.loginradius.com&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> </span><span class=\"mtk12\">email</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&quot;abcxyz@mail7.io;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tString password = &quot;</span><span class=\"mtk1\">password</span><span class=\"mtk8\">&quot;;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tRequestSpecification request;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tprivate  static  Response response;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\tprivate  static  String  jsonString;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    @Given(&quot;</span><span class=\"mtk10\">Post</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Login</span><span class=\"mtk1\"> API</span><span class=\"mtk8\">&quot;)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    public void post_login_api() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\t    RestAssured.baseURI  =  BASE_URL;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\t\trequest  =  RestAssured.given();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">\t\trequest.header(&quot;</span><span class=\"mtk1\">Content-Type</span><span class=\"mtk8\">&quot;,  &quot;</span><span class=\"mtk1\">application/json</span><span class=\"mtk8\">&quot;);    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">   @When(&quot;</span><span class=\"mtk10\">Provide</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Valid</span><span class=\"mtk1\"> Credential</span><span class=\"mtk8\">&quot;)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    public void provide_valid_credential() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">      response  =  request.body(&quot;</span><span class=\"mtk1\">{ \\</span><span class=\"mtk8\">&quot;userName</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">  +  email  +  </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">, </span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">password</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">  +  password  +  </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t\t\t\t\t  .</span><span class=\"mtk11\">post</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;/user/login&quot;</span><span class=\"mtk1\">);\t</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=\"mtk1\">   @</span><span class=\"mtk10\">Then</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;Status_code equals {int}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">statuscode_equals_</span><span class=\"mtk1\">(</span><span class=\"mtk10\">int</span><span class=\"mtk1\"> agr) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    </span><span class=\"mtk12\">Assert</span><span class=\"mtk1\">.</span><span class=\"mtk11\">assertEquals</span><span class=\"mtk1\">(arg, </span><span class=\"mtk12\">response</span><span class=\"mtk1\">.</span><span class=\"mtk11\">getStatusCode</span><span class=\"mtk1\">());</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t@</span><span class=\"mtk10\">And</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;response contains IsPosted equals {string}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">response_contains_IsPosted_equals_</span><span class=\"mtk1\">(</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> message) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    </span><span class=\"mtk12\">Assert</span><span class=\"mtk1\">.</span><span class=\"mtk11\">assertEquals</span><span class=\"mtk1\">(message, </span><span class=\"mtk11\">getJsonPath</span><span class=\"mtk1\">(response, </span><span class=\"mtk8\">&quot;IsPosted&quot;</span><span class=\"mtk1\">));</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }\t</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   @</span><span class=\"mtk10\">And</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;response contains message equals {string}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">response_contains_equals_</span><span class=\"mtk1\">(</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> message) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    </span><span class=\"mtk12\">Assert</span><span class=\"mtk1\">.</span><span class=\"mtk11\">assertEquals</span><span class=\"mtk1\">(message, </span><span class=\"mtk11\">getJsonPath</span><span class=\"mtk1\">(response, </span><span class=\"mtk8\">&quot;message&quot;</span><span class=\"mtk1\">));</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t@</span><span class=\"mtk10\">When</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;Provide different combinations to {string}, {string}&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">void</span><span class=\"mtk1\"> </span><span class=\"mtk11\">provide_different_combinations_to_somethingsomething</span><span class=\"mtk1\">(</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> email, </span><span class=\"mtk10\">String</span><span class=\"mtk1\"> password){</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t    response = </span><span class=\"mtk12\">request</span><span class=\"mtk1\">.</span><span class=\"mtk11\">body</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;{ </span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">userName</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\"> + email + </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">, </span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">password</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">:</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\"> + password + </span><span class=\"mtk8\">&quot;</span><span class=\"mtk6\">\\&quot;</span><span class=\"mtk8\">}&quot;</span><span class=\"mtk1\">) .</span><span class=\"mtk11\">post</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;/user/login&quot;</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=\"mtk1\">\t</span><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk10\">String</span><span class=\"mtk1\"> </span><span class=\"mtk11\">getJsonPath</span><span class=\"mtk1\">(</span><span class=\"mtk10\">Response</span><span class=\"mtk1\"> response, </span><span class=\"mtk10\">String</span><span class=\"mtk1\"> key) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t</span><span class=\"mtk10\">String</span><span class=\"mtk1\"> </span><span class=\"mtk12\">resp</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">response</span><span class=\"mtk1\">.</span><span class=\"mtk11\">asString</span><span class=\"mtk1\">();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t</span><span class=\"mtk10\">JsonPath</span><span class=\"mtk1\"> </span><span class=\"mtk12\">js</span><span class=\"mtk1\"> = </span><span class=\"mtk15\">new</span><span class=\"mtk1\"> </span><span class=\"mtk11\">JsonPath</span><span class=\"mtk1\">(resp);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t</span><span class=\"mtk15\">return</span><span class=\"mtk1\"> </span><span class=\"mtk12\">js</span><span class=\"mtk1\">.</span><span class=\"mtk11\">get</span><span class=\"mtk1\">(key).</span><span class=\"mtk11\">toString</span><span class=\"mtk1\">();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<p>Now we have Our Feature file and StepDefinition Ready, we need a runner file to run our Test Scenario's</p>\n<p><strong>Runner File:</strong>\nA runner will help us to run the feature file and acts as an interlink between the feature file and StepDefinition Class\nBelow is the code which will help you to run the tests</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"java\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">package</span><span class=\"mtk1\"> runner;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">import</span><span class=\"mtk1\"> io.cucumber.testng.CucumberOptions;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">@</span><span class=\"mtk10\">CucumberOptions</span><span class=\"mtk1\">(</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\tfeatures= {</span><span class=\"mtk8\">&quot;feature_files/login.feature&quot;</span><span class=\"mtk1\">},</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        glue= {</span><span class=\"mtk8\">&quot;step_definations/StepDefinitation.java&quot;</span><span class=\"mtk1\">},</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        tags= </span><span class=\"mtk8\">&quot;@validLogin&quot;</span><span class=\"mtk1\">,    </span><span class=\"mtk3\">// based on tags scenarios will run</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        monochrome=</span><span class=\"mtk4\">true</span><span class=\"mtk1\">, dryRun=</span><span class=\"mtk4\">false</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">\t\t)\t</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">public</span><span class=\"mtk1\">  </span><span class=\"mtk4\">class</span><span class=\"mtk1\">  </span><span class=\"mtk10\">TestRunner</span><span class=\"mtk1\">  {</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<p>Now We have Feature, StepDefinition, and runner files ready, We can run the runner file to see the results.</p>\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>Cucumber is very useful in understanding the overall testing process without having coding knowledge. Since it uses simple English to write the feature file and makes developer, QA and other stakeholders on same page before starting the actual development.</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 .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk14 { color: #F44747; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk6 { color: #D7BA7D; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n</style>","frontmatter":{"date":"November 05, 2020","updated_date":null,"description":"This article is about basic overview of how to automate Rest API using Cucumber and JAVA.","title":"Automating Rest API's using Cucumber and Java","tags":["Automation","Cucumber","Rest API","Java"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/6185494b9a177d30a2dc78ccaca79e14/ee604/cucumber_rest_assured.png","srcSet":"/static/6185494b9a177d30a2dc78ccaca79e14/69585/cucumber_rest_assured.png 200w,\n/static/6185494b9a177d30a2dc78ccaca79e14/497c6/cucumber_rest_assured.png 400w,\n/static/6185494b9a177d30a2dc78ccaca79e14/ee604/cucumber_rest_assured.png 800w,\n/static/6185494b9a177d30a2dc78ccaca79e14/f3583/cucumber_rest_assured.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Surendranath Reddy Birudala","github":"reddysuren","avatar":null}}}},{"node":{"excerpt":"Introduction to Arduino and its usage Arduino is an open-source community that works on both Hardware and software development. We can say…","fields":{"slug":"/engineering/bluetooth-controlled-arduino-car-miniature/"},"html":"<h2 id=\"introduction-to-arduino-and-its-usage\" style=\"position:relative;\"><a href=\"#introduction-to-arduino-and-its-usage\" aria-label=\"introduction to arduino and its usage 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 to Arduino and its usage</h2>\n<p>Arduino is an open-source community that works on both Hardware and software development. We can say that both the hardware and software help build the new segment automated devices like e.g., 3D printer, IOT based projects, and much more. </p>\n<p>The Arduino software is used to build the code for every project made using any Arduino boards; it mostly uses the C/C++ language for its coding. Once the code is ready, we have to just compile and upload it on the board to make our project work. There are many types of Arduino boards like  Arduino Uno, Arduino Nano, Arduino USB, etc. In this project, we are going to use the Arduino UNO board (Atmega 328p).</p>\n<h3 id=\"bluetooth-module-hc-05\" style=\"position:relative;\"><a href=\"#bluetooth-module-hc-05\" aria-label=\"bluetooth module hc 05 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>Bluetooth Module HC-05</h3>\n<p>Bluetooth HC-05 is a Bluetooth module that is mostly used in the Bluetooth based project. It is easy to operate and can be easily configured with the Arduino.</p>\n<p>It has two operating modes: Command mode and Data mode, as we can change these modes by just pressing the push button on the Bluetooth module.\nIt has Six terminals. Two terminal are Vcc and GROUND for power purpose. The other two are TXD and RXD, the transmitter and receiver; respectively, these are the terminals that send and receive signals from the Arduino board to control the device. The other two terminals are State and Key, which tells the state of the module that it is in command mode or data mode.</p>\n<h3 id=\"motor-driver-l298d\" style=\"position:relative;\"><a href=\"#motor-driver-l298d\" aria-label=\"motor driver l298d 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>Motor Driver L298D</h3>\n<p>This is an IC made into a Module with a HEAT SINK embedded into it, which helps release heat whenever the L298D IC is heated. Now, this module is used to control the motors connected for the locomotion of the car; these motors work by the command prompted by the Arduino to move or rotate in a specific direction. It can control Four Gear motors at maximum; also, the speed of the motors can be handled by this IC.</p>\n<h2 id=\"objective\" style=\"position:relative;\"><a href=\"#objective\" aria-label=\"objective 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>Objective</h2>\n<ul>\n<li>This project's main motive is to expand the knowledge for smart micro-controllers like Arduino, which is widely used in the latest IoT technologies.</li>\n<li>Making the use of Connectivity Modules like Bluetooth HC-05, to understand the different modes of operating and communications with the micro-controller board.</li>\n<li>To get familiar with Codes and programs used for the controlling of the Arduino Uno board.</li>\n<li>Introductory project for Every Electronics And Electrical Student, to get the working of the Arduino board and its software.</li>\n</ul>\n<h3 id=\"components-required-for-the-project\" style=\"position:relative;\"><a href=\"#components-required-for-the-project\" aria-label=\"components required for the project 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>Components Required for the project:</h3>\n<ol>\n<li>Arduino UNO</li>\n<li>Bluetooth HC-05 Module</li>\n<li>Motor Driver L298</li>\n<li>Jumper Wires </li>\n<li>Gear Motors (x4)</li>\n<li>12 V battery (x3 Lithium-ion cells)</li>\n<li>LED</li>\n<li>Motor Wheels </li>\n</ol>\n<h3 id=\"pin-connections\" style=\"position:relative;\"><a href=\"#pin-connections\" aria-label=\"pin connections 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>Pin Connections:</h3>\n<ol>\n<li>Connect one terminal of each of two motors to the OUT1 (left side) and OUT2(left side) pins and each of the other two motors to the OUT3(right side) and OUT4(right side) of L298N motor driver.</li>\n<li>Connect the  positive wire of batteries to +12V pin and negative to the GND of L298N also +5V(of motor driver) to Vin(in analog pins)</li>\n<li>Connect the same GND of a motor driver to GND (in analog) of Arduino.</li>\n<li>Pins of HC-05 are connected to Arduino like this: GND(in analog pins) to GND; VCC(in analog) to 5V; RX to TX(in digital pins) and TX to RX(in digital pins).</li>\n<li>Connect anode and cathode of LED to Pin 9 (in digital pins) and 3.3V (in analog pins) pins, respectively.</li>\n<li>The use of the LED light is the optional parameter in this project.</li>\n</ol>\n<p>Here, I want to tell one important point that, The code that will be given should be uploaded before connection of the pins; else you will face an error in uploading the code, so, just first copy the code provided below and pasted in the Arduino software and upload it to the board before the pin connections.</p>\n<blockquote>\n<p>Software details: Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: \"Arduino/Genuino Uno \"</p>\n</blockquote>\n<blockquote>\n<p>The application used for Controlling the car is <code>Arduino Car</code>, which can be found on Playstore.</p>\n</blockquote>\n<h3 id=\"code-for-the-project\" style=\"position:relative;\"><a href=\"#code-for-the-project\" aria-label=\"code for the project 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>CODE FOR THE PROJECT</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">char t;</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">void setup() {</span>\n<span class=\"grvsc-line\">pinMode(13,OUTPUT);   //left motors forward</span>\n<span class=\"grvsc-line\">pinMode(12,OUTPUT);   //left motors reverse</span>\n<span class=\"grvsc-line\">pinMode(11,OUTPUT);   //right motors forward</span>\n<span class=\"grvsc-line\">pinMode(10,OUTPUT);   //right motors reverse</span>\n<span class=\"grvsc-line\">pinMode(9,OUTPUT);   //Led</span>\n<span class=\"grvsc-line\">Serial.begin(9600);</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">void loop() {</span>\n<span class=\"grvsc-line\">if(Serial.available()){</span>\n<span class=\"grvsc-line\">  t = Serial.read();</span>\n<span class=\"grvsc-line\">  Serial.println(t);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">if(t == &#39;F&#39;){            //move forward(all motors rotate in forward direction)</span>\n<span class=\"grvsc-line\">  digitalWrite(13,HIGH);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,HIGH);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">else if(t == &#39;G&#39;){      //move reverse (all motors rotate in reverse direction)</span>\n<span class=\"grvsc-line\">  digitalWrite(12,HIGH);</span>\n<span class=\"grvsc-line\">  digitalWrite(10,HIGH);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">else if(t == &#39;R&#39;){      //turn right (left side motors rotate in forward direction, right side motors doesn&#39;t rotate)</span>\n<span class=\"grvsc-line\">  digitalWrite(11,HIGH);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">else if(t == &#39;L&#39;){      //turn left (right side motors rotate in forward direction, left side motors doesn&#39;t rotate)</span>\n<span class=\"grvsc-line\">  digitalWrite(13,HIGH);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">else if(t == &#39;M&#39;){    //turn led on or off)</span>\n<span class=\"grvsc-line\">  digitalWrite(9,HIGH);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\">else if(t == &#39;m&#39;){</span>\n<span class=\"grvsc-line\">  digitalWrite(9,LOW);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> </span>\n<span class=\"grvsc-line\">else if(t == &#39;S&#39;){      //STOP (all motors stop)</span>\n<span class=\"grvsc-line\">  digitalWrite(13,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(12,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(10,LOW);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\">else if(t == &#39;Q&#39;){</span>\n<span class=\"grvsc-line\">   digitalWrite(13,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000);</span>\n<span class=\"grvsc-line\">    digitalWrite(13,HIGH);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000) ;</span>\n<span class=\"grvsc-line\">  digitalWrite(13,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,LOW);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> else if(t == &#39;E&#39;){</span>\n<span class=\"grvsc-line\">   digitalWrite(11,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000);</span>\n<span class=\"grvsc-line\">    digitalWrite(13,HIGH);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000); </span>\n<span class=\"grvsc-line\">  digitalWrite(13,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,LOW);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> else if(t == &#39;Z&#39;){</span>\n<span class=\"grvsc-line\">   digitalWrite(13,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000);</span>\n<span class=\"grvsc-line\">  digitalWrite(12,HIGH);</span>\n<span class=\"grvsc-line\">  digitalWrite(10,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000) ;</span>\n<span class=\"grvsc-line\">  digitalWrite(12,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(10,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(13,LOW);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\"> else if(t == &#39;C&#39;){</span>\n<span class=\"grvsc-line\">   digitalWrite(11,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000);</span>\n<span class=\"grvsc-line\">    digitalWrite(12,HIGH);</span>\n<span class=\"grvsc-line\">  digitalWrite(10,HIGH);</span>\n<span class=\"grvsc-line\">  delay(2000); </span>\n<span class=\"grvsc-line\">  digitalWrite(12,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(11,LOW);</span>\n<span class=\"grvsc-line\">  digitalWrite(10,LOW);</span>\n<span class=\"grvsc-line\">}</span>\n<span class=\"grvsc-line\">}</span></code></pre>\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":"November 04, 2020","updated_date":null,"description":"In this blog, you will learn how to make a Bluetooth controlled Arduino Car.","title":"Bluetooth Controlled Arduino Car Miniature","tags":["Arduino","Bluetooth"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/8506853b30d28d4025e1c2a0ad2593a6/ee604/Arduinocar.png","srcSet":"/static/8506853b30d28d4025e1c2a0ad2593a6/69585/Arduinocar.png 200w,\n/static/8506853b30d28d4025e1c2a0ad2593a6/497c6/Arduinocar.png 400w,\n/static/8506853b30d28d4025e1c2a0ad2593a6/ee604/Arduinocar.png 800w,\n/static/8506853b30d28d4025e1c2a0ad2593a6/db955/Arduinocar.png 900w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Abhishek Potekar","github":"Madmaxcoder2612","avatar":null}}}},{"node":{"excerpt":"Amazon Web Services offers scalable, reliable, and inexpensive cloud computing services. Below are some salient features provided by AWS…","fields":{"slug":"/engineering/a-journey-with-aws/"},"html":"<p>Amazon Web Services offers scalable, reliable, and inexpensive cloud computing services. Below are some salient features provided by AWS.</p>\n<ol>\n<li>Secure cloud services platform</li>\n<li>Compute power</li>\n<li>Database storage</li>\n<li>Content delivery </li>\n<li><strong>Pay for what you use</strong></li>\n</ol>\n<p>Prerequisites:</p>\n<ul>\n<li>AWS Account</li>\n<li>Active internet connection</li>\n<li>CLI usage</li>\n</ul>\n<h2 id=\"aws-ec2elastic-compute-cloud\" style=\"position:relative;\"><a href=\"#aws-ec2elastic-compute-cloud\" aria-label=\"aws ec2elastic compute cloud 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>AWS EC2(Elastic Compute Cloud)</h2>\n<p>It is the most commonly used service of AWS and catered deployment of various applications as per AMI configured before creating an EC2 Instance.\nAmazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure and resizable compute capacity in the cloud.\nIt is designed to make web-scale cloud computing easier for developers. <br>\n<strong>Here are some of the important steps while setting up new EC2 Instance-></strong> <br></p>\n<p>Choose an Amazon AMI.\n<span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 46.15384615384615%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAABfElEQVQoz22SyU7DQBBE/f+fxIEDQkickEAJm7J798Qe72tcdHUIRAJLpbF77FfVPXYC30MYBAjDUOX7PowxiOMYWZbhdDphHEfVNE36/N9lmwn9OMMpyxKFKM9zWJsjLwp0XYd5nv98xBpF6EWjmLT9KJsnDMMAx6ZGYdNEZ9E8CrBH27ZomgZ1XasBxRp1DaSKusP9MsImKuGEYYDVaoU0zbDbbfH+utB2o+/2qUBGwjFwBDQntO97NRmGXu4HPH4YuKYWYGyw2+9xPB5RFtJ2ZhSepqnWCLHWopBRMDFB1+kVPox42pXwsw5OYjJEUazO280ay8WzpAo01V6MXNeF53kKP8/Z/qw0K8Woalo8LAO4ibSc5/Y3hbyYJgaJtGe+FUURkiTRhAQx2WWmei8J66bD3at0mkjLhNGdwMNhj4/PNwWxRl1+IcKuD4itnyWHJTO8efKwDovzb8OXq6oCD2izXf8kYu2yz5VArpTu6X4ha4PblxjbuMIXWwmvDzeZGigAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS\"\n        title=\"AWS\"\n        src=\"/static/39375118427b51e5a9addb9f636f8b74/e5715/AWS_EC21.png\"\n        srcset=\"/static/39375118427b51e5a9addb9f636f8b74/a6d36/AWS_EC21.png 650w,\n/static/39375118427b51e5a9addb9f636f8b74/e5715/AWS_EC21.png 768w,\n/static/39375118427b51e5a9addb9f636f8b74/67a79/AWS_EC21.png 1408w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>Choose the instance type.\n<span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 48.15384615384615%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABrElEQVQoz5VS2Y6dMAzl/z+mUv+j6nulau703gJZIJCNkAQ4tTND3/rQSEdecxzH7iazQosesn9CzzMWv6EcF1I5sH/Cp4K4V6RccZwnruv6J7pp0hiGEdZ5aK0gpUBMO2z8IAEu/M/pxnEAg4m1UlBSkj1ilAqjkJBCYFkWWGvhvSNJHWlNPtNsR/4QApwj6T06szo8f/dYSHLLcpqabl2AWVaoyYBzfr3oWxTFLHUyLxSz4O96vD+psIKgmJpmatnueHtJGFfwUAN+DA+EDLh0NdjtbLaYPYzPTfc39gsvYSANvTCdWCnYbfsOpSewDHFrf1mOE6UeDblUVLKdD9job1kvx9GQKT6bpcU4LxFHt4aEx2sAy8VHaGplKyciTTfmjwmnetEr1pbDOsdvDNTqbAMCDdDGhK7kjHVdUUpGpgrbtuE8j4aDXlFLwUWrwn7OPUlnP7++EiINJJP/qLXFuy0l9H2PRDLGSNNyfy+1i0xI+8VFOYcPF7nPYmZEKsaHiTu+xIk3QaVKTMCkN9hmEl52GyJeo8aXbxpfv0/4+RQQtHaC1mumLfkDmiYD4QmXc7YAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS\"\n        title=\"AWS\"\n        src=\"/static/2b98ce5fcfa460cd9d674eb4884f8121/e5715/AWS_EC22.png\"\n        srcset=\"/static/2b98ce5fcfa460cd9d674eb4884f8121/a6d36/AWS_EC22.png 650w,\n/static/2b98ce5fcfa460cd9d674eb4884f8121/e5715/AWS_EC22.png 768w,\n/static/2b98ce5fcfa460cd9d674eb4884f8121/133ae/AWS_EC22.png 1424w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>Configure security group(It allows specific IP's that user will give permission to specific ports as per requirement.)\n<span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 48.76923076923077%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABSElEQVQoz52Ry3KEIBBF+f+/yTI/kU22WY1veSsoOCM3DWqSxSySUHWquy9tewHGpQYXCj2XEJQPQsItAUvY4NeIZQ3wk8FsJBbvsMYN9/v9Kfu+g7VNg77rUFU3okJdN+DjCME5jNEwWpdojYHWitBQSp1IKDtDmQlKSszzDIZzTdME5xzs5NC2LYQQ2Lat7KWU8NvF1nVFjKG4aMjtOA7kskLf9yV23TE8O7PWYouR+iP9LCKEUFxFipfG+mGENhbLstIdKnAu4P1Cjmd0/UCDTKnHkdPwvsTcbywdUxncbnXR87e5l8mhRvSKzhWBPROQiJKno8ZZZz091m+yni79gD1cCyc+4E0F9wNv6yPmWt9O7ajznj/39sCRNnEQBdjXheeY9j+RLvYTylm6ZuHvPH3l7PA/ZBfbI8HTY7ajxsubwOu7xCd3vQcxzSIDPgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS\"\n        title=\"AWS\"\n        src=\"/static/58a086d6cddcc19dc4af4208b8f996a1/e5715/AWS_EC23.png\"\n        srcset=\"/static/58a086d6cddcc19dc4af4208b8f996a1/a6d36/AWS_EC23.png 650w,\n/static/58a086d6cddcc19dc4af4208b8f996a1/e5715/AWS_EC23.png 768w,\n/static/58a086d6cddcc19dc4af4208b8f996a1/afd61/AWS_EC23.png 1431w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>Login to EC2 via CLI</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">$ ssh -i ec2-key.pem ec2-user@11.11.11.111</span></code></pre>\n<p>Switch to ROOT</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">sudo su</span></code></pre>\n<h2 id=\"aws-rdsrelational-database-service\" style=\"position:relative;\"><a href=\"#aws-rdsrelational-database-service\" aria-label=\"aws rdsrelational database service 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>AWS RDS(Relational Database Service)</h2>\n<p>Amazon Relational Database Service is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides a resizable,  cost-efficient capacity for an industry-standard relational database and manages everyday database administration tasks.\nAfter setting up RDS, you can be logged in to the local tool(SQL Developer/ MY SQL Workbench) and copy RDS's endpoint with Username/Password configured while setting RDS.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 760px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 90.15384615384615%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsTAAALEwEAmpwYAAACuklEQVQ4y51U22rcMBT0/39AH/sBJYW+9KlQKBRKKAklLck6m653vd71/W5ZvkienCN7k01oXioYjnXxaHTOSFYcxbDte7g7F6uVDcdxsF6vTbSpvzv46IYRQ9+jJwzDYOJbsGrRIsoK5FWNJC8pNsjo28SyQtG0aJmQiQgcx3HEqJSBWuJAYwwrlRp3XoLbzQ62e4SXlghribCijZaYy9GQBWEEd++hrCoIEtIIgbpuTJRdR+QaVjNOOBQCTpBiFxcLcuyT0kQvq5B1pERrQ+hRCo5BiILUl4QsL8wGrFxrJux61L2CGDWaQaHqhhcoJaHtIGWHVkqjRFLsz1LA0YwTrLIsEccx0jRFlmVo2/YM4lX/GYIhGGL+XmAx2f36wVR162znpC87/w8sPkZKyvjoCoCeJsrXZOJE4Ka1Mvk5jellfJ7T85ie5yy/lPi18WHvfTz4CTKpkBA4rx3lJIqi+UfGmU2yPEeSZmaOq6uWOaseJsRiwM/fNi5v7lBRP++1IcSkkZB1Pn94DxlsZuITKXlOUo6d22u0opmJucr1QD91GlerDX7c2EhZIfXLjhMwQdD8x08XqEJ3UTMr5BZ5DlbX35+ObRRKsktFilpaI8iTzcB9BR7nBZPWs7KJycano7FCvaSSc2puDStk9rIoEAY+hk4aVRMXgRZIKlRMxh046aeCLWRFXZPVMuSUy5zWqBPhMM7yv1z+wbuLr+bbyKdJRT/2uy3Ufg8dhpjIEYaU0FKxHHpE/CAw/mVCc1O4Qtx2VOFvV7dPVTOXn68TGV4lMVQcQdNrwhvxXNcIOlWAw/FonPBMOM6GfKvpcyxHVosnz5sZY0IvzLD+uzW5YF8lSTp7jGJEbyUfe8nDy50Wk09nF4Cb1dGDwK/IkaT7Ph3hcMTOdeF5B7juHgG9LKcfplck/8IjQ7huFqyrrNkAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Available Databases\"\n        title=\"Available Databases\"\n        src=\"/static/d8b2d343908b287d565a18fa57154372/3c051/AWS_RDS.png\"\n        srcset=\"/static/d8b2d343908b287d565a18fa57154372/a6d36/AWS_RDS.png 650w,\n/static/d8b2d343908b287d565a18fa57154372/3c051/AWS_RDS.png 760w\"\n        sizes=\"(max-width: 760px) 100vw, 760px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<h2 id=\"aws-elasticache\" style=\"position:relative;\"><a href=\"#aws-elasticache\" aria-label=\"aws elasticache 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>AWS ElastiCache</h2>\n<p>Amazon ElastiCache allows you to seamlessly set up, run, and scale popular open-Source compatible in-memory data stores in the cloud. This service is commonly used to avoid unnecessary calls to RDS and improve the user experience by displaying the data faster.</p>\n<p>There are two types of cluster engine supported by AWS ElastiCache</p>\n<ul>\n<li>Redis</li>\n<li>Memcached</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.15384615384615%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAABW0lEQVQ4y41Sa2+CQBDkb7fWpFXTBK2pNenj3xkT/eALUEAQ7pjebMEcV7XdZFjucju7s7veaPIB//UT/uQL3cEYd48+Or0hHnojdJ6GBj7uzV138IL+cIqe/9ZC3+fdVPzz+B0eHFNlAa1KpEmMJElwPB6hzPm/5mmtQShlfFXJpdbVD1mWIwgjrFYr7HYBttstNpuNeGK/39exqoaGVxmSqiZq/pszLc9zLBYLLJdLqfZ0OgmyLBMSN+4s2SaxSYMgxGw2MxXupKLD4SDVk5TJ3GI8m6woCqnCvSNBakAfx7G8KctScJOQAev1WjLLgJre1tIumS33pmTzNUOCDIU9pNQ0TcWzQrffNwntcxRFmM/n56kmtXSSE5yy/b4luVkhOzMnyT5yCOqK9F+Sm2BK4TSZ+dIa0TdJbfzZQxr3LAxDZ3FVi4hTdreiVaFdDR82PboGJiCpHfsNQk7klNdShVAAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS Elasti Cache\"\n        title=\"AWS Elasti Cache\"\n        src=\"/static/cfc6a58469afeb93ed80642ead207a62/e5715/AWS_EC.png\"\n        srcset=\"/static/cfc6a58469afeb93ed80642ead207a62/a6d36/AWS_EC.png 650w,\n/static/cfc6a58469afeb93ed80642ead207a62/e5715/AWS_EC.png 768w,\n/static/cfc6a58469afeb93ed80642ead207a62/05fb0/AWS_EC.png 1138w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>Login to Redis locally via this command (First port can be anything except 6379 as it will direct AWS Redis to local Redis installed on the machine) and after first port, just paste the endpoint of Redis.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">ssh -f -i ec2-key.pem -N -L 6378:demo-redis.xxxx.xx.0001.xxxx.cache.amazonaws.com:6379 ec2-user@11.11.11.111</span></code></pre>\n<h2 id=\"aws-lex\" style=\"position:relative;\"><a href=\"#aws-lex\" aria-label=\"aws lex 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>AWS Lex</h2>\n<p>Amazon Lex provides advanced deep learning functionalities of ASR(Automatic Speech Recognition) &#x26; NLU(Natural Language Understanding). With the use of Lex, we can build chatbots that can converse using speech and text as mediums.\nThere are a few components of BOT that need to be understood to build it.</p>\n<ul>\n<li>Intent:- It is a particular goal that the user wants to achieve.</li>\n<li>Utterances:-These are spoken/typed phrases that invoke content.</li>\n<li>Slots:- Data provided by the user to fulfill the intent.</li>\n<li>Prompts:-These are queries/questions asked by the user to input the data.</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 74%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAACtElEQVQ4y31UaU8TURTld2o0hBgXBDQkRj74QayIKEpDwIVSbAAxQhcK2NpSoMsUCpXSSolFsP3QIqYbNV1m68zxvWmHFkRPcvOmr/PuPWfOva9FlmVQ0FV9rlarKJVKykr3isUiCoUCJEk6E81nVbSoG/QFKC9JEEWRJCzX9pqgFqVBi12UvKU5O3f2uHKoXC4rBQRBUNbzRc4XVBjm83n4/Qy8fj88Xi+ikRDZlcDzPNLpNFiWBcdxStAiFPF4HAzDIBAIwOPxIJlMNiSHQiH09j/HgHYUmmdD0L59hyLL11heIJtizmhC/9MBaIeHoenrg93haCTcDn/FTZ0Dt95voH2KQavBj2CyAJmv4OjnsWIKlU6jUqkoB52LVuhfj2J6Qg/dyDB8K65aQp4UHIsk0LXgwz3bOjqsPvQ4NnHCCaeON75qDfGSgB73LrrtAdxfDqJ9yY832/sNhsFIlDC0o3PGj2sGDy5PMNgiDCGwKBK3q3VTeGoM+a4V8nvQFcT1uXW0WzbR+pHBo5U9lEViCuUxFYnjxvwGOm0h3F7YxN2lLWRKRJooIJPNKjJVySw1h7DW2Ty4ol9D26QPl8ZX8WApgpJYd9m5s4fe8UkMTs7gjmERV6d82Pv1G7LII5vLnbYNx/OKrASR3MXso2M1gm5vFG3OHbwMxRuSU4k4XHY7GJcTJtcGXi3v4jDHQq6KSKWOUDjJg60QQ8pkegSSVBZhsTswojdAN/0B2jE9nG5vPSFpg+N0Fl+iMUT3D5A4iOHH4XfkSpxiA88LCjt1QqR62xhnZ/HksQZDLwah6X2IzzZbE8NUCmazGQtWK4wmE9bcbtpw/5wGinA4DMv8PD6RRGaLBd9isb9HrxmSyuiCi0D+T7EzlwMN2neZTEZpZtVd+kzHj/5PDaLRfEGoK8UfkmhEcz19YjQAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS Lex\"\n        title=\"AWS Lex\"\n        src=\"/static/27f62b87be9405b2c4160aeab5222eee/e5715/AWS_Lex.png\"\n        srcset=\"/static/27f62b87be9405b2c4160aeab5222eee/a6d36/AWS_Lex.png 650w,\n/static/27f62b87be9405b2c4160aeab5222eee/e5715/AWS_Lex.png 768w,\n/static/27f62b87be9405b2c4160aeab5222eee/7e4a6/AWS_Lex.png 952w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>Moreover, there are VERSIONS linked with bots, intents, and custom slots. With the help of versions, we can make changes in the dev version without any impact occurring in PROD; hence it helps to make Immutable versions of bot that is created using AWS Lex.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 69.84615384615384%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAACYUlEQVQ4y22Ty27aQBSG/S48DC/ToPQSmpAmQC+oapQ+A1JXTTfNKhuaBYssGlCCHU98v1+hqigv8PecMUaQdvFrPPb4n+/8c0ZpPT/CyWkf7cMTvH7zFu8GZ3h5eIre+4/of/gk5+1OD+2jHvYPOth/Vet4o2cvOmgddHHcHUARQuDu9icMXcAUBmzLhmM7JBemYcJ4NOC5LnzfI/kI5OghCHy5xn4U+D5SMRje4Op6AsWyDIiHOwhdx3QypVFgejvB7H4GTdVgkqFLhpZlPZEtR9M0IWiNRv8ZBKDEeQY/ipBkOcIoRZ7nkoQXj8djXF5eQtM0LBYL+a0oCil+llrPy7IaFT/0ca/OyCzEvCyRpCk8z5PqdrtoNpsYDodYrVZIkgRZlkntmObFWjkRpgk8yiOMY6RpRkph27Yss7W3h0ajgfPzz0T4S25iU76G5Uqimrg2loRxlsKlkB0q0w9i+pDBdegQgghfL76h3+/j+scIf5YL2ixBGEYykpKq2TZkEGkY0SLTsWFSZglRcjmO68G6uUI8GWG5/A1N5Phy4WGmcRWRJK0Nn+ZaEQZMF8gXbChLExrEbAqdTl97MKCLmFolQURZ/4+wlpJxFvMSxXqBJHQc2FR2nKR0EKksdV7yQeRkuEtYG24IU1rEyop8k0UYhpuTZppq7ss5P/Om21S7hOScllU/bRsyZUAxyNtBI4sNY8qZe7LOrepBqrAo65Lzfwy5+1VVle3Dvcc/sCGTsSG3FG9aUzE9R8GRVIRsxrutM+QfmJBvC5vyNeP+q9/zu7pX2YifNZ3uvBfgL4MA1JOPP07EAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS Lex Versions\"\n        title=\"AWS Lex Versions\"\n        src=\"/static/29fe85239a84f13823470cc3b162593e/e5715/AWS_LexV.png\"\n        srcset=\"/static/29fe85239a84f13823470cc3b162593e/a6d36/AWS_LexV.png 650w,\n/static/29fe85239a84f13823470cc3b162593e/e5715/AWS_LexV.png 768w,\n/static/29fe85239a84f13823470cc3b162593e/aa08e/AWS_LexV.png 967w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<h2 id=\"aws-api-gateway\" style=\"position:relative;\"><a href=\"#aws-api-gateway\" aria-label=\"aws api gateway 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>AWS API Gateway</h2>\n<p>This AWS service is used to Create, Publish, Maintain, and Monitor secure Application Programming Interfaces(<strong>API</strong>). Moreover, it provides an easy interface for code running on AWS Lambda.\nHere are some of the pointers that explain the need for this service.</p>\n<ul>\n<li>Efficient API Development.</li>\n<li>Performance at Scale.</li>\n<li>Cost-saving at scale.</li>\n<li>Flexible Security Controls.</li>\n</ul>\n<p>This service enables us to make APIs on the go with a few clicks; also, we can use the Mocking approach to make dummy routes without any original data. In this faking data is used and bouncing back to without any activity.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABG0lEQVQoz42SiW6DMBBE+f+frAikBWODsQ3hnu6YJEoVaLvSiGNX4ze2k6ZpoLXBsixonUdpGnk6+OChjcFHmiLLc6SXC2qZdd7H/pu8i70khA6327Ab+oCs0DC2jc3GWhRliVIpfBUFbNvKQuFQnGc/GccJ4zhi27ZoeFU1rPN3ygBT1zCmhhLTruviwvM8v2kYRgTpJ3gp2zpkn4WY7NGoPL+i73v8txKSUSwaMKIWIr6TUKkKqqqErsf8pFvetexKHmasTkjcfT8Y2Un0WminaZJIg+z17VDsMa6Vvf9ByJ+vJxcJhY6RXxc+K84cGj4J/X51eHoPkjOxz4Snhg9VWseTpRj9TDSM9/A3QkauJDIJnXyv6/pn7G+pSwh8eghThwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS API Gateway\"\n        title=\"AWS API Gateway\"\n        src=\"/static/6476a0f189d08b6bd81760c48ec0f9bb/e5715/AWS_API.png\"\n        srcset=\"/static/6476a0f189d08b6bd81760c48ec0f9bb/a6d36/AWS_API.png 650w,\n/static/6476a0f189d08b6bd81760c48ec0f9bb/e5715/AWS_API.png 768w,\n/static/6476a0f189d08b6bd81760c48ec0f9bb/1e093/AWS_API.png 1376w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<h2 id=\"aws-dynamodb\" style=\"position:relative;\"><a href=\"#aws-dynamodb\" aria-label=\"aws dynamodb 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>AWS DynamoDB</h2>\n<p>Dynamo DB is a NO SQL database provided by Amazon Web Services. The main job of Dynamo DB is to Store &#x26; Retrieve any amount of data and serve any level requests of traffic.\nIn this, there are different terminologies as that of a regular database. Secondary Indexes is a Data Structure that contains a subset of attributes from a table.</p>\n<ul>\n<li>Partition &#x26; Sort Keys (Partition key is single primary key composed of one attribute only)</li>\n<li>\n<p>Local &#x26; Global Secondary Indexes</p>\n<ul>\n<li>Local Index: Index with same partition key as of base table but different sort key</li>\n<li>Global Index: In the global index, both the partition key and sort key can differ from that of the base table.  </li>\n</ul>\n</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 55.69230769230769%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAABUklEQVQoz5WSi26DMAxF+f9/7DaVAoFCeYRXSODO1y2snTRts3SUl33tOInGcYQxBnme65hlGZIkgbUWzjnM8/wC96ZpOuBe0zRI01RjIgpSoCxLFEWhooQOhGdxHB+J6NP3vTIMg47UWJYFtAgPo0ghVVZVhbZtEUJQvPca9Bfbtu0uyEnXdSpU1zW6thExr6xrkEq+Ktr9fyLaJ+oovBuL/HqDHaRHLijW/kPwpWThI2sRmxp179EMHpUNKOtORDtt+m8WMTObfj6fj+Y64hZMs9ORa/aSL8xz9Xma76zrehfcn5ywjxz7x3qQc/aX1937vLPHEJ4xSfS95KKZJUGmVd/kgf5r0WsHIVdbEMv1T6cT3oRU/l5yuUiSBFf5g9M0avX8Ac9xh2BYNzi/3gkbRudhihKpkU9+rXBJjc4vWa77/Tij7Ud5fa/+R6zgZf0JG0xVhVQuTaAAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS Dynammo\"\n        title=\"AWS Dynammo\"\n        src=\"/static/092e8d1d77c1e9912f7f58f5dbb15977/e5715/AWS_Dynammo.png\"\n        srcset=\"/static/092e8d1d77c1e9912f7f58f5dbb15977/a6d36/AWS_Dynammo.png 650w,\n/static/092e8d1d77c1e9912f7f58f5dbb15977/e5715/AWS_Dynammo.png 768w,\n/static/092e8d1d77c1e9912f7f58f5dbb15977/f79fa/AWS_Dynammo.png 940w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></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":"November 03, 2020","updated_date":null,"description":"Learn about various AWS services and how to set up in a step by step tutorial.","title":"AWS Services-Walkthrough","tags":["AWS","Serverless"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/1bc36a6b88cc1025d3852dc1ffe6eef6/ee604/aws.png","srcSet":"/static/1bc36a6b88cc1025d3852dc1ffe6eef6/69585/aws.png 200w,\n/static/1bc36a6b88cc1025d3852dc1ffe6eef6/497c6/aws.png 400w,\n/static/1bc36a6b88cc1025d3852dc1ffe6eef6/ee604/aws.png 800w,\n/static/1bc36a6b88cc1025d3852dc1ffe6eef6/db955/aws.png 900w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Nitin Gupta","github":"ng29","avatar":null}}}},{"node":{"excerpt":"As we all know, Twitter is one of the most preferred microblogging websites when it comes to putting your thoughts on the internet. Big…","fields":{"slug":"/engineering/beginners-guide-to-tweepy/"},"html":"<p>As we all know, Twitter is one of the most preferred microblogging websites when it comes to putting your thoughts on the internet. Big organizations use this platform for advertising their product; government institutions even use it to provide prompt customer resolution; various groups use Twitter to run social awareness campaigns and media campaigns. Twitter has close to 330 million monthly active users worldwide, out of which 17 million hits are generated from India itself along with more than 1 billion downloads on Play Store. With all this in mind, Twitter allows access to Twitter API to developers to create some cool applications like bots, automation tools, etc. This Twitter API gives developers access to almost all of Twitter's functionalities like likes, retweets, tweets, etc. Tweepy, a python package, helps us in achieving all this.</p>\n<p>Tweepy is a python package that smoothly and transparently accesses Twitter's endpoints made available for the developers. Without Tweepy, the user would have to take care of various low-level details about HTTP requests, rate limiting, authentication, serialization, etc. Tweepy handles all this mess on behalf of the user making the application prone to errors.\nIn simple words, Tweepy is an open-source python package that provides a way for developers to communicate with the Twitter API. But keep in mind that Twitter levies a rate limit on the number of requests made to the Twitter API. To be precise, 900 requests/15 minutes are allowed; Twitter feeds anything above that an error.</p>\n<h3 id=\"installation\" style=\"position:relative;\"><a href=\"#installation\" aria-label=\"installation 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>Installation</h3>\n<p>Tweepy can be installed by using Python package manager <strong>pip</strong>. A simple demonstration can be seen below:\n<img src=\"/40dde8efec2ad55ac4676067a47623cc/installation.png\" alt=\"installation\" title=\"Installation\"></p>\n<p>Installation on Linux and macOS should follow similar steps as well.</p>\n<p>Twitter API uses OAuth for authentication, so initially, you need to apply for authentication credentials from Twitter. These authentication credentials basically consists of 4 components namely : <em>consumer</em>key, consumer<em>secret</em>key, access<em>token, access</em>token<em>secret</em> . These credentials from Twitter are used to instantiate the API. <strong>Each account gets a unique key, so don't reuse someone else's keys.</strong>\nFor getting those credentials from Twitter, apply for a developer account on the <a href=\"https://developer.twitter.com/en\">Twitter Developers</a> page.\n<img src=\"/5c15dfefc6853d899b15baf7a91ab241/twitterdev.png\" alt=\"twitterdev\" title=\"Twitter Dev Dashboard\">\nThis is what the account looks like. Here you will get detailed information about the total no. of requests made, your API credentials, and much more information. After creating an account, you need to create an app wherein you will be asked to name your app and a short description. You must be wondering what an app is?\nThe app is like a gateway that contains a set of permissions and keys used to access the Twitter API. An app is needed for accessing the Twitter API as a part of Twitter's OAuth authentication. After creating an app, generate new authentication tokens for authorization purposes.</p>\n<p><img src=\"/3e1ad6c1ae5d8e5ab84b112068ba87f1/keys.png\" alt=\"keys\"></p>\n<h3 id=\"getting-started-tweepy\" style=\"position:relative;\"><a href=\"#getting-started-tweepy\" aria-label=\"getting started tweepy 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>Getting Started: Tweepy</h3>\n<p>There are four common basic steps in any Tweepy application.</p>\n<ol>\n<li>Importing tweepy package.</li>\n<li>Setting the authentication credentials.</li>\n<li>Instantiating the API.</li>\n<li>Creating API object.</li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> tweepy</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># authenticating twitter api credentials</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">consumer_key = </span><span class=\"mtk8\">&#39;2OsNoPKOYCpxxxxxxxxxxxxxxxxxxxxxx&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">consumer_secret = </span><span class=\"mtk8\">&#39;Xw07uU51xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">access_token = </span><span class=\"mtk8\">&#39;24621057xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">access_token_secret = </span><span class=\"mtk8\">&#39;pXt5xxxxxxxxxxxxxxxxxxxxxxxxxxxx&#39;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># instantiating the api</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">auth = tweepy.OAuthHandler(consumer_key, consumer_secret)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">auth.set_access_token(access_token, access_token_secret)</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk3\"># creating API object</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">api = tweepy.API(auth,</span><span class=\"mtk12\">wait_on_rate_limit</span><span class=\"mtk1\">=</span><span class=\"mtk4\">True</span><span class=\"mtk1\">,</span><span class=\"mtk12\">wait_on_rate_limit_notify</span><span class=\"mtk1\">=</span><span class=\"mtk4\">True</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\"> tabulate</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">user = api.get_user(</span><span class=\"mtk8\">&quot;Cristiano&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;User Details:&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(tabulate([[</span><span class=\"mtk8\">&quot;Name&quot;</span><span class=\"mtk1\">,</span><span class=\"mtk8\">&quot;Description&quot;</span><span class=\"mtk1\">,</span><span class=\"mtk8\">&quot;Location&quot;</span><span class=\"mtk1\">],[user.name,user.description,user.location]],</span><span class=\"mtk12\">headers</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;firstrow&quot;</span><span class=\"mtk1\">))</span></span></code></pre>\n<blockquote>\n<p>Note: Use your credentials in the hidden keys above._</p>\n</blockquote>\n<p>Objects created from the Tweepy. API class helps us access most of Twitter's available functionality like tweets, retweets, likes, etc. In the code snippet, we used the api.get_user method for getting information about a certain user on Twitter. Likewise, there can be several use cases of different methods(discussed below) made available by Twitter to developers. You can find the link for this code <a href=\"https://colab.research.google.com/drive/1dN02ioXElOQPOktIzNBACCncyrI2eiBR?usp=sharing\">here.</a></p>\n<p>Now we will see different methods provided by Twitter. The API methods have been divided into groups based on their functionality. The detailed guide for the API methods can be found at the official <a href=\"https://tweepy.readthedocs.io/en/latest/api.html\">API Reference</a> documentation. </p>\n<ul>\n<li>Timeline methods</li>\n<li>Status methods</li>\n<li>User methods</li>\n<li>Direct Message Methods</li>\n<li>Friendship Methods</li>\n<li>Favorite Methods</li>\n<li>Block Methods</li>\n<li>Search Methods</li>\n<li>Trends Methods</li>\n<li>Geo Methods</li>\n</ul>\n<h4 id=\"timeline-methods\" style=\"position:relative;\"><a href=\"#timeline-methods\" aria-label=\"timeline methods 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>Timeline Methods</h4>\n<p>These methods handles the tweets, retweets, statuses on your/someone else's timeline as long as the account is public.</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\">tweets = api.home_timeline()</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">for</span><span class=\"mtk1\"> tweet </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> tweets:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(</span><span class=\"mtk4\">f</span><span class=\"mtk8\">&quot;</span><span class=\"mtk4\">{</span><span class=\"mtk1\">tweet.user.name</span><span class=\"mtk4\">}</span><span class=\"mtk8\"> said </span><span class=\"mtk4\">{</span><span class=\"mtk1\">tweet.text</span><span class=\"mtk4\">}</span><span class=\"mtk8\">&quot;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>api.home_timeline() is an API method that returns the 20 most recent tweets on the user's timeline.</p>\n<h4 id=\"status-methods\" style=\"position:relative;\"><a href=\"#status-methods\" aria-label=\"status methods 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>Status Methods</h4>\n<p>These methods deal with creating, fetching tweets, retweeting tweets.</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\">api.update_status(</span><span class=\"mtk8\">&quot;Hello World!&quot;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>api.update_status() is an API method used to create a tweet on the user's timeline. For each update request, it will check the user's recent tweets. If any duplication is found, the request will be blocked by Twitter as a user cannot post the same tweet more than once.</p>\n<h4 id=\"user-methods\" style=\"position:relative;\"><a href=\"#user-methods\" aria-label=\"user methods 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>User Methods</h4>\n<p>These methods help to find the user details using various paramaeter like name, location, description,friends, followers,etc. as long as the account is public. </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=\"mtk1\">user = api.get_user(</span><span class=\"mtk8\">&quot;ISRO&quot;</span><span class=\"mtk1\">)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(user.name)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(user.decscription)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(user.followers)</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk11\">print</span><span class=\"mtk1\">(user.location)</span></span></code></pre>\n<p>We have used get_user() previously to fetch user details of specific accounts.</p>\n<h4 id=\"friendship-methods\" style=\"position:relative;\"><a href=\"#friendship-methods\" aria-label=\"friendship methods 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>Friendship Methods</h4>\n<p>These methods help the user to follow, unfollow certain accounts, list the accounts user follows, etc.</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=\"mtk1\">api.create_friendship(</span><span class=\"mtk8\">&quot;elonmusk&quot;</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>create_friendship() will add @elonmusk to the list of accounts you follow.</p>\n<h4 id=\"favorite-methods\" style=\"position:relative;\"><a href=\"#favorite-methods\" aria-label=\"favorite methods 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>Favorite Methods</h4>\n<p>Likes or unlikes(if already liked) the status specified in the ID parameter as the authenticating user.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"python\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">api.create_favorite(tweet.id)</span></span></code></pre>\n<p>create_favorite() will like a tweet based on the tweet id provided.</p>\n<h4 id=\"block-methods\" style=\"position:relative;\"><a href=\"#block-methods\" aria-label=\"block methods 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>Block Methods</h4>\n<p>Used to block, unblock, list blocked accounts of the user.</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=\"mtk1\">api.create_block(</span><span class=\"mtk11\">id</span><span class=\"mtk1\">/screen_name)</span></span></code></pre>\n<p>create<em>block() will block the specific user using the id/screen</em>name provided. </p>\n<h4 id=\"search-methods\" style=\"position:relative;\"><a href=\"#search-methods\" aria-label=\"search methods 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>Search Methods</h4>\n<p>These methods help the user to search specific tweet based upon the search query and parameters provided. But not all tweets will be indexed or made available through the search methods.</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=\"mtk15\">for</span><span class=\"mtk1\"> tweets </span><span class=\"mtk4\">in</span><span class=\"mtk1\"> api.search(</span><span class=\"mtk12\">q</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;iphone&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">lang</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;en&quot;</span><span class=\"mtk1\">):</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk11\">print</span><span class=\"mtk1\">(tweet.text)</span></span></code></pre>\n<p>search() will look out for all the tweets available for the query keyword 'q' provided.</p>\n<h4 id=\"trends-methods\" style=\"position:relative;\"><a href=\"#trends-methods\" aria-label=\"trends methods 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>Trends Methods</h4>\n<p>It returns the trends going on at a specific geographical location.</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=\"mtk1\">api.trends_place(</span><span class=\"mtk7\">1</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>trends_place() will show trends in the specific area. Here one stands for worldwide.</p>\n<h4 id=\"geo-methods\" style=\"position:relative;\"><a href=\"#geo-methods\" aria-label=\"geo methods 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>Geo Methods</h4>\n<p>It returns the geographical location like latitude, the longitude of the place id provided.</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=\"mtk1\">api.geo_id(</span><span class=\"mtk11\">id</span><span class=\"mtk1\">)</span></span></code></pre>\n<p>geo_id() returns more geographical information of the concerned place id.</p>\n<h3 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</h3>\n<p>Tweepy allows the user to concentrate on the application's logic by hiding many low-level details, thus making the application bug-free. You can use tweepy to do some cool projects like bots, automation, machine learning applications, etc. </p>\n<h5 id=\"ket-takeaways\" style=\"position:relative;\"><a href=\"#ket-takeaways\" aria-label=\"ket takeaways 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>Ket Takeaways</h5>\n<ul>\n<li>What is Tweepy?</li>\n<li>Installation</li>\n<li>Getting Started with Tweepy</li>\n<li>Various API methods</li>\n</ul>\n<p>More information about tweepy can be found at <a href=\"https://tweepy.readthedocs.io/en/latest/index.html\">docs.</a> Make sure to look at the official documentation as it will provide you with a greater picture of the package. So what are you waiting for? Go ahead, use your imagination, and get started with the side-project you've always been thinking of.</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 .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n</style>","frontmatter":{"date":"November 02, 2020","updated_date":null,"description":"Learn how to use Twitter APIs using Tweepy, a python package,","title":"Beginners Guide to Tweepy ","tags":["Twitter","Tweepy","Python"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/63d4d3ea1070111c43e0bdfa476b2a62/14b42/coverimage.jpg","srcSet":"/static/63d4d3ea1070111c43e0bdfa476b2a62/f836f/coverimage.jpg 200w,\n/static/63d4d3ea1070111c43e0bdfa476b2a62/2244e/coverimage.jpg 400w,\n/static/63d4d3ea1070111c43e0bdfa476b2a62/14b42/coverimage.jpg 800w,\n/static/63d4d3ea1070111c43e0bdfa476b2a62/47498/coverimage.jpg 1200w,\n/static/63d4d3ea1070111c43e0bdfa476b2a62/0e329/coverimage.jpg 1600w,\n/static/63d4d3ea1070111c43e0bdfa476b2a62/d8255/coverimage.jpg 1920w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Sameer Mahajan","github":"sameermahajan101","avatar":null}}}}]},"markdownRemark":{"excerpt":"Google has prepared a roadmap to restrict third-party cookies in Chrome. Since 04 January 2024, Chrome has rolled out third-party cookie…","fields":{"slug":"/engineering/identity-impact-of-google-chrome-thirdparty-cookie-restrictions/"},"html":"<p>Google has prepared a roadmap to restrict third-party cookies in Chrome. Since 04 January 2024, Chrome has rolled out third-party cookie restrictions for 1% of stable clients and 20% of Canary, Dev, and Beta clients.</p>\n<p><strong>What does it mean for user authentication?</strong></p>\n<p>On one hand, Google believes third-party cookies are widely used for cross-site tracking, greatly affecting user privacy. Hence, Google wants to phase out (or restrict) supporting third-party cookies in Chrome by early Q2 2025 (subject to regulatory processes).</p>\n<p>On the other hand, Google introduced Privacy Sandbox to support the use cases (other than cross-site tracking and advertising) previously implemented using third-party cookies.</p>\n<p>In this article, we’ll discuss:</p>\n<ul>\n<li>How is user authentication (identity) affected?</li>\n<li>What is Google offering as part of Privacy Sandbox to support various identity use cases when third-party cookies are phased out?</li>\n</ul>\n<h2 id=\"how-is-user-authentication-affected\" style=\"position:relative;\"><a href=\"#how-is-user-authentication-affected\" aria-label=\"how is user authentication affected 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 is User Authentication Affected?</h2>\n<p>Third-party cookie restrictions affect user authentication in three ways, as follows.</p>\n<h3 id=\"external-identity-providers\" style=\"position:relative;\"><a href=\"#external-identity-providers\" aria-label=\"external identity providers 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>External Identity Providers</h3>\n<p>If your website or app uses an external Identity Provider (IdP) — like LoginRadius, the IdP sets a third-party cookie when the user authenticates on your app.</p>\n<h3 id=\"web-sso\" style=\"position:relative;\"><a href=\"#web-sso\" aria-label=\"web sso 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>Web SSO</h3>\n<p>If you have multiple apps across domains within your organization and authentication is handled using an IdP (internal or external) with web SSO, you already use third-party cookies to facilitate seamless access for each user using a single set of credentials.</p>\n<p>If you have implemented web SSO with one primary domain and multiple sub-domains of the primary domain, third-party cookie restrictions may not apply. For now, Google doesn’t consider the cookies set by sub-domains as third-party cookies, although this stance may change in the future.</p>\n<p>For example, you have apps at <code>example.com</code>, <code>travel.example.com</code>, <code>stay.example.com</code>, and web SSO is handled by <code>auth.example.com</code>. In this case, third-party cookie restrictions don’t apply.</p>\n<h3 id=\"federated-sso\" style=\"position:relative;\"><a href=\"#federated-sso\" aria-label=\"federated sso 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>Federated SSO</h3>\n<p>Federated SSO is similar to, albeit different from, web SSO. It can handle multiple IdPs and applications—aka., Service Providers (SPs)—spanning multiple organizations. It can also implement authentication scenarios that are usually implemented through web SSO.</p>\n<p>Usually, authentication is handled on a separate pop-up or page when the user wants to authenticate rather than on the application or website a user visits. </p>\n<p>For example, you already use federated SSO if you facilitate authentication for a set of apps through multiple social identity providers as well as traditional usernames and passwords.</p>\n<blockquote>\n<p><strong>Note</strong>: It is also possible to store tokens locally, not within cookies. In this case, third-party cookie restrictions won’t affect token-based authentication. However, the restrictions still affect authentication where tokens are stored within third-party cookies (a common and secure method).</p>\n</blockquote>\n<h2 id=\"chromes-alternatives-for-third-party-cookies\" style=\"position:relative;\"><a href=\"#chromes-alternatives-for-third-party-cookies\" aria-label=\"chromes alternatives for third party cookies 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>Chrome’s Alternatives for Third-Party Cookies</h2>\n<p>Google has been developing alternative features and capabilities for Chrome to replace third-party cookies as part of its Privacy Sandbox for Web initiative.</p>\n<p>Specific to authentication, Google recommends the following:</p>\n<ol>\n<li>Cookies Having Independent Partitioned State (CHIPS)</li>\n<li>Storage Access API</li>\n<li>Related Website Sets</li>\n<li>Federated Credential Management (FedCM) API</li>\n</ol>\n<h3 id=\"cookies-having-independent-partitioned-state-chips\" style=\"position:relative;\"><a href=\"#cookies-having-independent-partitioned-state-chips\" aria-label=\"cookies having independent partitioned state chips 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>Cookies Having Independent Partitioned State (CHIPS)</h3>\n<p><a href=\"https://developers.google.com/privacy-sandbox/3pcd/chips\">CHIPS</a> are a restricted way of setting third-party cookies on a top-level site without making them accessible on other top-level sites. Thus, they limit cross-site tracking and enable specific cross-site functionalities, such as maps, chat, and payment embeds.</p>\n<p>For example, a user visits <code>a.com</code> with a map embed from <code>map-example.com</code>, which can set a partitioned cookie that is only accessible on a.com. </p>\n<p>If the user visits <code>b.com</code> with a map embed from <code>map-example.com</code>, it cannot access the partitioned cookie set on <code>a.com</code>. It has to create a separate partitioned cookie specific to <code>b.com</code>, thus blocking cross-site tracking yet allowing limited cross-site functionality.</p>\n<p>You should specifically opt for partitioned cookies (CHIPS), which are set with partitioned and secure cookie attributes.</p>\n<p>If you’re using an external identity provider for your application, CHIPS is a good option to supplant third-party cookie restrictions. </p>\n<p>However, CHIPS may not be ideal if you have a web SSO or federated SSO implementation. It creates separate partitioned cookies for each application with a separate domain, which can increase complexity and create compatibility issues.</p>\n<h3 id=\"storage-access-api\" style=\"position:relative;\"><a href=\"#storage-access-api\" aria-label=\"storage access 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>Storage Access API</h3>\n<p>With <a href=\"https://developers.google.com/privacy-sandbox/3pcd/storage-access-api\">Storage Access API</a>, you can access the local storage in a third-party context through iframes, similar to when users visit it as a top-level site in a first-party context. That is, it gives access to unpartitioned cookies and storage.</p>\n<p>Storage Access API requires explicit user approval to grant access, similar to locations, camera, and microphone permissions. If the user denies access, unpartitioned cookies and storage won’t be accessible in a third-party context.</p>\n<p>It is most suitable when loading cross-site resources and interactions, such as:</p>\n<p>Verifying user sessions when allowing interactions on an embedded social post or providing personalization for an embedded video.\nEmbedded documents requiring user verification status to be accessible.</p>\n<p>As it requires explicit user approval, it is advisable to use Storage Access API when you can’t implement an identity use case with the other options.</p>\n<h3 id=\"related-website-sets\" style=\"position:relative;\"><a href=\"#related-website-sets\" aria-label=\"related website sets 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>Related Website Sets</h3>\n<p>With <a href=\"https://developers.google.com/privacy-sandbox/3pcd/related-website-sets\">Related Website Sets</a>, you can declare a <code>primary</code> website and <code>associatedSites</code> for limited purposes to grant third-party cookie access and local storage for a limited number of sites.</p>\n<p>Chrome automatically recognizes related website sets declared, accepted, and maintained in this open-source GitHub repository: <a href=\"https://github.com/GoogleChrome/related-website-sets\">Related Website Sets</a></p>\n<p>It provides access through Storage Access API directly without prompting for user approval, but only after the user interacts with the relevant iframe.</p>\n<p>It is important to declare a limited number of domains in related website sets that are meaningful and used for specific purposes. Google may block or suspend any exploitative use of this feature.</p>\n<p>The top-level site can also request approval for specific cross-site resources and scripts to Storage Access API using <code>resuestStorageAccessFor()</code> API.</p>\n<p>If you’re using an external identity provider for your web application, you can declare the domain of the identity provider in the related set to ensure limited third-party cookies and storage access to the identity provider, thus ensuring seamless user authentication.</p>\n<p>Related Website Sets can also work to supplement third-party cookie restrictions in web SSO and federated SSO if the number of web applications (or domains) is limited.</p>\n<h3 id=\"federated-credential-management-fedcm-api\" style=\"position:relative;\"><a href=\"#federated-credential-management-fedcm-api\" aria-label=\"federated credential management fedcm 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>Federated Credential Management (FedCM) API</h3>\n<p>FedCM API enables federated SSO without third-party cookies.</p>\n<p>With FedCM API, a user follows these steps for authentication:</p>\n<ol>\n<li>The User navigates to a Service Provider (SP) — aka., Relying Party (RP)</li>\n<li>As the user requests to authenticate, the SP requests the browser through FedCM API to initiate authentication.</li>\n<li>The browser displays a list of available identity providers (supported by the RP), such as social IdPs like Google, Apple, LinkedIn, and Facebook, or other OAuth IdPs like LoginRadius.</li>\n<li>Once the user selects an IdP, the browser communicates with the IdP. Upon valid authentication, the IdP generates a secure token.\nThe browser delivers this secure token to the RP to facilitate user authorization.</li>\n</ol>\n<p>You can access a user demo of FedCM here: <a href=\"https://fedcm-rp-demo.glitch.me/\">FedCM</a>. </p>\n<p>For more information about implementing federated SSO with FedCM API, go through the <a href=\"https://developers.google.com/privacy-sandbox/3pcd/fedcm-developer-guide\">FedCM developer guide</a>.</p>\n<h2 id=\"how-is-loginradius-preparing-for-the-third-party-cookie-phase-out\" style=\"position:relative;\"><a href=\"#how-is-loginradius-preparing-for-the-third-party-cookie-phase-out\" aria-label=\"how is loginradius preparing for the third party cookie phase out 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 is LoginRadius Preparing for the Third-party Cookie Phase-out?</h2>\n<p>Firstly, we’re committed to solving our customers' user identity pain points — and preparing for the third-party cookies phase-out is no different.</p>\n<p>We’ll implement the most relevant and widely useful solutions to facilitate a smooth transition for our customers.</p>\n<p>Please subscribe to our blog for more information. We’ll update you on how we help with the third-party cookie phase-out.</p>\n<h2 id=\"in-conclusion\" style=\"position:relative;\"><a href=\"#in-conclusion\" aria-label=\"in 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>In Conclusion</h2>\n<p>The proposed changes to phase out third-party cookies and suggested alternatives are evolving as Google has been actively collaborating and discussing changes with the border community.</p>\n<p>Moreover, browsers like Firefox, Safari, and Edge may approach restricting third-party cookies differently than Google does.</p>\n<p>From LoginRadius, we’ll keep you updated on what we’re doing as a leading Customer Identity and Access Management (CIAM) vendor to prepare for the third-party cookie phase-out.</p>\n<h2 id=\"glossary\" style=\"position:relative;\"><a href=\"#glossary\" aria-label=\"glossary 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>Glossary</h2>\n<p><strong>Top-level site</strong>: It is the primary site a user has visited.</p>\n<p><strong>First-party cookie</strong>: A cookie set by the top-level site.</p>\n<p><strong>Third-party cookie</strong>: A cookie set by a domain other than the top-level site. For example, let’s assume that a user has visited <code>a.com</code>, which might use an embed from <code>loginradius.com</code> to facilitate authentication. If <code>loginradius.com</code> sets a cookie when the user visits <code>a.com</code>, it is called a third-party cookie as the user hasn’t directly visited <code>loginradius.com</code>.</p>\n<h2 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references 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>References</h2>\n<ul>\n<li><a href=\"https://developers.google.com/privacy-sandbox/3pcd/prepare/prepare-for-phaseout\">Changes to Chrome's treatment of third-party cookies</a></li>\n<li><a href=\"https://developers.google.com/privacy-sandbox/3pcd/guides/identity\">Check the impact of the third-party cookie changes on your sign-in workflows</a></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</style>","frontmatter":{"date":"July 08, 2024","updated_date":null,"description":"Google Chrome has planned to phase out third-party cookies, which will affect different website functionalities depending on third-party cookies. This blog focuses on how this phase-out affects identity and user authentication and discusses alternatives for overcoming challenges.","title":"How Chrome’s Third-Party Cookie Restrictions Affect User Authentication?","tags":["Identity","Cookies","Chrome"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/eb7396060c0adc430dbed2d04b63d431/ee604/third-party-cookies-phaseout-chrome.png","srcSet":"/static/eb7396060c0adc430dbed2d04b63d431/69585/third-party-cookies-phaseout-chrome.png 200w,\n/static/eb7396060c0adc430dbed2d04b63d431/497c6/third-party-cookies-phaseout-chrome.png 400w,\n/static/eb7396060c0adc430dbed2d04b63d431/ee604/third-party-cookies-phaseout-chrome.png 800w,\n/static/eb7396060c0adc430dbed2d04b63d431/f3583/third-party-cookies-phaseout-chrome.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Raghunath Reddy","github":"raghunath-r-a","avatar":null}}}},"pageContext":{"limit":6,"skip":114,"currentPage":20,"type":"//engineering//","numPages":52,"pinned":"17fa0d7b-34c8-51c4-b047-df5e2bbaeedb"}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}