Data APIs

Collection of mock data APIs for various use cases including user data, products, posts, and more.

User Data

Mock user profiles and authentication endpoints.

https://mockly.me/user/basic
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/user/basic"
fetch('https://mockly.me/user/basic')
    .then(response => response.json())
    .then(data => {
        console.log(data);
        // Example: display user name
        document.getElementById('username').textContent = data.name;
    });
import requests

    response = requests.get('https://mockly.me/user/basic')
    user_data = response.json()
    print(f"User: {user_data['name']}")
    print(f"Email: {user_data['email']}")
Result Preview:
{
    "name": "Alice Johnson",
    "email": "[email protected]",
    "avatar": "https://mockly.me/avatar"
}
https://mockly.me/users?count=5
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/users?count=10"
// Get a list of 10 users
    fetch('https://mockly.me/users?count=10')
    .then(response => response.json())
    .then(users => {
        // Generate user list in HTML
        const userList = document.getElementById('user-list');
        users.forEach(user => {
        const item = document.createElement('li');
        item.textContent = `${user.name} - ${user.job_title}`;
        userList.appendChild(item);
        });
    });
import requests

    response = requests.get('https://mockly.me/users?count=5')
    users = response.json()

    for user in users:
        print(f"Name: {user['name']}")
        print(f"Job: {user['job_title']}")
        print(f"Location: {user['location']}")
        print("---")
Result Preview:
[
    {
        "name": "John Smith",
        "email": "[email protected]",
        "avatar": "https://mockly.me/avatar/1234",
        "age": 32,
        "job_title": "Software Engineer",
        "location": "New York"
    },
    {
        "name": "Emma Davis",
        "email": "[email protected]",
        "avatar": "https://mockly.me/avatar/5678",
        "age": 28,
        "job_title": "Product Manager",
        "location": "London"
    },
    // more users...
    ]
Product Data

E-commerce product and cart endpoints.

https://mockly.me/product
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/product"
fetch('https://mockly.me/product')
    .then(response => response.json())
    .then(product => {
        // Display product details
        document.getElementById('product-name').textContent = product.name;
        document.getElementById('product-price').textContent = `$${product.price}`;
        document.getElementById('product-rating').textContent = `${product.rating}⭐`;
    });
Copy
import requests

    response = requests.get('https://mockly.me/product')
    product = response.json()

    print(f"Product: {product['name']}")
    print(f"Price: ${product['price']}")
    print(f"Category: {product['category']}")
    print(f"In stock: {'Yes' if product['in_stock'] else 'No'}")
Result Preview:
{
    "name": "Wireless Headphones",
    "price": 149.99,
    "description": "High-quality premium wireless headphones featuring advanced technology. Perfect for daily use, this product offers exceptional performance.",
    "category": "Electronics",
    "in_stock": true,
    "tags": ["new", "popular"],
    "rating": 4.7,
    "review_count": 1243,
    "images": [
        "https://mockly.me/image/placeholder/150/150",
        "https://mockly.me/image/placeholder/150/151"
    ]
}
https://mockly.me/products
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/products?limit=10&skip=0"
// Paginated product list
    fetch('https://mockly.me/products?limit=5&skip=0')
    .then(response => response.json())
    .then(data => {
        const products = data.products;
        const productGrid = document.getElementById('product-grid');
        
        products.forEach(product => {
        const card = document.createElement('div');
        card.className = 'product-card';
        card.innerHTML = `
            

${product.title}

$${product.price}

${product.rating}⭐ (${product.stock} in stock)

`; productGrid.appendChild(card); }); });
import requests

    response = requests.get('https://mockly.me/products?limit=5')
    data = response.json()

    print(f"Total products: {data['total']}")
    print("Products:")

    for product in data['products']:
        print(f"- {product['title']} (${product['price']})")
        print(f"  Brand: {product['brand']}, Category: {product['category']}")
Result Preview:
{
    "products": [
        {
        "id": 1,
        "title": "TechPro Smart Watch",
        "description": "High-quality premium smart watch featuring advanced technology.",
        "price": 249.99,
        "discountPercentage": 8.5,
        "rating": 4.8,
        "stock": 42,
        "brand": "TechPro",
        "category": "Wearables",
        "thumbnail": "https://mockly.me/product/thumbnail/1",
        "images": ["https://mockly.me/product/image/1/1", "https://mockly.me/product/image/1/2"],
        "tags": ["sale", "trending"]
        },
        // more products...
    ],
    "total": 100,
    "skip": 0,
    "limit": 5
    }
Content

Text content, posts, and comments endpoints.

https://mockly.me/posts
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/posts?limit=5&skip=0"
fetch('https://mockly.me/posts?limit=5')
    .then(response => response.json())
    .then(data => {
        const posts = data.posts;
        const postsContainer = document.getElementById('posts-container');
        
        posts.forEach(post => {
        const postElement = document.createElement('article');
        postElement.className = 'post';
        postElement.innerHTML = `
            

${post.title}

${post.tags.map(tag => `${tag}`).join('')}

${post.body.substring(0, 150)}...

👤 User: ${post.userId} ❤️ ${post.reactions} 📅 ${post.date}
`; postsContainer.appendChild(postElement); }); });
import requests

    response = requests.get('https://mockly.me/posts?limit=3')
    data = response.json()

    print(f"Total posts: {data['total']}")

    for post in data['posts']:
        print(f"\nTitle: {post['title']}")
        print(f"Tags: {', '.join(post['tags'])}")
        print(f"Date: {post['date']}")
        print(f"Reactions: {post['reactions']}")
        print("Preview: " + post['body'][:100] + "...")
