# Usage

# Generate any data you can think about

For any routes, the backend would return JSON data of anything you request. You can also do anything with your path, such as adding imaginary query strings or paths.

  • A basic list of forum users
Request
fetch('https://aiplaceholder.terrydjony.com/forum/users')
      .then(response => response.json())
      .then(json => console.log(json))
Response
{
    "users": [
        {
            "id": 1,
            "username": "johndoe",
            "name": "John Doe",
            "email": "johndoe@example.com",
            "avatar": "https://picsum.photos/200"
        },
        {
            "id": 2,
            "username": "janedoe",
            "name": "Jane Doe",
            "email": "janedoe@example.com",
            "avatar": "https://picsum.photos/200"
        },
        {
            "id": 3,
            "username": "bobsmith",
            "name": "Bob Smith",
            "email": "bobsmith@example.com",
            "avatar": "https://picsum.photos/200"
        }
    ]
}
  • Or, list of CRM sales deals with deal size more than 10K
Request
fetch('https://aiplaceholder.terrydjony.com/crm/deals?amount_greater_than=10000&limit=3&project=marketing')
      .then(response => response.json())
      .then(json => console.log(json))
Response
{
    "deals": [
        {
            "id": 1,
            "project": "marketing",
            "deal_owner": "Alice",
            "amount": 15000,
            "closed_date": "2020-07-01"
        },
        {
            "id": 2,
            "project": "marketing",
            "deal_owner": "Bob",
            "amount": 20000,
            "closed_date": "2020-06-28"
        },
        {
            "id": 3,
            "project": "marketing",
            "deal_owner": "Charlie",
            "amount": 12000,
            "closed_date": "2020-07-02"
        }
    ]
}
  • Or... a list of products from marketplace sorted by price
Request
fetch('https://aiplaceholder.terrydjony.com/products?marketplace=amazon&price_greater_than=20&views_greater_than=1000&sort_by=price&sort_order=desc')
      .then(response => response.json())
      .then(json => console.log(json))
Response
{
    "products": [
        {
            "id": 456,
            "name": "Wireless Earbuds",
            "description": "Listen to your music on the go with these high-quality wireless earbuds.",
            "price": 35.99,
            "views": 1500,
            "image": "https://picsum.photos/200"
        },
        {
            "id": 123,
            "name": "Smartwatch",
            "description": "Stay connected with this sleek and stylish smartwatch.",
            "price": 25.99,
            "views": 2000,
            "image": "https://picsum.photos/200"
        },
        {
            "id": 789,
            "name": "Bluetooth Speaker",
            "description": "Get the party started with this powerful Bluetooth speaker.",
            "price": 22.49,
            "views": 1200,
            "image": "https://picsum.photos/200"
        }
    ]
}

Any data you want to retrieve , you can get it!

# Generate data with rules specified

If you want to get some specific data, you can use this route
/fake/:content_type/:number_of_records?/:fields_separated_by_commas?

So, you can specify directly in your content:

  1. :content_type

Fill this content type that you want, it can be tweet, posts, instagram-posts, linkedin-posts or anything you can think of

  1. :number_of_records (optional)

Fill this if you want to set the number of records you want to retrieve. For example, fill 5 if you want to get 5 records.

  1. :fields_separated_by_commas (optional)

Fill this if you want to specify what fields each record object has.

Request
fetch('https://aiplaceholder.terrydjony.com/fake/tweets/3/id,datetime,username,full_name,tweet,num_likes')
      .then(response => response.json())
      .then(json => console.log(json))
Response
{
    "tweets": [
        {
            "id": 1,
            "datetime": "2020-07-01T10:30:00Z",
            "username": "johndoe",
            "full_name": "John Doe",
            "tweet": "Just had the best cup of coffee ever! ☕️",
            "num_likes": 10
        },
        {
            "id": 2,
            "datetime": "2020-07-02T15:45:00Z",
            "username": "johndoe",
            "full_name": "John Doe",
            "tweet": "Excited to be starting a new project today! 🚀",
            "num_likes": 12
        },
        {
            "id": 3,
            "datetime": "2020-07-03T20:00:00Z",
            "username": "johndoe",
            "full_name": "John Doe",
            "tweet": "Had a great workout at the gym today! Feeling pumped! 💪",
            "num_likes": 15
        }
    ]
}

You can also use imaginative query string as well

Request

fetch('https://aiplaceholder.terrydjony.com/fake/users/3/id,username,full_name?sort_by=username&sort_order=asc') .then(response => response.json()) .then(json => console.log(json))

Response
{
    "users": [
        {
            "id": 1,
            "username": "jdoe",
            "full_name": "John Doe"
        },
        {
            "id": 3,
            "username": "msmith",
            "full_name": "Mary Smith"
        },
        {
            "id": 2,
            "username": "rjohnson",
            "full_name": "Robert Johnson"
        }
    ]
}