API Introduction

Polite Fork Off As A Service (or PFOaaS) - https://pfoaas.desigeek.com/ is a modern REST API that solves the problem of one telling people to politely fork off. 😇

There are days when we all need such a service for various reasons, and I think it is a great way to release some pent-up frustration. 🖤 It is also a great way to get some laughs too. This is of course meant for hard code engineers, writing RPC free code 😜

Polite Fork Off As A Service
Polite Fork Off As A Service - API

API Usage

The API is simple to use; you make a GET request to the API endpoint and the relevant parameters. You can also use the API from the command line too. There are a few options to choose for the response format - plain text, JSON, XML, and HTTP. If you don’t select an option the default is HTML. The JSON response also supports a callback.

All the operations are idempotent, so you can make the same request multiple times and get the same response.

Here is a sample usage using the /row/:from operation which requires one parameter - the name of the person wishing this. 💀 The output shown below is in plain text.

curl -H 'Accept: text/plain' https://pfoaas.desigeek.com/row/Amit

PFOaaS API - sample usage
PFOaaS API - sample usage

The same operation in JSON format:

curl -H 'Accept: application/json' https://pfoaas.desigeek.com/row/Amit

PFOaaS API - JSON sample usage
PFOaaS API - JSON sample usage

Some of the other operations require more than one parameter such as the /shakespeare/:name/:from that can be invoked as follows:

curl -H 'Accept: text/plain' https://pfoaas.desigeek.com/shakespeare/Putin/Amit

PFOaaS - Shakespeare sample usage
PFOaaS API - Shakespeare sample usage

There is a notion of filters, which are output modifiers. These are added to the URL as a query parameter and can be chained together. For example, the same operation as above but with the i18n filter showing the output in Russia (Русский).

curl -H 'Accept: text/plain' https://pfoaas.desigeek.com/row/Amit?i18n=ru

PFOaaS - Shakespeare sample usage in Russian
Shakespeare sample usage output in Russian

The i18n is used to translate the output to another language via the ISO 639-1 language code, and supports the following languages:

LanguageISO 639-1
Englishen
Italian / Italianoit
Spanish / Españoles
French / Françaisfr
Dutch / Deutschde
Norwegian / Nederlandsnl
Swedish / Svenskasv
Portuguese / Portuguêspt
Russia / Русскийru
Japanese / 日本語ja
Chinese / 汉语zh
Korean / 한국어ko
Turkish / Türkçetr

API Details and Code

You can see all the API usage and examples at https://pfoaas.desigeek.com/ . I won’t go into the details here, but you can see the code on GitHub here .

You can see a simple theme in the code, and easy to follow along. This is a simple NodeJs app that is hosted on Azure. If you want to run it locally, you can clone the repo and run npm install, and then npm start. The app will be available at http://localhost:5000.

You can also run this as a docker container, and build the container yourself; the Dockerfile is included in the repo.

I would welcome any contributions and am open to adding more operations to the API. If you prefer to do this, adding a new PFOaaS operation is as follows:

  1. Fork the repo
  2. Branch into a feature branch (e.g. feature/operation-name)
    • See the operations in the /lib/operations folder for examples.
  3. Add specs using the spec/operations as examples. Note, the specs are needed for the operation to be added to the API.
  4. Push the changes to your fork and merge
  5. Submit a PR. 👍

I look forward to seeing your contributions and hope this helps you de-stress and get you to smile. 😄 💜