Create an API

Create an API with Barktler is very simple. This document will help you get to know about creating a simple API with Barktler.


Make sure the Barktler package is installed.

For install, run the following command under your project folder to install the required dependencies.

yarn add @barktler/core
# Or
npm install @barktler/core --save

First API

Let’s write a simple API with allow us to get the webpage of Google search result.

Google provides a simple URL for searching. For example, the URL of the search keyword hello will be:

The TypeScript code for the described API will look like this.

import { Barktler } from "@barktler/core";

class GoogleSearchAPI extends Barktler {

    public static create(): GoogleSearchAPI {

        return new GoogleSearchAPI();

    public async search(keyword: string): Promise<string> {

        const data: string = await this._requestForData({

            url: `${keyword}`,
            method: 'GET',
        return data;

And that’s it, your API is ready, and the various features of that class is ready to ship!


Timeout is supported by Barktler, see Timeout for more details.


API created by Barktler is multi-dimension configurable, see Runtime Config.


See Execute API for how to use your created API.