SampleAPIs
SampleAPIs copied to clipboard
Add an EndPoint
Sample APIs is a play ground for learning about RESTful and GraphQL based APIs.
If you would like to see a specific set of data in an endpoint, please feel free to submit a PR with your desired data. The more options there are the better this tool becomes!
Happy Coding!!
How To Contribute - Summary
Here's the "how to" guide to adding the endpoints YOU want (because those are the best https://github.com/jermbo/SampleAPIs/blob/main/CONTRIBUTING.md#example-of-adding-a-new-endpoint
Example of adding a new Endpoint
Our project is all about great data to play with! And I know of no one better than YOU (yes YOU) that knows what data YOU WOULD like to play with.
In this section we'll learn how to add a new dataset (or "endpoint" as we'll call them)
Each endpoint needs three files. Here's a example of a new PR adding just a new endpoint
Adding an Endpoint
Here are the official steps to add an endpoint
- Create a
endpointName.json
file- eg. baseball.json for
sampleapis.com/baseball/api
- The first level keys in the object becoming a "collection" of data. For example
homeruns
orstolen-bases
. - These will translate to
.com/baseball/api/homeruns/ or
.com/baseball/api/stolen-bases`
- eg. baseball.json for
- Create a backup
endpointName.json.backup
file.- This will be used as the basis for when the system resets.
- Update the
src/apiList.js
export array.- This will include your new endpoint in the list on the home page.
Updating the apiList.js
There is a specific format necessary to populate the home page list. Take a look at the example below and update to match your new information.
// example from the RickAndMorty endpoint
{
id: 22, ⬅ //use a new ID
title: "Rick And Morty", ⬅ //Title on top of page
longDesc: "This is t...", ⬅ //Description on the endpoint's page
desc: "AP", ⬅ // description for front page
link: "rickandmorty", ⬅ // endpoint url
graphLink: "rickandmorty/graphql", // graphql endpoint
endPoints: ["characters","episodes","locations"], ⬅ // All collections (or properties) in the endpoint from the endpointName.json file
}
Hey @jermbo I was wondering if you could forward me that article you were going off of in todays zoom about web scraping the data of a wiki page with chrome dev tools? It all happened so fast I couldn't screenshot the commands. I definitely want to add my own endpoint and will be working on this tomorrow.
All the best, Jeremy