Introdução
Esta documentação tem como objetivo fornecer todas as informações que você precisa para trabalhar com nossa API.
Autenticando solicitações
Esta API não está autenticada.
Posts
Listar todos os posts Este endpoint retorna uma lista de todos os posts não deletados.
requires authentication
Example request:
curl --request GET \
--get "https://api.sunstone.com.br/api/v1/posts" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"https://api.sunstone.com.br/api/v1/posts"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());Example response (200):
{
"id": 1,
"title": "Meu primeiro post",
"content": "Este é o conteúdo do post.",
"author_id": 1,
"created_at": "2023-08-30T19:20:02.000000Z",
"updated_at": "2023-08-30T19:20:02.000000Z"
}
Example response (404):
{
"error": "Nenhuma post foi encontrada."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Criar um novo post Este endpoint permite criar um novo post.
requires authentication
Example request:
curl --request GET \
--get "https://api.sunstone.com.br/api/v1/posts/create" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"title\": \"praesentium\",
\"content\": \"sint\",
\"author_id\": 17,
\"image\": \"fugit\"
}"
const url = new URL(
"https://api.sunstone.com.br/api/v1/posts/create"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"title": "praesentium",
"content": "sint",
"author_id": 17,
"image": "fugit"
};
fetch(url, {
method: "GET",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (201):
{
"message": "Post criado com sucesso.",
"data": {
"id": 1,
"title": "Meu novo post",
"content": "Este é o conteúdo do post.",
"author_id": 1,
"created_at": "2023-08-30T19:20:02.000000Z",
"updated_at": "2023-08-30T19:20:02.000000Z"
}
}
Example response (422):
{
"error": "Erro de validação",
"messages": {
"title": [
"O campo título é obrigatório."
],
"content": [
"O campo conteúdo é obrigatório."
]
}
}
Example response (500):
{
"error": "Erro no banco de dados."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Exibir um post Este endpoint retorna os detalhes de um post específico.
requires authentication
Example request:
curl --request GET \
--get "https://api.sunstone.com.br/api/v1/posts/11" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"https://api.sunstone.com.br/api/v1/posts/11"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());Example response (200):
{
"id": 1,
"title": "Meu primeiro post",
"content": "Este é o conteúdo do post.",
"author_id": 1,
"created_at": "2023-08-30T19:20:02.000000Z",
"updated_at": "2023-08-30T19:20:02.000000Z"
}
Example response (404):
{
"error": "Post não encontrado."
}
Example response (500):
{
"error": "Erro no banco de dados."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Atualizar um post Este endpoint permite atualizar um post existente.
requires authentication
Example request:
curl --request PUT \
"https://api.sunstone.com.br/api/v1/posts/14" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"title\": \"debitis\",
\"content\": \"molestias\",
\"author_id\": 17,
\"image\": \"sit\"
}"
const url = new URL(
"https://api.sunstone.com.br/api/v1/posts/14"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"title": "debitis",
"content": "molestias",
"author_id": 17,
"image": "sit"
};
fetch(url, {
method: "PUT",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (200):
{
"message": "Post atualizado com sucesso.",
"data": {
"id": 1,
"title": "Título atualizado",
"content": "Conteúdo atualizado",
"author_id": 1,
"created_at": "2023-08-30T19:20:02.000000Z",
"updated_at": "2023-08-30T19:40:02.000000Z"
}
}
Example response (404):
{
"error": "Post não encontrado."
}
Example response (422):
{
"error": "Erro de validação",
"messages": {
"title": [
"O campo título é obrigatório."
],
"content": [
"O campo conteúdo é obrigatório."
]
}
}
Example response (500):
{
"error": "Erro no banco de dados."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Excluir um post Este endpoint marca um post como excluído.
requires authentication
Example request:
curl --request DELETE \
"https://api.sunstone.com.br/api/v1/posts/9" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"https://api.sunstone.com.br/api/v1/posts/9"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "DELETE",
headers,
}).then(response => response.json());Example response (200):
{
"message": "Post excluído com sucesso."
}
Example response (404):
{
"error": "Post não encontrado."
}
Example response (500):
{
"error": "Erro no banco de dados."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Criar um novo post Este endpoint permite criar um novo post.
requires authentication
Example request:
curl --request POST \
"https://api.sunstone.com.br/api/v1/post/create" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"title\": \"non\",
\"content\": \"et\",
\"author_id\": 7,
\"image\": \"odio\"
}"
const url = new URL(
"https://api.sunstone.com.br/api/v1/post/create"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"title": "non",
"content": "et",
"author_id": 7,
"image": "odio"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (201):
{
"message": "Post criado com sucesso.",
"data": {
"id": 1,
"title": "Meu novo post",
"content": "Este é o conteúdo do post.",
"author_id": 1,
"created_at": "2023-08-30T19:20:02.000000Z",
"updated_at": "2023-08-30T19:20:02.000000Z"
}
}
Example response (422):
{
"error": "Erro de validação",
"messages": {
"title": [
"O campo título é obrigatório."
],
"content": [
"O campo conteúdo é obrigatório."
]
}
}
Example response (500):
{
"error": "Erro no banco de dados."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Exibir um post Este endpoint retorna os detalhes de um post específico.
requires authentication
Example request:
curl --request POST \
"https://api.sunstone.com.br/api/v1/post/1" \
--header "Authorization: Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"https://api.sunstone.com.br/api/v1/post/1"
);
const headers = {
"Authorization": "Bearer 1|LinnYgzxQm7zEQjdKg84GClWcTHfSrd0pGN9LLdWac9515e5",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "POST",
headers,
}).then(response => response.json());Example response (200):
{
"id": 1,
"title": "Meu primeiro post",
"content": "Este é o conteúdo do post.",
"author_id": 1,
"created_at": "2023-08-30T19:20:02.000000Z",
"updated_at": "2023-08-30T19:20:02.000000Z"
}
Example response (404):
{
"error": "Post não encontrado."
}
Example response (500):
{
"error": "Erro no banco de dados."
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.