• Home
  • Contact Me
Guru's Den Guru's Den
  • Home
  • SP26 Web Tech
  • MERN Online Book
  • Course Materials
    • CSC-336 Web Technologies Helping Material
      • CSC-336 Web Technologies Helping Material
      • CSC-336 Couse Hand Book
      • CSC-336 Lab Manual MERN Stack
      • CSC-336 Web Technologies OBE CDF
      • CSC-336 Web Technologies Lab Manual Laravel
    • Video Lectures
    • Web Technologies Lecture Slides
    • FAKE Stories RESTFUL API
    • Countries Auto Complete Example
    • MERN Stack App
    • Class Quiz
  • MERN Stack Articles
  • Hobby Blogs
    • Kids Stories
    • E-Books
  • About
    • About Me
    • CTO @ Cogentro
    • Contact Me

usmanlive presents a fake restful api for my students to practice api calls. Consult following Table for reference

Route Method Input Output Comments Test
http://usmanlive.com/wp-json/api/stories GET – – Returns an array of stories Try It Yourself
http://usmanlive.com/wp-json/api/stories/:id GET – – Replace :id with the id of the story to fetch a single record Try It Yourself
http://usmanlive.com/wp-json/api/stories/:id DELETE – – Replace :id with the id of the story to Delete Try It Yourself
 http://usmanlive.com/wp-json/api/stories  POST {“title”:”–“,”content”:”–“}    Submit a new story to add Try It Yourself
http://usmanlive.com/wp-json/api/stories/:id PUT {“title”:”–“,”content”:”–“} – Replace :id with the id of the story to Edit Try It Yourself

Hit Refresh Stories to refresh data

Visit JQuery/Bootstrap based Single page frontend which accesses above restful api

Source Code for the above example can be found here 

You can try https://reqbin.com/ to send api hits to test the above restful api

API Authentication

API Authentication can be done in numerous ways. One was is to use JSON Web Tokens. UsmanLive also present how a json web token based authentication can be implemented via following routes

Route Method Input Comments try
http://usmanlive.com/wp-json/api/auth/register POST
{“name”:”-“,”email”:”-“,”password”:”-“}
Registers a User if not registered already else returns an error Try It Yourself
http://usmanlive.com/wp-json/api/auth/login POST
{“email”:”-“,”password”:”usman”}
Returns a JSON Web Token Try It Yourself
http://usmanlive.com/wp-json/api/auth/protected POST x-auth-token token set as header Protected Route. Token is required

Try It Yourself

 

Countries Auto Complete API 

url: http://usmanlive.com/wp-json/api/countries 

It accepts a querystring parameter named q and will return the array of coutries which matches the provided parameter e.g. 

http://usmanlive.com/wp-json/api/countries?q=ak will return [“Kazakhstan”,”Pakistan”] use this api to practice autocomplete

Try Countries API yourself

 

Some Other Fake APIs

https://jsonplaceholder.typicode.com

https://reqres.in

https://fakestoreapi.com

https://gorest.co.in

https://thedogapi.com

https://fake.rest

Recent Posts

  • Setting Up CI/CD for a Node.js Application on a VPS
  • test post
  • Installing WordPress on VPS
  • Installing WordPress on VPS
  • Hosting multiple Node.js applications on a single VPS

Categories

  • Class Quiz
  • general
  • MERN Stack Articles
  • Uncategorized
  • Web Technologies Course

My Name is Usman

  • Class Quiz
  • general
  • MERN Stack Articles
  • Uncategorized
  • Web Technologies Course
© 2024 UsmanLive- A Personal Blog. All Rights Reserved. UsmanLive