Fake API - An API to generate fake data

Here is an API for all the frontend developers. An API to generate fake data, lots of it. This tool comes in handy when you are developing a frontend for applications that requires data a lot of data.

Frontend frameworks like React, Vue, etc., are trendy, and many applications are built on these frameworks. Hot reloading is one of the features of such libraries. So when you press save, the whole app reloads, and all the APIs are called.

Making multiple API calls every few seconds is a costly task. Keeping the backend running the whole time to prototype the frontend is also an expensive process. This is where an API generating fake data comes into play.

API Base URL

How does the API work?

The API is built using FastAPI, and the fake data is generated using the Faker library. All the data types(the type of data generated) supported by the API are the ones in Faker.

Endpoints

  • [GET] /api/types

    This endpoint returns all the data types supported. Only these types should be provided as values to any key.

  • [POST] /api/

    This endpoint does all the heavy lifting. It generates fake data based on the JSON payload. Each key in the payload is an identifier, i.e., the key in the resulting fake data. The value to each key must be one of the valid data types. For an invalid type, the API ignores the entry.

For example,

{
    "name": "name"
}

Will generate something like,

{
    "name": "Amal Shaji"
}

What kind of payload can the API handle?

  • Simple Payloads

    simple.PNG

  • Complex payloads (nested JSON)

    complex1.PNG

  • Complex payloads (Maybe the person has multiple contact information)

    complex2.PNG

You can use the repeat key for repeating any block of data. Max repeat count is 10. Use the repeat key in the outer block to get data for n users.

The function to generate data based on the payload is recursive. So whenever the function encounters a dict, it calls itself, solving all the nested structures. interesting.PNG

Hmm. Interesting...

Navigate to fakeapi.tk/api/types to know about all the supported data types. Fire up your favorite API testing client and test it out with various data types.

Happy Hunting🥳🥳

Catalin's Tech's photo

Nice one. It's super useful when you want to test an app with data. :-)

Liyas Thomas's photo

Works awesome. Might come handy for my project - Hoppscotch

hoppscotch.io/?method=POST&url=https://..

Amal Shaji's photo

Hoppscotch is amazing.