REST API

Web API

ViaCEP API

https://viacep.com.br/ws/58015430/json/:

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

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

curl:

$ curl https://viacep.com.br/ws/58015430/json/
$ curl https://viacep.com.br/ws/58015430/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 todos os repositórios privados
GET/repos/luizchaves/ls200Retorna o repositório com nome luizchaves/ls
PATCH/repos/luizchaves/ls200Atualiza o repositório com nome luizchaves/ls
DELETE/repos/luizchaves/ls204Exclui o repositório com nome luizchaves/ls

HTTP Status Codes

Exemplos de Códigos

CódigoNomeSignificado
200OkSolicitação gerada com sucesso
201CreatedSolicitação gerada com sucesso e um novo recurso foi criado como resultado
204No ContentSolicitação gerada com sucesso e não há conteúdo para ser enviado
400Bad RequestSolicitação não compreendida por motivos de erro
401UnauthorizedSolicitação foi bloqueada porque não possui 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.

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
}
$ TOKEN=abc
$ curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/user/repos \
  -d '{"name":"github-repo-api","description":"This is your first repo!","homepage":"https://github.com","private":false,"is_template":true}'
$ TOKEN=abc
$ curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/user/repos \
  -d '{"name":"github-repo-api","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
$ TOKEN=abc
$ curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/users/luizchaves/repos
$ TOKEN=abc
$ curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/users/luizchaves/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
$ TOKEN=abc
$ curl -L \
   -H "Accept: application/vnd.github+json" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
   https://api.github.com/repos/luizchaves/github-repo-api
$ TOKEN=abc
$ curl -L \
   -H "Accept: application/vnd.github+json" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
   https://api.github.com/repos/luizchaves/github-repo-api

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
}
$ TOKEN=abc
$ curl -L \
   -X PATCH \
   -H "Accept: application/vnd.github+json" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
   https://api.github.com/repos/luizchaves/github-repo-api \
   -d '{"name":"github-repo-api","description":"This is your first repo!","homepage":"https://github.com","private":false,"is_template":false}'
$ TOKEN=abc
$ curl -L \
   -X PATCH \
   -H "Accept: application/vnd.github+json" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
   https://api.github.com/repos/luizchaves/github-repo-api \
   -d '{"name":"github-repo-api","description":"This is your first repo!","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
$ TOKEN=abc
$ curl -L \
   -X DELETE \
   -H "Accept: application/vnd.github+json" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
   https://api.github.com/repos/luizchaves/github-repo-api
$ TOKEN=abc
$ curl -L \
   -X DELETE \
   -H "Accept: application/vnd.github+json" \
   -H "Authorization: Bearer ${TOKEN}" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
   https://api.github.com/repos/luizchaves/github-repo-api

Editar esta página