<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ledacoding</title>
    <description>The latest articles on DEV Community by ledacoding (@ledacoding).</description>
    <link>https://dev.to/ledacoding</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F872846%2Fa3b15107-725b-4e47-a86f-84d42be742a6.jpeg</url>
      <title>DEV Community: ledacoding</title>
      <link>https://dev.to/ledacoding</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ledacoding"/>
    <language>en</language>
    <item>
      <title>Stop overthinking and start choosing</title>
      <dc:creator>ledacoding</dc:creator>
      <pubDate>Fri, 01 Jul 2022 03:35:03 +0000</pubDate>
      <link>https://dev.to/ledacoding/stop-overthinking-and-start-choosing-37j3</link>
      <guid>https://dev.to/ledacoding/stop-overthinking-and-start-choosing-37j3</guid>
      <description>&lt;p&gt;Technology is a field that gives freedom and joy to many people. There are always new languages and frameworks we can learn, new fields we can get into, and new people we can work with. Today there is an opportunity to make money here and tomorrow a chance to contribute to an exciting project there. So much availability can be a great source of excitement and happiness. So many people feel welcome in this space.&lt;/p&gt;

&lt;p&gt;But there is another side to tech that is not as fun to talk about. This opportunity comes with a higher level of anxiety about what to do with ourselves. Since our time on this earth is limited and the options are plenty, we need to make choices constantly about what to get into and what to leave out. If we are not careful we will try to do too much and end in burnout or even worse, get completely paralyzed unable to decide.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Should we get into Twitter?&lt;/li&gt;
&lt;li&gt;Should we start a personal blog?&lt;/li&gt;
&lt;li&gt;Should we try technical writing?&lt;/li&gt;
&lt;li&gt;Should we do freelance work?&lt;/li&gt;
&lt;li&gt;Should we get more into crypto?&lt;/li&gt;
&lt;li&gt;Should we start coaching others?&lt;/li&gt;
&lt;li&gt;Should we learn this new technology?&lt;/li&gt;
&lt;li&gt;Should we build a more ambitious project with what we know?&lt;/li&gt;
&lt;li&gt;Should we try to enter the big company or the startup?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It can get overwhelming quickly.&lt;/p&gt;

&lt;p&gt;So to lower the anxiety we will need to make choices and focus.&lt;br&gt;
In this short piece I will try to answer the old question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can we decide what to do next with confidence and commitment?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have a good reason to do this since it all comes from my struggles. You see, I've been overthinking my choices for a long time, and even after I make them I get the feeling that they might not be quite right, that maybe there is a better alternative. Always overthinking, doubting, and postponing my choices.&lt;/p&gt;

&lt;p&gt;So in my doubt and my search I've been observing others and learning from those who know better than me. The ones that go through life with apparent ease despite the uncertainty. They don't seem to have any doubt, they are not tense and they don't linger in regret.&lt;/p&gt;

&lt;p&gt;Those people gave me a lesson that I want to share with you.&lt;/p&gt;

&lt;p&gt;I find this is the key to all the questions I had before, if you implement this idea into your life it has the potential to change everything.&lt;/p&gt;

&lt;p&gt;This was my discovery:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;All confident decision-makers believe their decision is the best available to them at this moment.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stop for a second and read it again. If you are not too impressed just wait. You will know why this is relevant in just a moment.&lt;/p&gt;

&lt;p&gt;There are two key phrases in this sentence.&lt;/p&gt;

&lt;p&gt;They believe their decision is the best &lt;strong&gt;avaliable to them&lt;/strong&gt; at &lt;strong&gt;this moment&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Available to them means they see reality. They are not thinking about options that are completely disconnected from their current reality. They are very aware of where they stand and the general direction in which they want to move their life. Self-awareness is the key to this. They know if the thing they are after is more freedom, more money, better relationships, and in which order. In other words: they know their values.&lt;/p&gt;

&lt;p&gt;Plus they believe there is a link between their current state and their desired state. It doesn't matter that they don't know all the steps or if they start from zero. They just need to know the starting point and the end. Most likely they won't start from zero because they have learned to play to their strengths.&lt;/p&gt;

