Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web APIs from Scratch

Web APIs from Scratch

Alefe Souza

August 04, 2018
Tweet

More Decks by Alefe Souza

Other Decks in Programming

Transcript

  1. @alefesouza @alefesouza <h2 itemprop="name">Alefe Souza</h2> @alefesouza <p itemprop="knows">JS, PHP, Java,

    C#</p> <p itemprop="sameAs">@alefesouza</p> <a itemprop="url">https://alefesouza.com</a> <h3 itemprop="jobTitle">Full Stack Developer</h3> <p itemprop="worksFor">iMasters</p> UTF-8 LF HTML [email protected]
  2. @alefesouza @alefesouza <h1>Web API</h1> <ul> <li>Comunicação do cliente com o

    servidor.</li> <li>Back-end unificado.</li> <li>Ferramentas que auxiliam no desenvolvimento.</li> <li>Uso em praticamente qualquer linguagem.</li> </ul> UTF-8 LF HTML [email protected]
  3. @alefesouza @alefesouza <h1>Como funciona</h1> Web Apps IoT Mobile Apps Desktop

    Apps Outros Web API Lógica de Negócios Banco de Dados UTF-8 LF HTML [email protected]
  4. @alefesouza @alefesouza <h1>Status Codes</h1> <table> <tr><td>200 - OK.</td> <td>401 -

    Unauthorized.</td></tr> <tr><td>201 - Created.</td> <td>403 - Forbidden.</td></tr> <tr><td>204 - No Content.</td> <td>404 - Not Found.</td></tr> <tr><td>301 - Redirected.</td> <td>409 - Conflict.</td></tr> <tr><td>500 - Internal Server Error.</td></tr> </table> UTF-8 LF HTML [email protected]
  5. @alefesouza @alefesouza <h1>Verbos HTTP</h1> UTF-8 LF HTML [email protected] GET POST

    PUT DELETE Retorna dados Adiciona dados Atualiza dados Remove dados E alguns outros...
  6. @alefesouza @alefesouza <h1>Endpoints</h1> UTF-8 LF HTML [email protected] Endpoint de usuários:

    http://exemplo.com/api/users GET /users - retorna todos os usuários GET /users/:id - retorna usuários cujo ID seja igual a :id POST /users - adiciona novo usuário PUT /users/:id - edita usuário cujo ID seja igual a :id DELETE /users/:id - remove o usuário cujo ID seja igual a :id
  7. @alefesouza @alefesouza UTF-8 LF HTML [email protected] POST http://exemplo.com/api/users Status Code:

    201 - CREATED GET http://exemplo.com/api/users Status Code: 200 - OK
  8. @alefesouza @alefesouza UTF-8 LF HTML [email protected] DELETE http://exemplo.com/api/users/2 Status Code:

    204 - No Content GET http://exemplo.com/api/users Status Code: 200 - OK