Introduction
The Censorship API gives you the power to censor anybody, anywhere. Keep them from using dirty words, like "family", and "love". Ugh๐คฎ.
This documentation aims to provide all the information you need to work with our API.
Base URL
http://localhost:8000
Authenticating requests
This API is authenticated by sending an Authorization
header with the value "Bearer {your-token}"
.
You can retrieve your token by visiting your dashboard and clicking Generate API token.
Bad words
APIs for performing basic CRUD operations on our collection of bad words.
This group of endpoints will help you realise your dream of using a bad word. Thank us later.๐
Fetch the list of bad words.
Example request:
curl -X GET \
-G "http://localhost:8000/api/badwords?filters[how_bad_is_it]=eaque&filters[created_at]=blanditiis&fields[]=corporis&page=1" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/badwords"
);
let params = {
"filters[how_bad_is_it]": "eaque",
"filters[created_at]": "blanditiis",
"fields[]": "corporis",
"page": "1",
};
Object.keys(params)
.forEach(key => url.searchParams.append(key, params[key]));
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"current_page": 1,
"data": [
{
"id": 1,
"word": "est",
"how_bad_is_it": "very bad",
"created_at": "2020-09-10T17:19:10.000000Z",
"updated_at": "2020-09-10T17:19:10.000000Z"
},
{
"id": 2,
"word": "molestiae",
"how_bad_is_it": "very bad",
"created_at": "2020-09-10T17:19:10.000000Z",
"updated_at": "2020-09-10T17:19:10.000000Z"
}
],
"first_page_url": "http:\/\/localhost\/api\/badwords?page=1",
"from": 1,
"last_page": 6,
"last_page_url": "http:\/\/localhost\/api\/badwords?page=6",
"links": [
{
"url": null,
"label": "Previous",
"active": false
},
{
"url": "http:\/\/localhost\/api\/badwords?page=1",
"label": 1,
"active": true
},
{
"url": "http:\/\/localhost\/api\/badwords?page=2",
"label": 2,
"active": false
},
{
"url": "http:\/\/localhost\/api\/badwords?page=3",
"label": 3,
"active": false
},
{
"url": "http:\/\/localhost\/api\/badwords?page=4",
"label": 4,
"active": false
},
{
"url": "http:\/\/localhost\/api\/badwords?page=5",
"label": 5,
"active": false
},
{
"url": "http:\/\/localhost\/api\/badwords?page=6",
"label": 6,
"active": false
},
{
"url": "http:\/\/localhost\/api\/badwords?page=2",
"label": "Next",
"active": false
}
],
"next_page_url": "http:\/\/localhost\/api\/badwords?page=2",
"path": "http:\/\/localhost\/api\/badwords",
"per_page": 2,
"prev_page_url": null,
"to": 2,
"total": 12
}
Received response:
Request failed with error:
Add a word to the list.
This endpoint allows you to add a word to the list. It's a really useful endpoint, and you should play around with it for a bit.
Example request:
curl -X POST \
"http://localhost:8000/api/badwords" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"word":"\"children\"","how_bad_is_it":"very bad","dad":false}'
const url = new URL(
"http://localhost:8000/api/badwords"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"word": "\"children\"",
"how_bad_is_it": "very bad",
"dad": false
}
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (201, Word added):
{
"id": "http:\/\/google.com?page=3"
}
Received response:
Request failed with error:
Fetch a specific bad word.
Example request:
curl -X GET \
-G "http://localhost:8000/api/badwords/1" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/badwords/1"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"id": 1,
"word": "est",
"how_bad_is_it": "very bad",
"created_at": "2020-09-10T17:19:10.000000Z",
"updated_at": "2020-09-10T17:19:10.000000Z"
}
Received response:
Request failed with error:
Update a bad word.
requires authentication
Example request:
curl -X PUT \
"http://localhost:8000/api/badwords/2" \
-H "Authorization: Bearer {YOUR_AUTH_KEY}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"how_bad_is_it":"very bad"}'
const url = new URL(
"http://localhost:8000/api/badwords/2"
);
let headers = {
"Authorization": "Bearer {YOUR_AUTH_KEY}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"how_bad_is_it": "very bad"
}
fetch(url, {
method: "PUT",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Received response:
Request failed with error:
Remove a bad word from the list.
Example request:
curl -X DELETE \
"http://localhost:8000/api/badwords/fugiat" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/badwords/fugiat"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "DELETE",
headers,
}).then(response => response.json());
Example response (204):
<Empty response>
Received response:
Request failed with error:
Endpoints
Health check
Check if the API is still alive.
PS. This is a Closure route. ๐
Example request:
curl -X GET \
-G "http://localhost:8000/api/healthcheck" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/healthcheck"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
Hi!! ๐
Received response:
Request failed with error:
api/user
Example request:
curl -X GET \
-G "http://localhost:8000/api/user" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/user"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (401):
{
"message": "Unauthenticated."
}
Received response:
Request failed with error:
Services
Services provided by this API.
Highlight bad words in texts.
This endpoint will highlight any bad words in the provided texts, surrounding them with <em></em>
HTML tags.
Example request:
curl -X POST \
"http://localhost:8000/api/services/highlightBadWordsInText" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
-d '{"texts":["He loves his family sooo much","But they don't fucking love him back."],"things":[{"name":"sapiente"},{"name":"sapiente"}]}'
const url = new URL(
"http://localhost:8000/api/services/highlightBadWordsInText"
);
let headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
};
let body = {
"texts": [
"He loves his family sooo much",
"But they don't fucking love him back."
],
"things": [
{
"name": "sapiente"
},
{
"name": "sapiente"
}
]
}
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (200):
{
"highlighted": "He <em>loves<\/em> his <em>family<\/em> sooo much!"
}
Received response:
Request failed with error:
Censor bad words in texts.
This endpoint will censor any bad words in a list of texts.
Example request:
curl -X POST \
"http://localhost:8000/api/services/censorTexts/ea" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"texts":"He loves his family sooo much","items":{"inttt":4},"things":[{"name":"nam"},{"name":"nam"}]}'
const url = new URL(
"http://localhost:8000/api/services/censorTexts/ea"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"texts": "He loves his family sooo much",
"items": {
"inttt": 4
},
"things": [
{
"name": "nam"
},
{
"name": "nam"
}
]
}
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());
Example response (200):
[
"He l===s his f====y sooo much",
"But they don't fucking l===e him back."
]
Received response:
Request failed with error:
Censor bad words in an image.
This endpoint will censor any bad words in the provided image and return the censored image. All bad words will be replaced by ======.
Example request:
curl -X POST \
"http://localhost:8000/api/services/censorImage" \
-H "Content-Type: multipart/form-data" \
-H "Accept: application/json" \
-F "image=@C:\Users\shalvah\Projects\Temp\TheCensorshipAPI\public\images\logo-scribe.png"
const url = new URL(
"http://localhost:8000/api/services/censorImage"
);
let headers = {
"Content-Type": "multipart/form-data",
"Accept": "application/json",
};
const body = new FormData();
body.append('image', document.querySelector('input[name="image"]').files[0]);
fetch(url, {
method: "POST",
headers,
body,
}).then(response => response.json());
Example response (200):
<Binary data> - The censored image
Example response (400, When the image's words are too powerful๐ข):
{
"message": "Operation failed",
"reason": "The words are too touching.๐ญ"
}
Received response:
Request failed with error:
Get the most frequently used bad words.
PS: This response was generated using the @apiResource
and @apiResourceModel
tag. ๐
Example request:
curl -X GET \
-G "http://localhost:8000/api/services/getTopBadWords" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/services/getTopBadWords"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"data": [
{
"word": "sed",
"how_bad_is_it": "very bad"
},
{
"word": "consequatur",
"how_bad_is_it": "horrible"
}
],
"links": {
"first": "\/?page=1",
"last": null,
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"path": "\/",
"per_page": "5",
"to": 2
}
}
Received response:
Request failed with error:
Get stats for a word's usage.
PS: This response was generated using the @transformer
tag. ๐
Example request:
curl -X GET \
-G "http://localhost:8000/api/services/getBadWordStats" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost:8000/api/services/getBadWordStats"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
Example response (200):
{
"data": {
"word": "earum",
"last_used": 1602167486,
"frequency": 1240354959
}
}
Received response:
Request failed with error:
Response
Response Fields
word
string
The word
last_used
integer
Timestamp the word was last used anywhere in the world.
frequency
integer
The number of times people have used this word.