Back in the early days of the front end, Ajax really touched every kneel. At that time, I did not understand the backend, did not know what API was, and did not have a backend partner to write interfaces for me to test.
This article has put together a few free online apis I’ve used without having to deal with cross-domain issues.
I hope I can provide a little help to the beginners when learning Ajax.
The online interfaces cited in this article include: text and images.
The examples in this article are tested using Postman because I’m too lazy to write Ajax code myself.
If this article is helpful to you, please give me a thumbs up at 👍
{JSON} Placeholder
“JSONPlaceholder”Provide a free API for testing.
JSONPlaceholder is very simple to use, providing GET, POST, PUT, PATCH, and DELETE request methods.
Also provides paging query, specific ID query and other functions.
Example: GET 100 articles data (GET)
Returns 100 pieces of data, each with a post ID, a post ID, a title, and a brief introduction.
http://jsonplaceholder.typicode.com/posts
Copy the code
Example: GET article data by article ID (GET)
Gets data for the specified article based on the article ID.
Returns: post ID, post ID, title, and content.
http://jsonplaceholder.typicode.com/posts/2
Copy the code
This example passes in ID 2 and returns data with ID 2.
Example: Add article (POST)
Use POST to send an article, and an article ID is returned on success.
http://jsonplaceholder.typicode.com/posts
Copy the code
Other interfaces (try it yourself)
Post interface:
- To obtain a list posts: jsonplaceholder.typicode.com/posts
- According to the post ID for more details: jsonplaceholder.typicode.com/posts/1
- For a user all posts: jsonplaceholder.typicode.com/posts?userI…
- All access to post comments: jsonplaceholder.typicode.com/posts/1/com…
Comments on the interface
- Get comments list: jsonplaceholder.typicode.com/comments
- Get all the comments of a post: jsonplaceholder.typicode.com/comments?po…
Album interface:
- Their album list: jsonplaceholder.typicode.com/albums
- According to the album ID for more details: jsonplaceholder.typicode.com/albums/6
- To obtain a user all album: jsonplaceholder.typicode.com/albums?user…
To-do list Interface:
- Get to-do list: jsonplaceholder.typicode.com/todos
- According to the backlog ID for more details: jsonplaceholder.typicode.com/todos/6
- To obtain a user all todo: jsonplaceholder.typicode.com/todos?userI…
User interface:
- Get the user list: jsonplaceholder.typicode.com/users
- According to the user ID for more details: jsonplaceholder.typicode.com/users/5
Photo interface:
- To obtain a list photos: jsonplaceholder.typicode.com/photos
- According to the photo ID for more details: jsonplaceholder.typicode.com/photos/8
Second, cat slave welfare interface
“The Cat API-cats as a Service.”Will return pictures of cats, definitely a benefit.
You can see the “document”, which includes “search by breed”, “search by category”, “paging search”, “picture upload”, “image analysis” and other interfaces for cats, which can be used according to the document.
Example: Randomly GET 1 cat graph (GET)
Each request returns a random picture of a cat.
https://api.thecatapi.com/v1/images/search?limit=1
Copy the code
The use of other interfaces are relatively simple, “official documentation” is very clear, you can use postman test.
Three, dog sub interface
The “Dog API” provides a picture of a Dog, and when you first see the API on the homepage of the official website, you can get a random picture of a Dog, which is very interesting.
Example: Return a random dog photo (GET)
https://dog.ceo/api/breeds/image/random
Copy the code
Other interfaces are also easy to use, details can be seen in the “dog official documentation”
Random picture interface
“Lorem Picsum” can return a random photo and can also specify the size of the photo.
The interface provided by Lorem Picsum returns an image resource at random.
You can use it directly within the SRC attribute of the tag.
Example: the returnedIt's 200px wide and 200px high
Picture of (GET)
https://picsum.photos/200
Copy the code
Example: Say you want to getIt's 200 wide and 300 high
Picture of (GET)
If the width and height are different, you can set them yourself.
https://picsum.photos/200/300
Copy the code
5. Other interfaces
The first four are the ones I use the most, and the next ones are the ones I use less but know about. You can test it yourself if you need to.
Iqiyi interface
https://cache.video.iqiyi.com/jp/avlist/} {content id /} {paging /Copy the code
Example: Use one Piece source ID (GET)
https://cache.video.iqiyi.com/jp/avlist/202861101/1/
Copy the code
You can guess:
vpic
: The cover of each episodeshortTitle
: putvt
: Name of the episodevid
: video idvur
: Video playing address
Other fields guess yourself, I am lazy ~
Logistics interface
http://www.kuaidi100.com/query?type= express company code & postid = express a single numberCopy the code
Express Company Code:
-
Shentong: shentong
-
EMS: EMS
-
Motion: shunfeng
-
Yuantong: yuantong
-
Zhongtong: zhongtong
-
YunDa: yunda
-
Every day: tiantian
-
Herald: huitongkuaidi
-
The peak: quanfengkuaidi
-
DE bont: debangwuliu
-
Delivery: zhaijisong
Taobao Commodity Interface
http://suggest.taobao.com/sug?code=utf-8&q= keyword & commodity callback = cbCopy the code
Callback is the callback function setting