Header add

In this article we will learn about How to host a JSON API on GitHub Pages.

GitHub Pages is an excellent place to host a site for your portfolio or a project and another helpful use for it is to host JSON API data. We need to create a GitHub Pages repository, put that JSON file in there, and your custom URL will have all of that data. From there you make an API call to your GitHub Pages URL rather than the API server.



Create a new Repository in Github page

Create a GitHub Pages repository, and it should be like username.github.io, where username is your GitHub username. Make sure that it matches your username else it won’t work.

For more details about GitHub pages go through this link https://pages.github.com/.

Github.io pages

Once you create the repository it navigate to this screen and you can create a new file or you can clone this and push the file using Git command else you can use also Github Desktop app.


Then create a new file of customers.json like below.

customer.json

After creation of this hit the commit button you can get the URL like below

https://corespider.github.io/customer.json






You can use this JSON file anywhere. In below you can see we are use to read json data in ASP.Net.




Summary
In this tutorial we discussed How to host a JSON API on GitHub Pages. If have any question related to this topic then give your feedback.

Post a Comment

Previous Post Next Post