← Back to Course Home

API Playground

Practice making API requests before building your own backend

API Endpoints

Use these endpoints to practice making HTTP requests. The base URL is: https://aw.profbobby.com/api/

GET /search

Search programming resources. Returns JSON data.

Query Parameters:

Examples:

GET /api/search
GET /api/search?q=javascript
GET /api/search?category=tutorial
GET /api/search?tag=css
GET /messages

Get all messages from the message board.

Query Parameters:

GET /api/messages
GET /api/messages?limit=10
POST /messages

Create a new message on the message board.

Request Body (JSON):

{
    "username": "your_name",
    "message": "your_message"
}

Or Form Data:

username=your_name&message=your_message
DELETE /messages

Delete a message by ID.

DELETE /api/messages?id=123

Search Resources (GET)

Search our database of programming resources.

Click "Search Resources" to see results...

Post Message (POST)

Post a message to the class message board.

Fill out the form and click "Post Message"...

Live Message Board

Messages posted by you and your classmates:

Click "Refresh Messages" to load...

Code Examples

Using Fetch API (JavaScript)

// GET Request - Search for resources
fetch('/api/search?q=javascript')
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

// POST Request - Create a message
fetch('/api/messages', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        username: 'StudentName',
        message: 'Hello from JavaScript!'
    })
})
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

Using HTML Form (No JavaScript)

Note: HTML forms can only send GET and POST requests. The form below demonstrates a POST request to the message board.
<form action="/api/messages" method="POST">
    <label for="username">Username:</label>
    <input type="text" id="username" name="username" required>

    <label for="message">Message:</label>
    <textarea id="message" name="message" required></textarea>

    <button type="submit">Post Message</button>
</form>

Using async/await

// Modern async/await syntax
async function searchResources(query) {
    try {
        const response = await fetch(`/api/search?q=${query}`);
        const data = await response.json();

        if (data.success) {
            console.log(`Found ${data.count} results:`);
            data.results.forEach(item => {
                console.log(`- ${item.title}: ${item.url}`);
            });
        }
    } catch (error) {
        console.error('Failed to fetch:', error);
    }
}

// Call the function
searchResources('react');

Understanding HTTP Methods

GET Read data from the server. Like asking a question - "What resources match this search?"
POST Create new data on the server. Like filling out a form - "Here's a new message to store."
PUT Update existing data. Like editing - "Replace this item with new data."
DELETE Remove data from the server. Like erasing - "Delete this item."