Get mock API data
curl --request GET \
--url https://mock.mocklyapi.com/mock/{mockApiId}import requests
url = "https://mock.mocklyapi.com/mock/{mockApiId}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mock.mocklyapi.com/mock/{mockApiId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mock.mocklyapi.com/mock/{mockApiId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mock.mocklyapi.com/mock/{mockApiId}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mock.mocklyapi.com/mock/{mockApiId}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mock.mocklyapi.com/mock/{mockApiId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": 1,
"username": "alice_admin",
"email": "alice@example.com",
"status": "active",
"role": "admin",
"age": 32,
"createdAt": "2024-01-15",
"profile": {
"firstName": "Alice",
"lastName": "Johnson",
"address": {
"city": "New York",
"country": "USA",
"zipCode": "10001"
}
}
},
{
"id": 2,
"username": "bob_user",
"email": "bob@example.com",
"status": "active",
"role": "user",
"age": 28,
"createdAt": "2024-02-20",
"profile": {
"firstName": "Bob",
"lastName": "Smith",
"address": {
"city": "London",
"country": "UK",
"zipCode": "SW1A 1AA"
}
}
}
]
Mock Endpoint examples
Get Mock api endpoint
Retrieve mock data from a specific mock API endpoint. Supports filtering, ordering, and limiting results.
GET
/
mock
/
{mockApiId}
Get mock API data
curl --request GET \
--url https://mock.mocklyapi.com/mock/{mockApiId}import requests
url = "https://mock.mocklyapi.com/mock/{mockApiId}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mock.mocklyapi.com/mock/{mockApiId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mock.mocklyapi.com/mock/{mockApiId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mock.mocklyapi.com/mock/{mockApiId}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mock.mocklyapi.com/mock/{mockApiId}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mock.mocklyapi.com/mock/{mockApiId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"id": 1,
"username": "alice_admin",
"email": "alice@example.com",
"status": "active",
"role": "admin",
"age": 32,
"createdAt": "2024-01-15",
"profile": {
"firstName": "Alice",
"lastName": "Johnson",
"address": {
"city": "New York",
"country": "USA",
"zipCode": "10001"
}
}
},
{
"id": 2,
"username": "bob_user",
"email": "bob@example.com",
"status": "active",
"role": "user",
"age": 28,
"createdAt": "2024-02-20",
"profile": {
"firstName": "Bob",
"lastName": "Smith",
"address": {
"city": "London",
"country": "UK",
"zipCode": "SW1A 1AA"
}
}
}
]
Headers
Authentication token required for private endpoints. Can also be provided via query parameter.
Path Parameters
Unique identifier for the mock API
Query Parameters
Authentication token required for private endpoints. Can also be provided via header.
URL-encoded filter conditions to apply on the mock data. Supports operators: $eq, $eqi, $ne, $nei. Multiple conditions are combined with AND logic.
Field name to sort results by. Supports nested paths using dot notation (e.g., 'profile.firstName').
Sort direction for the order_by field
Available options:
asc, desc Maximum number of results to return. Must be 0 or greater.
Required range:
x >= 0Response
Successful response with mock data

