REST API

Arquitetura REST

HTTP Clients

HTTP Status Code

Os códigos de status HTTP são códigos numéricos retornados pelo servidor para indicar o resultado de uma solicitação HTTP. Eles são divididos em cinco categorias principais:

Exemplos de Códigos

CódigoNomeSignificado
200OkSolicitação gerada com sucesso
201CreatedSolicitação gerada com sucesso e novo recurso foi criado
204No ContentSolicitação gerada com sucesso e sem conteúdo para enviar
400Bad RequestSolicitação não compreendida por motivos de erro
401UnauthorizedSolicitação bloqueada sem credenciais de autenticação válidas
404Not FoundO servidor não pode encontrar o recurso solicitado
500Internal Server ErrorO servidor encontrou uma situação com a qual não sabe lidar

ViaCEP | REST API

Rotas

Código Fonte

MétodoCaminhoStatusResposta
GET/ws/{cep}/json/200Retorna os dados do CEP em JSON
GET/ws/{cep}/xml/200Retorna os dados do CEP em XML

Consultar CEP

ViaCEP - Consultar CEP::

@cep=58015430
 
GET https://viacep.com.br/ws/{{cep}}/json/
 
@cep=58015430
 
GET https://viacep.com.br/ws/{{cep}}/json/
 

Github | REST API

Rotas

Código Fonte (Requisição | Rest Client)

MétodoCaminhoStatusResposta
POST/user/repos201Cria um novo repositório
GET/users/luizchaves/repos200Retorna todos os repositórios
GET/users/luizchaves/repos?type=private200Retorna repositórios privados
GET/repos/luizchaves/pw2200Retorna o repositório luizchaves/pw2
PATCH/repos/luizchaves/pw2200Atualiza o repositório luizchaves/pw2
DELETE/repos/luizchaves/pw2204Exclui o repositório luizchaves/pw2

Create a repository

GitHub - REST API - Create a repository for the authenticated user

/codes/api/rest/.env.example
GITHUB_TOKEN=
/codes/api/rest/.env.example
GITHUB_TOKEN=
@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
POST {{host}}/user/repos
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
Content-Type: application/json
 
{
  "name": "{{repo}}",
  "description": "This is your first repo!",
  "homepage": "https://github.com",
  "private": false,
  "is_template": true
}
 
@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
POST {{host}}/user/repos
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
Content-Type: application/json
 
{
  "name": "{{repo}}",
  "description": "This is your first repo!",
  "homepage": "https://github.com",
  "private": false,
  "is_template": true
}
 

Read repositories

GitHub - REST API - List repositories for a user

@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
 
###
GET {{host}}/users/{{username}}/repos
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
 
@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
 
###
GET {{host}}/users/{{username}}/repos
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
 

Essa rota pode ser solicitada sem Token:

@host=https://api.github.com
@username=luizchaves
 
###
GET {{host}}/users/{{username}}/repos
 
@host=https://api.github.com
@username=luizchaves
 
###
GET {{host}}/users/{{username}}/repos
 

Read a repository (name)

GitHub - REST API - Get a repository

@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
 
GET {{host}}/repos/{{username}}/{{repo}}
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
 
@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
 
GET {{host}}/repos/{{username}}/{{repo}}
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
 

Update a repository

GitHub - REST API - Update a repository

@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
PATCH {{host}}/repos/{{username}}/{{repo}}
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
Content-Type: application/json
 
{
  "name": "{{repo}}",
  "description": "This is your first repository",
  "homepage": "https://github.com",
  "private": false,
  "is_template": false
}
 
@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
PATCH {{host}}/repos/{{username}}/{{repo}}
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
Content-Type: application/json
 
{
  "name": "{{repo}}",
  "description": "This is your first repository",
  "homepage": "https://github.com",
  "private": false,
  "is_template": false
}
 

Delete a repository

GitHub - REST API - Delete a repository

@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
DELETE {{host}}/repos/{{username}}/{{repo}}
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
 
@host=https://api.github.com
@token={{$dotenv GITHUB_TOKEN}}
@username=luizchaves
@repo=github-repo-api
 
###
DELETE {{host}}/repos/{{username}}/{{repo}}
Accept: application/vnd.github+json
Authorization: Bearer {{token}}
X-GitHub-Api-Version: 2022-11-28
 

Editar esta página