/Working-with-API

The project FactBox exposes its data in the form of API. This README gives an insight about different API exposed and how to work with them.

Working-with-FactsBox-API

The project FactsBox (deployed on Heroku) exposes its data in the form of API. This README gives an insight about different API exposed and how to work with them.

To see the Live Demo of project Click here
To Learn more about the project Visit here

FactsBox API

I wouldn't feel my app to be complete if it doesn't have an API for you. You can just request the JSON feed for all facts or some particular facts of your choice.

  1. To get all the facts:
 GET https://factsbox.herokuapp.com/api/FactAPI/allFacts 

That will give the array something like this:

 [{"factId":1,"factCategory":"PHYSICS","factDesc":"BLACK HOLES ARE VERY DARK, BUT THEY GLOW, SLIGHTLY, GIVING OFF LIGHT ACROSS THE WHOLE SPECTRUM"},{"factId":2,"factCategory":"PHYSICS","factDesc":"IT IS ESTIMATED THAT SUN BURNS AROUND 620 MILLION METRIC TONS OF HYDROGEN PER SECOND INTO 616 MILLION METRIC TONS OF HELIUM."},{"factId":3,"factCategory":"PHYSICS","factDesc":"LIGHTNING STRIKES ABOUT 6,000 TIMES PER MINUTE ON OUR PLANET."}] 

2. To get a single fact based on ID:
 GET https://factsbox.herokuapp.com/api/FactAPI/factId/10 
That will give the array something like this:
 [{"factCategory":"MATHS","factDesc":"ZERO IS THE ONLY NUMBER WHICH IS KNOWN WITH SO MANY NAMES INCLUDING NOUGHT, NAUGHT, NIL, ZILCH AND ZIP."}] 

3. To get the list of categories:
 GET https://factsbox.herokuapp.com/api/FactAPI/distinctCategory 
That will give an array of distinct categories like:
 ["BIOLOGY","CHEMISTRY","MATHS","PHYSICS","SCIENTIST","WWII"] 

  1. To get a list of facts based on Category:
GET https://factsbox.herokuapp.com/api/FactAPI/category/PHYSICS

That will give the array something like this:

 [{"factId":7,"factDesc":"THE HIGHEST TEMPERATURE EVER REACHED ON EARTH WAS 4 TRILLION DEGREES CELSIUS. THIS WAS IN QUARK-GLUON PLASMA AT BROOKHAVEN RHIC. "},{"factId":8,"factDesc":"THE YOUNGEST PERSON TO RECEIVE THE NOBEL PRIZE IN PHYSICS WAS WILLIAM L. BRAGG AT AGE 25. I WONDER IF HE BRAGGED ABOUT IT. "}]