Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Free Public APIs for Frontend Testing

Tech May 9 3

JSONPlaceholder

JSONPlaceholder offers a fully functional REST API for testing and prototyping. It supports standard HTTP methods along with filtering and pagination capabilities.

Fetching Post Collections

Retrieve a list of 100 posts. Each object contains identifiers, title, and body.

const fetchAllPosts = async () => {
  const res = await fetch('https://placeholder.typicode.com/posts');
  return res.();
};

Retrieving a Specific Post

Fetch a single post by appending its identifier to the endpoint.

const targetPostId = 2;
const postRes = await fetch(`https://placeholder.typicode.com/posts/${targetPostId}`);
const postData = await postRes.();

Creating a Post

Submit a POST request to generate a new post. A successful response returns the newly created resource identifier.

const createNewPost = async () => {
  const response = await fetch('https://placeholder.typicode.com/posts', {
    method: 'POST',
    headers: { 'Content-Type': 'application/' },
    body: JSON.stringify({
      authorId: 11,
      postTitle: 'API Testing',
      postBody: 'Content goes here'
    })
  });
  return response.();
};

Available Resources

  • Posts: /posts, /posts/{id}, /posts?userId={userId}, /posts/{id}/comments
  • Comments: /comments, /comments?postId={postId}
  • Albums: /albums, /albums/{id}, /albums?userId={userId}
  • Todos: /todos, /todos/{id}, /todos?userId={userId}
  • Users: /users, /users/{id}
  • Photos: /photos, /photos/{id}

The Cat API

This service provides feline images and supports operations like breed filtering, category search, pagination, and image analysis.

Retrieving Random Cat Images

Fetch a random cat image. The limit parameter controls the number of returned results.

const fetchLimit = 1;
const catUrl = `https://api.thecatapi.com/v1/images/search?limit=${fetchLimit}`;
const catData = await (await fetch(catUrl)).();

Dog API

A straightforward API for fetching random canine images.

Fetching a Random Dog Image

const dogImgEndpoint = 'https://dog.ceo/api/breeds/image/random';
const dogResult = await (await fetch(dogImgEndpoint)).();

Lorem Picsum

Generates placeholder images with customizable dimensions. The response is a direct image resource, making it suitable for use within the src attribute of an <img> tag.

Specifying Image Dimensions

To retrieve a square image, provide a single dimension value (e.g., 200x200 pixels).

<img src="https://picsum.photos/200" alt="Square Placeholder" />

For rectangular dimensions, supply both width and height.

<img src="https://picsum.photos/200/300" alt="Rectangular Placeholder" />

Miscellaneous Public APIs

Video Platform Episode Listing (IQiyi)

Fetches episode lists for a given series identifier and page number.

const seriesId = 202861101;
const pageNum = 1;
const episodeApi = `https://cache.video.iqiyi.com/jp/avlist/${seriesId}/${pageNum}/`;

Response fields include vpic (cover image), shortTitle (episode number), vt (episode name), vid (video identifier), and vur (playback URL).

Shipment Tracking (Kuaidi100)

Queries delivery status by carrier code and tracking number.

const carrierCode = 'shunfeng';
const trackingNum = 'SF1234567890';
const trackingApi = `http://www.kuaidi100.com/query?type=${carrierCode}&postid=${trackingNum}`;

Supported carrier codes:

  • Shentong: shentong
  • EMS: ems
  • Shunfeng: shunfeng
  • Yuantong: yuantong
  • Zhongtong: zhongtong
  • Yunda: yunda
  • Tiantian: tiantian
  • Huitong: huitongkuaidi
  • Quanfeng: quanfengkuaidi
  • Debang: debangwuliu
  • Zhaijisong: zhaijisong

Product Search Suggestions (Taobao)

Returns product suggestions based on a keyword, with JSONP support via a callback parameter.

const searchKeyword = 'laptop';
const pCallback = 'handleSuggestions';
const suggestApi = `http://suggest.taobao.com/sug?code=utf-8&q=${searchKeyword}&callback=${pCallback}`;

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.