How it works
JSON data source
Create and edit the JSON data source of your API responses with TMPAPI's online editor. Data can be automatically generated by convenient annotations and placeholders.
{
"posts": [
"@repeat(3)",
{
"id": "%index%",
"title": "%randomtext%",
"content": "%text%",
"love": "%randomint%",
"image": "https://picsum.photos/50"
}
]
}
API call
Call your API using REST or GraphQL interface. The following code is an example of retrieving data from API in JavaScript using GraphQL.
const gqlQuery = `
{
posts {
id
title
content
love
image
}
}
`;
const response = await fetch(
'https://api.tmpapi.dev/graphql',
{
method: 'POST',
mode: 'cors',
headers: {
'X-Data-Name': 'lorem-4c9d87e6',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: gqlQuery
})
}
);
const data = await response.json();
// ...
Advance front-end development
Use the dummy data retrieved from your mock API for front-end development until the actual back-end is ready. So this is the TeMPorary API.