SampleAPIs icon indicating copy to clipboard operation
SampleAPIs copied to clipboard

Add an EndPoint

Open jermbo opened this issue 5 years ago • 2 comments

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!!

jermbo avatar Feb 28 '20 14:02 jermbo

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

  1. Create a endpointName.json file
    1. eg. baseball.json for sampleapis.com/baseball/api
    2. The first level keys in the object becoming a "collection" of data. For example homeruns or stolen-bases.
    3. These will translate to .com/baseball/api/homeruns/ or .com/baseball/api/stolen-bases`
  2. Create a backup endpointName.json.backup file.
    1. This will be used as the basis for when the system resets.
  3. Update the src/apiList.js export array.
    1. 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
}

thedamian avatar Oct 21 '20 02:10 thedamian

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

Darkskittlz avatar Oct 06 '21 02:10 Darkskittlz