&lt;p&gt;Many of us undervalue what we have. We write and think: what I write does not compare with what others write. Maybe writing is not the skill you have right now. Maybe your skill now is that you are a great reader. Maybe your skill is that you can think logically. Start with that. You are never starting from zero. Being a good reader and thinking logically is a strong start in order to become a good writer. Don't confuse the two.&lt;/p&gt;

&lt;p&gt;The resources you have might be the people you know. Knowing someone is a great resource. If your cousin has an exciting life as a freelancer that is something you have. You can get access to a person who seems to know how to lead an exciting life while freelancing. That person is easily available to you. Having access to the right person is something incredibly valuable.&lt;/p&gt;

&lt;p&gt;Confident decision-makers are very aware of their experiences, whatever they are. If they had to deal with an older sister growing up, that is something they have. That experience showed them how to communicate with older people, how to solve problems together, and how to play as a team. All experiences in life can be used in our favor if we see them from the right angle.&lt;/p&gt;

&lt;p&gt;This is an important aspect of making a choice. A choice starts with who you are now. We cannot pull it out of the ether. 'Know Thyself' was carved into stone at the entrance to Apollo's temple for a reason. It's pretty much impossible to decide if you don't know yourself. If you don't know what you have, if you undervalue it or if you choose to ignore it. Never ignore what you have and what is important to you. Knowing it is 50% of the equation.&lt;/p&gt;

&lt;p&gt;Now the second part.&lt;/p&gt;

&lt;p&gt;They believe their decision is the best available for them at &lt;strong&gt;this moment&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is about living in the now and recognizing that this moment is all we have. Confident decision-makers make their decisions quickly. As quickly as they can. &lt;/p&gt;

&lt;p&gt;Overthinkers like me have a false belief. "If I spend just a little more time I will make a better decision. Why rush it if it's important?". Don't make my mistake. You will never find enough time. You will quickly find yourself with too many choices and more questions than answers.&lt;/p&gt;

&lt;p&gt;To solve this issue I know a fantastic tool. It is called a deadline. A good deadline keeps the momentum going. We just need to pick a date and commit ourselves to choose. Even if we don't feel fully confident when our time is up we will place a bet.&lt;/p&gt;

&lt;p&gt;People who make their choices with ease know that limited information is never a problem. Choosing is simple because they know:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;they can pivot &lt;/li&gt;
&lt;li&gt;they can learn&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The worst mistake would be to lose the momentum not to pick the wrong thing.&lt;/p&gt;

&lt;p&gt;The whole process is simple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set a deadline -&amp;gt; recognize yourself -&amp;gt; look for options -&amp;gt; choose&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The last two steps are just a natural consequence of the first two steps. Choosing is the effect of a setting deadline, looking for options is the effect of knowing yourself and having to choose. And that is all you need. Once the choice is made there is no looking back. If you find a better opportunity in the future go through the process again.&lt;/p&gt;

&lt;p&gt;Thanks for reading and I hope you find it helpful.&lt;/p&gt;

&lt;p&gt;If you want to continue learning about choices I will recommend to you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/-/es/Annie-Duke/dp/0735216355"&gt;A practical approach to making choices by former poker professional Annie Duke&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ted.com/talks/barry_schwartz_the_paradox_of_choice?language=en"&gt;A fantastic TED talk by psychologist Ben Schwartz about the paradox of choice&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mindingourway.com/deliberate-once/"&gt;A great article about deliberation by Nate Soares, MIRI executive director&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>choice</category>
      <category>motivation</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Autenticación de APIs: qué es y porqué importa</title>
      <dc:creator>ledacoding</dc:creator>
      <pubDate>Mon, 13 Jun 2022 04:23:39 +0000</pubDate>
      <link>https://dev.to/ledacoding/autenticacion-de-apis-que-es-y-porque-importa-1i7a</link>
      <guid>https://dev.to/ledacoding/autenticacion-de-apis-que-es-y-porque-importa-1i7a</guid>
      <description>&lt;p&gt;¿Qué pasa cuando un servidor permite acceso a sus datos indiscriminadamente?&lt;/p&gt;

&lt;p&gt;Lo mismo que pasa si le prestamos dinero a otras personas indiscriminadamente. Siempre estará ese pequeño grupo de personas que se aproveche.&lt;/p&gt;

