NAV -image
bash javascript

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
}

Request      

GET api/badwords

Query Parameters

filters[how_bad_is_it]  string optional  
Filter by level of badness.

filters[created_at]  string optional  
Filter for when the word was created.

fields[]  string optional  
Fields to include in the response

page  string optional  
Page number to return.

pageSize  string optional  
Number of items to return in a page. Defaults to 10.

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"
}

Request      

POST api/badwords

Body Parameters

word  string  
The word.

how_bad_is_it  string optional  
One of: `unspeakable`, `horrible`, `very bad`, `bad`.

dad  boolean optional  

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"
}

Request      

GET api/badwords/{badword}

URL Parameters

badword  string  
The ID of the word.

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());

Request      

PUT api/badwords/{badword}

PATCH api/badwords/{badword}

URL Parameters

badword  string  
The bad word ID.

Body Parameters

how_bad_is_it  string optional  
One of: `unspeakable`, `horrible`, `very bad`, `bad`.

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>

Request      

DELETE api/badwords/{badword}

URL Parameters

badword  string  

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!! ๐Ÿ‘‹

Request      

GET api/healthcheck

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."
}

Request      

GET api/user

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!"
}

Request      

POST api/services/highlightBadWordsInText

Body Parameters

texts  string[] optional  
Texts to be highlighted.

things  object[] optional  
Things to be done.

things[].name  string  
Thing.

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."
]

Request      

POST api/services/censorTexts/{mode?}

URL Parameters

mode  string optional  
Censorship mode. `full` will replace the entire word with `=====`, `partial` will replace all characters but the first and last. Defaults to `partial`.

Body Parameters

texts  string[] optional  
Text to be censored.

items  object optional  
An it

items.inttt  integer optional  
Other it

things  object[] optional  
Things to be done.

things[].name  string  
Thing.

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.๐Ÿ˜ญ"
}

Request      

POST api/services/censorImage

Body Parameters

image  file  
The image containing text to be censored.

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
    }
}

Request      

GET api/services/getTopBadWords

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
    }
}

Request      

GET api/services/getBadWordStats

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.