Result Preview:
{
    "posts": [
        {
        "id": 1,
        "title": "How I improved my productivity this month",
        "body": "This is sentence 1 of this paragraph. This is sentence 2 of this paragraph...",
        "userId": 47,
        "tags": ["productivity", "technology", "learning"],
        "reactions": 123,
        "date": "2023-04-15"
        },
        {
        "id": 2,
        "title": "10 tips for better coding practices",
        "body": "This is sentence 1 of this paragraph. This is sentence 2 of this paragraph...",
        "userId": 28,
        "tags": ["programming", "webdev"],
        "reactions": 87,
        "date": "2023-05-22"
        }
        // more posts...
    ],
    "total": 150,
    "skip": 0,
    "limit": 5
    }
https://mockly.me/text
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/text?length=medium&type=business"
// Get placeholder text for a specific purpose
    fetch('https://mockly.me/text?length=short&type=technical')
    .then(response => response.json())
    .then(data => {
        // Insert the generated text into a placeholder
        document.getElementById('placeholder-text').textContent = data.text;
    });
import requests

    # Get lorem ipsum placeholder text
    response = requests.get('https://mockly.me/text?length=long&type=lorem')
    data = response.json()

    # Print the first 100 characters
    print(data['text'][:100] + "...")
Result Preview:
{
    "text": "The system architecture implements a microservices approach with containerized deployments for maximum scalability.\n\nOur RESTful API supports JSON and XML formats with OAuth2 authentication and rate limiting features.\n\nBackend services are written in Python and Node.js, with PostgreSQL and Redis for data persistence needs."
}
Utility Data

Date formats, status codes, and other utility endpoints.

https://mockly.me/dates
GET
cURL
JavaScript
Python
curl -X GET "https://mockly.me/dates?format=readable"
// Get dates in Unix timestamp format
    fetch('https://mockly.me/dates?format=unix')
    .then(response => response.json())
    .then(dates => {
        console.log('Current timestamp:', dates.current);
        console.log('Past timestamp:', dates.past);
        console.log('Future timestamp:', dates.future);
        
        // Convert Unix to JavaScript Date
        const futureDate = new Date(dates.future * 1000);
        console.log('Future date:', futureDate.toLocaleDateString());
    });
import requests
    from datetime import datetime

    # Get ISO-formatted dates
    response = requests.get('https://mockly.me/dates?format=iso')
    dates = response.json()

    print(f"Current: {dates['current']}")
    print(f"Past: {dates['past']}")
    print(f"Future: {dates['future']}")

    # Parse ISO date to datetime object
    future_date = datetime.fromisoformat(dates['future'].replace('Z', '+00:00'))
    print(f"Formatted future date: {future_date.strftime('%A, %B %d, %Y')}")
Result Preview:
{
    "current": "2023-07-22T15:48:23.416732",
    "past": "2022-10-14T15:48:23.416732",
    "future": "2024-03-18T15:48:23.416732"
}
https://mockly.me/status/{code}
GET
cURL
JavaScript
Python
curl -i -X GET "https://mockly.me/status/401"
// Test error handling with various status codes
    async function testErrorHandling() {
    try {
        const response = await fetch('https://mockly.me/status/500');
        
        if (!response.ok) {
        const errorData = await response.json();
        console.error(`Error ${response.status}: ${errorData.message}`);
        return;
        }
        
        const data = await response.json();
        console.log(data);
    } catch (error) {
        console.error('Network error:', error);
    }
    }
import requests

    # Test error handling
    def test_status_code(code):
        try:
            response = requests.get(f'https://mockly.me/status/{code}')
            response.raise_for_status()  # Raise exception for 4XX/5XX responses
            
            return response.json()
        except requests.exceptions.HTTPError as e:
            print(f"HTTP Error: {e}")
            print(f"Response: {e.response.json()}")
        except requests.exceptions.RequestException as e:
            print(f"Request failed: {e}")

    # Test with various status codes
    test_status_code(200)  # Success
    test_status_code(404)  # Not Found
    test_status_code(500)  # Server Error
Result Preview (404 response):
HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 78
WWW-Authenticate: Bearer

{
    "message": "Not Found - The server has not found anything matching the Request-URI"
}
AI-Powered

Meet Mockly Assistant

Your AI assistant for API testing, debugging and code generation. Access the power of mockly.me directly in ChatGPT.

  • Generate code examples in your preferred language
  • Get guidance for request/response handling and formatting
  • Supercharged by ChatGPT Plus from OpenAI

"How do I send data to a POST endpoint"

"I can show you how to structure your request with headers and JSON — here's a code example..."

Powered by AI