The RandomNumber API generates a random integer between the specified start
and end
values.
POST /api/random-number
The request body must be a JSON object containing the following properties:
start
(required): The start of the range. Must be an integer.end
(required): The end of the range. Must be an integer.
Example request body:
{
"start": 1,
"end": 10
}
The API responds with a JSON object containing a single property: randomNumber
, which is a random integer between the specified start
and end
values (inclusive).
Example response:
{
"randomNumber": 6
}
If the request body is missing or invalid, the API will respond with a 400 Bad Request
status code and an error message in the response body.
If the start
or end
values are not integers, the API will respond with a 400 Bad Request
status code and an error message in the response body.
If the start
value is greater than the end
value, the API will respond with a 400 Bad Request
status code and an error message in the response body.
Request:
POST /api/random-number
{
"start": 1,
"end": 10
}
Response:
{
"randomNumber": 6
}
Request:
POST /api/random-number
{
"start": -50,
"end": 50
}
Response:
{
"randomNumber": -10
}
The Generate Person API generates a random person based on the input provided by the client. The API retrieves data from a third-party API and returns a subset of that data based on the requested properties.
POST /api/generate-person
The request body must be a JSON object containing an array of property names that the client wants to retrieve. The following properties are valid:
firstName
: The first name of the person.lastName
: The last name of the person.email
: The email address of the person.avatar
: The URL of the person's avatar image.age
: The age of the person.address
: The address of the person.
Example request body:
{
"properties": ["firstName", "lastName", "email", "avatar", "age"]
}
The API responds with a JSON object containing a subset of the data retrieved from the third-party API, based on the requested properties.
Example response:
{
"firstName": "John",
"lastName": "Doe",
"email": "johndoe@example.com",
"avatar": "<https://example.com/johndoe.jpg>",
"age": 35
}
If the request body is missing or invalid, the API will respond with a 400 Bad Request
status code and an error message in the response body.
If the API encounters an error while retrieving data from the third-party API, it will respond with a 500 Internal Server Error
status code and an error message in the response body.
Request:
POST /api/generate-person
{
"properties": ["firstName", "lastName", "email", "avatar", "age"]
}
Response:
{
"firstName": "John",
"lastName": "Doe",
"email": "johndoe@example.com",
"avatar": "<https://example.com/johndoe.jpg>",
"age": 35
}
Request:
POST /api/generate-person
{
"properties": ["firstName", "email", "address"]
}
Response:
{
"firstName": "Jane",
"email": "janedoe@example.com",
"address": "123 Main St, Anytown USA"
}