&lt;p&gt;Lo que te voy a contar es como se establece la confianza en la web. Como los actores se identifican ante otros para acceder al contenido que solicitan. Voy a mostrarte como la autenticación en la web ha evolucionado, haciendo la comunicación entre páginas cada vez más automatizada y más segura.&lt;/p&gt;

&lt;p&gt;Empecemos con un breve repaso.&lt;/p&gt;

&lt;p&gt;Primero vamos a recordar que en todo proceso de autenticación hay tres actores: usuario, cliente y servidor. El usuario es la persona de carne y hueso que quiere conectar dos equipos, el cliente es el equipo que solicita la información y el servidor es el equipo que comparte la información.&lt;/p&gt;

&lt;p&gt;Los servidores comparten información en la web a partir de APIs &lt;a href="https://dev.to/ledacoding/entiende-que-es-una-api-en-un-minuto-41nd"&gt;puedes ver mi post anterior sobre el tema&lt;/a&gt;. Esto sigue un ciclo de &lt;em&gt;request&lt;/em&gt; &lt;em&gt;response&lt;/em&gt;, donde el cliente y servidor siguen un protocolo donde uno solicita y otro responde.&lt;/p&gt;

&lt;p&gt;Para que el servidor confíe se han usado varios mecanismos:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic Auth&lt;/li&gt;
&lt;li&gt;API Key&lt;/li&gt;
&lt;li&gt;O Auth &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;El primer mecanismo es lo más sencillo que nos podemos imaginar. Basic Auth, es una forma corta de decir &lt;em&gt;basic authorization&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Es algo así:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--28rQJG5p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47i438tl8h05w2iey8fw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--28rQJG5p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47i438tl8h05w2iey8fw.png" alt="Modelo de Basic Auth para aplicaciones de Rust [Acceder a fuente](https://github.com/EstebanBorai/http-auth-basic)" width="650" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Esto sigue un sistema muy familiar: la combinación &lt;em&gt;user:password&lt;/em&gt;. De manera análoga a como nosotros nos identificamos en una página web lo hace Basic Auth. En su caso usa la combinación &lt;em&gt;user:password&lt;/em&gt; del usuario y lo pasa por un proceso de encriptación. Luego lo pone en los Headers como parte la HTTP Request bajo el nombre "Authorization".&lt;/p&gt;

&lt;p&gt;Se podría ver así:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Authorization: Basic tZNlpmtwXYNzd29sTAe=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;El servidor tiene una lista &lt;em&gt;user:password&lt;/em&gt; de sus usuarios y si ve esos credenciales están en su lista le dejará pasar. Básicamente usa la misma información para acceder a la cuenta del dueño y para acceder a los APIs. Esto le de un acceso amplio a los datos del servidor. Aquí el cliente no es solo un visitante, es alguien de la casa.&lt;/p&gt;

&lt;p&gt;¿Que pasa entonces si queremos restringir más el acceso?&lt;/p&gt;

&lt;p&gt;Introducimos API Keys. Con API Keys el dueño de la cuenta da acceso al cliente compartiendo una llave secreta, no su usuario.  Como las llaves de un hotel, el invitado solo ingresa al cuarto que le corresponde. A diferencia de Basic Auth, el protocolo para usar API Keys no está estandarizado. En algunos casos el cliente escribe esta llave en la sección de Headers de la HTTP request y en otros casos lo hará en la URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P2a9h-JS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vo2ow2tx9zuisk5xocu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P2a9h-JS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vo2ow2tx9zuisk5xocu.png" alt="Diagrama de _request_ con API Keys [Acceder a fuente](https://blog.restcase.com/4-most-used-rest-api-authentication-methods/)" width="880" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tanto este método como el anterior tienen un problema: la experiencia de usuario no es la mejor. Parte de la configuración de cliente y servidor debe hacerse manualmente y hay una posibilidad alta de cometer errores. &lt;/p&gt;

&lt;p&gt;O Auth mejora todo esto. Con este sistema la experiencia de usuario se ve como un simple &lt;em&gt;logueo&lt;/em&gt; pero de fondo cliente y servidor están trabajando para automatizar el intercambio de llaves.&lt;/p&gt;

&lt;p&gt;El proceso que O Auth suele seguir en la web es:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;El usuario le dice al cliente que se conecte con un servidor.&lt;/li&gt;
&lt;li&gt;El cliente dirije el usuario al servidor compartiendo una URL de partido (&lt;em&gt;callback&lt;/em&gt; URL)&lt;/li&gt;
&lt;li&gt;El usuario se &lt;em&gt;loguea&lt;/em&gt; y le da acceso al cliente&lt;/li&gt;
&lt;li&gt;El servidor envía de vuelta al usuario a la URL previa compartiendo un código de autorización en el fondo&lt;/li&gt;
&lt;li&gt;El cliente hace una nueva petición con el código de autorización y la llave secreta del cliente. El servidor responde con un token de acceso&lt;/li&gt;
&lt;li&gt;El cliente utiliza el token de acceso para acceder al contenido del servidor&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Visto gráficamente sería algo así (numeración varía):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--24wQPCJk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du63i5rhigs68gjs5duv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--24wQPCJk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/du63i5rhigs68gjs5duv.png" alt="Modelo de O Auth 2 [Acceder a fuente](https://goteleport.com/blog/how-oauth-authentication-works/)" width="850" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Este proceso aunque aparentemente más largo, permite una experiencia de usuario realmente sencilla. Vemos que solo en un paso el usuario tiene que tomar acción directa, lo demás está totalmente automatizado, a la vez que hace el proceso más seguro. O Auth tiene 2 versiones: O Auth 1 y O Auth 2. Se espera que encontremos más APIs con Auth 2 por ser última versión, y la que se considera más cómoda y segura. &lt;/p&gt;

&lt;p&gt;Hemos visto brevemente como la web ha evolucionado para ser más segura y predecible, y que con un simple &lt;em&gt;logueo&lt;/em&gt; hay un gran proceso detrás de autenticación en muchas de las páginas que usamos. Esto nos dará más claridad a la hora de utilizar los diferentes modelos de autenticación y también saber que está pasando cuando accedemos a páginas como usuarios.&lt;/p&gt;

&lt;p&gt;Espero este texto haya sido útil. Para finalizar comparto un apartado con los conceptos clave.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conceptos clave&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Autenticación: proceso por el cual un cliente prueba su identidad ante un servidor&lt;/li&gt;
&lt;li&gt;Basic Auth: sistema de autenticación que utiliza la encriptación de un usuario y una contraseña como credenciales&lt;/li&gt;
&lt;li&gt;API Keys: preceso de autenticación que utiliza llaves secretas como credenciales&lt;/li&gt;
&lt;li&gt;O Auth: sistema de autenticación que automatiza el intercambio de llaves secretas entre usuario y servidor.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>spanish</category>
      <category>api</category>
    </item>
    <item>
      <title>Entiende qué es una API en un minuto</title>
      <dc:creator>ledacoding</dc:creator>
      <pubDate>Mon, 06 Jun 2022 00:22:03 +0000</pubDate>
      <link>https://dev.to/ledacoding/entiende-que-es-una-api-en-un-minuto-41nd</link>
      <guid>https://dev.to/ledacoding/entiende-que-es-una-api-en-un-minuto-41nd</guid>
      <description>&lt;p&gt;¿Recuerdas cuando le pedías apuntes a tu amiga antes del examen?&lt;/p&gt;

&lt;p&gt;Algo así es una API.&lt;/p&gt;

&lt;p&gt;Me explico.&lt;/p&gt;

&lt;p&gt;Una API es fundamentalmente un mecanismo de comunicación. Dos programas que están corriendo en diferentes equipos necesitan intercambiar información. Mediante un protocolo uno le solicita al otro por algo y el segundo responde su solicitud.&lt;/p&gt;

&lt;p&gt;Muchas páginas tienen APIs corriendo en su software que están libres para que otros equipos lo consuman.&lt;/p&gt;

&lt;p&gt;Por ejemplo: aquí tenemos el API de Spotify.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IBmZhH7V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7a87tww587ytq8oqolf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IBmZhH7V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7a87tww587ytq8oqolf.png" alt="API de Spotify" width="706" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En este caso Spotify nos está diciendo que podemos acceder a información de su sistema como la letra de las canciones y su posición en la plataforma. Si logramos conectar nuestro software con el suyo, accederemos a millones de datos que ellos comparten.&lt;/p&gt;

&lt;p&gt;Para hacerlo no tenemos que darle a ningún botón de descarga. De nuevo, la conexión que tendremos será directa entre su software y el nuestro, descargar archivos requeriría trabajar localmente y probablemente nos lleve más tiempo.&lt;/p&gt;

&lt;p&gt;Entonces ¿Cómo lo hacemos?&lt;/p&gt;

&lt;p&gt;Simplemente seguiremos un protocolo.&lt;/p&gt;

&lt;p&gt;Un protocolo es una manera acordada de hacer las cosas. El protocolo da la receta para establecer la comunicación y si la seguimos adecuadamente accederemos a lo que queremos.&lt;/p&gt;

&lt;p&gt;Spotify tiene su API para consumo a través de la web. El protocolo en que se basa una API en la web es HTTP, la cual establece comunicación entre un cliente y un servidor. El cliente hace una petición al servidor y el servidor da una respuesta.&lt;/p&gt;

&lt;p&gt;Lo que requiere la petición son 4 cosas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL: una dirección a la que acceder&lt;/li&gt;
&lt;li&gt;Method: una instrucción de como manejar la solicitud&lt;/li&gt;
&lt;li&gt;Headers: metadatos de la petición&lt;/li&gt;
&lt;li&gt;Body: el contenido de la petición&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;La respuesta requiere de 3 cosas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code status: Un código informando el resultado de la solicitud&lt;/li&gt;
&lt;li&gt;Headers: información adicional sobre la petición&lt;/li&gt;
&lt;li&gt;Body: el contenido de la petición&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notemos que la petición y la respuesta tienen una estructura muy similar; la dirección y el método son solo necesarias para la petición y el código de estado solo necesario para la respuesta.&lt;/p&gt;

&lt;p&gt;Lo bueno del protocolo HTTP es que puede ser usado con diferentes lenguajes. Así que a pesar de que la sintaxis varíe, podemos acceder al contenido con el mismo proceso.&lt;/p&gt;

&lt;p&gt;Aquí tenemos algunos ejemplos de como manejar la petición.&lt;/p&gt;

&lt;p&gt;Con JavaScript:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--69vElFtb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr6yjx8fc2acpz1tb4cr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--69vElFtb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr6yjx8fc2acpz1tb4cr.png" alt="Petición con JavaScript" width="630" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Con Phyton:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bFdDTS6M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t25u6robu59e7f24rg9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bFdDTS6M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t25u6robu59e7f24rg9i.png" alt="Petición con Python" width="633" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Con Kotlin:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pOK05-cL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v7dc03occ6uhu0upw1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pOK05-cL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8v7dc03occ6uhu0upw1x.png" alt="Petición con Kotlin" width="622" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En todas estas peticiones tenemos la URL en donde está el recurso:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://spotify23.p.rapidapi.com/search/?q=%3CREQUIRED%3E&amp;amp;type=multi&amp;amp;offset=0&amp;amp;limit=10&amp;amp;numberOfTopResults=5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;El &lt;em&gt;method&lt;/em&gt; para saber que hacer con la petición:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;En este caso GET indica que queremos recibir información.&lt;/p&gt;

&lt;p&gt;Los &lt;em&gt;headers&lt;/em&gt; que nos cuentan información relevante.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'X-RapidAPI-Host': 'spotify23.p.rapidapi.com'
'X-RapidAPI-Key': 'SIGN-UP-FOR-KEY'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vemos que necesitamos registrarnos para obtener una llave.&lt;/p&gt;

&lt;p&gt;Y no tenemos &lt;em&gt;body&lt;/em&gt;. Como queremos recibir y no compartir, no hay ningún contenido asociado.&lt;/p&gt;

&lt;p&gt;Tan pronto hagamos esa solicitud el servidor procesará la solicitud y nos dará una respuesta. Ahí vemos la respuesta que nos da una solicitud con JavaScript.&lt;/p&gt;

&lt;p&gt;Body:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M64dC5PD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf90pir8zkiplyyjxhtm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M64dC5PD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kf90pir8zkiplyyjxhtm.png" alt="Body de solicitud" width="295" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Headers:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qO44Yszf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ba4xa541p1o1s0kipi7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qO44Yszf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ba4xa541p1o1s0kipi7.png" alt="Headers de solicitud" width="479" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En el caso de las solicitudes a un API, no siempre obtendremos un código de estado, en este caso obtenemos una respuesta "success". Suficiente para saber que obtuvimos una respuesta satisfactoria a nuestra petición.&lt;/p&gt;

&lt;p&gt;Voy a hacer una petición en JavaScript para buscar los albumes que Spotify tiene disponibles de The Beatles.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vhrUq65l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svrqsu7jp1s1km1eltln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vhrUq65l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/svrqsu7jp1s1km1eltln.png" alt='Búsqueda de álbumes de "beatles"' width="620" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;La búsqueda la especifico en mi URL, indicando la palabra de búsqueda "?q=beatles", comentando que deseo los albumes "type=albums" y que limite la busqueda a 10 caracteres "limit=10". &lt;/p&gt;

&lt;p&gt;Utilizo como &lt;em&gt;method&lt;/em&gt; GET y me aseguro que los &lt;em&gt;headers&lt;/em&gt; tengan la clave que me solicitan. Como no voy a enviar contenido mi &lt;em&gt;body&lt;/em&gt; está vacío.&lt;/p&gt;

&lt;p&gt;Perfecto. Ahora enviamos y esperamos la respuesta.&lt;/p&gt;

&lt;p&gt;El servidor me respondió. Me comunica que hay 1000 resultados para la busqueda y me comparte los 10 items que le pedí.&lt;/p&gt;

&lt;p&gt;Body:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qc8VWpwy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfdjl3gyvfcnebwov315.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qc8VWpwy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfdjl3gyvfcnebwov315.png" alt='Body de respuesta a búsqueda de álbumes de "beatles"' width="445" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Veamos que hay en los items:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qC0fWPeR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs74zpiyzzfpgr4d2ubo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qC0fWPeR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs74zpiyzzfpgr4d2ubo.png" alt="Respuesta de 10 items de álbumes" width="432" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;El contenido del primer item es:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8s4PEdJL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpm0b6tc22fmfbbwbxxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8s4PEdJL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpm0b6tc22fmfbbwbxxi.png" alt="Contenido del primer item" width="560" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lo tenemos. El primer resultado es "Beatles For Sale (Remastered)".&lt;/p&gt;

&lt;p&gt;También nos comparte unos datos sobre la respuesta.&lt;/p&gt;

&lt;p&gt;Headers:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--upKTZUGz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhbca0f4sdpyz9d56ruj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--upKTZUGz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhbca0f4sdpyz9d56ruj.png" alt="Headers de respuesta a solicitud de álbumes" width="484" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Así de sencillo. Ahora ya entiendes que es una API.&lt;/p&gt;

&lt;p&gt;Recapitulando: Las API son un mecanismo de comunicación entre dos &lt;em&gt;softwares&lt;/em&gt;, que permiten que un cliente haga una petición a un servidor. Este proceso sigue un protocolo, que para APIs web es HTTP. El protocolo establece que habrá una petición y una respuesta. La petición necesita URL, &lt;em&gt;method&lt;/em&gt;, &lt;em&gt;headers&lt;/em&gt;, &lt;em&gt;body&lt;/em&gt;. La respuesta tiene &lt;em&gt;status code&lt;/em&gt;, &lt;em&gt;headers&lt;/em&gt; y &lt;em&gt;body&lt;/em&gt;. Si hacemos la petición adecuadamente obtendremos exactamente lo que necesitamos.&lt;/p&gt;

&lt;p&gt;Con esto millones de datos están a nuestro alcance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notas adicionales:&lt;/strong&gt;&lt;br&gt;
Este ejercicio utilizó el API de Spotify a través de RapidAPI. Esta página es muy intuitiva y muestra ejemplos de petición y respuesta. Puedes probarla directamente aqui: &lt;a href="https://rapidapi.com/Glavier/api/spotify23/"&gt;Rapid API&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>spanish</category>
    </item>
  </channel>
</rss>
