Sample Photos – Free Fake REST API for Practice

Updated: March 18, 2023 By: Khue Post a comment

This free mock REST API gives you more than one hundred sample photos for testing, learning, prototyping, and practice (no matter which programming languages or technologies you’re using).

Get a List of Photos

In order to obtain a list of photos, you can send a GET request to the following API endpoint:

https://api.slingacademy.com/v1/sample-data/photos

There are 2 optional parameters that can be used for pagination:

  • offset: Determines whether to start returning data. The default value is 0
  • limit: This limits the number of results (for better performance and speed). The default value is 10

For example, you can send a GET request to the following API endpoint to get 20 photos (starting from the 6th):

https://api.slingacademy.com/v1/sample-data/photos?offset=5&limit=20

The response is in JSON format.

Data Structure

Each photo record comes with the fields below:

  • id: The id of the photo
  • url: The URL of the photo
  • title: The title of the photo (just some meaningless text)
  • description: The description of the photo (a long meaningless sentence)
  • user: The id of the user who owns the photo

Get a Single Photo by ID

There’s one more thing I almost forgot to say. You can get a single photo by id with the API endpoint below:

https://api.slingacademy.com/v1/sample-data/photos/[photo id]

For example:

// JavaScript
const fetchData = async (url) => {
    const response = await fetch(url)
    const data = await response.json()
    console.log(data);
}

const URL = 'https://api.slingacademy.com/v1/sample-data/photos/1'
fetchData(URL)

The output would be:

{
  "success": true,
  "message": "Photo fetched successfully",
  "photo": {
    "title": "Defense the travel audience hand",
    "user": 28,
    "id": 1,
    "description": "Leader structure safe or black late wife newspaper her pick central forget single likely.",
    "url": "https://api.slingacademy.com/public/sample-photos/1.jpeg"
  }
}

Here’s the photo with the id of 1:

Get the User Associated with a Photo

You can access information about the user by sending a GET request to the following API endpoint:

https://api.slingacademy.com/v1/sample-data/users/[user id]

More details about sample users can be found here: Sample Users – Free Fake API for Practicing & Prototyping.

Hope that our free sample photos can somehow help you. f you see something that needs improvement, leave a comment. Goodbye!