Code Monkey home page Code Monkey logo

sampleapis's Introduction

Sample APIs 3.1

Screenshot

Purpose

Understanding RESTful APIs is hard enough, even without including an authentication mechanism. The sole purpose of this repository is to play with RESTful endpoints and learn. We have a few endpoints that you can start playing around with right away! If you are not finding anything you are interested in, create your own endpoints and/or submit a pull request. Take a look at the CONTRIBUTING for more information on how to get involved.

How to use the service

Choose an endpoint, say "futurama", then choose what information you'd like, say "characters":

const baseURL = "https://api.sampleapis.com/futurama/characters";
fetch(baseURL)
  .then(resp => resp.json())
  .then(data => console.log(data));

Want to Search? for all chatacters with the name "Bender"?

const baseURL = "https://api.sampleapis.com/futurama/characters";
fetch(`${baseURL}?name.first=Bender`)
  .then(resp => resp.json())
  .then(data => console.log(data));

You also have full CRUD, so you can add information or correct existing ones.

Note: Just know that we reset all datapoints weekly and each time we have a new endpoint added.



Changes

Hosting has switched again due to Vercel.com's static nature. The app is being self hosted and is back to being fully CRUD-able.

Checkout the Change Log for full details.

Disclaimers

  • The data on this site is for educational purposes only and is not owned by SampleAPIs.com
  • Data will be reset back to its original state on a regular basis. If you are updating or adding data to the endpoints and want to have them persist as part of the collection, please contribute to the repo by submitting a pull request.
  • By using SampleAPIs.com you agree to the following terms: This service is provided under an "as is" condition. It might change or will be discontinued without prior notice. The maker of this service can't be held liable in any way for any reason.

Recent changes.

Ok. a LOT of work from the great Jermbo, and then a little fluf from TheDamian to make it more pretty!

sampleapis's People

Contributors

bellingarc avatar ctnkaan avatar dboudet avatar dependabot[bot] avatar devdigression avatar elistone avatar gareys avatar hcmlopes avatar jermbo avatar jldorta avatar jsanchez-legacy avatar jzacka1 avatar mj305 avatar samvbeckmann avatar thedamian avatar wesbos avatar yarocruz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sampleapis's Issues

Rate Limiter

Need to add a rate limiter to help prevent malicious users.

Create Custom EndPoints

With all the amazing endpoints on the site already, sometimes having a quick way to start something up would be ideal. SampleAPIs should have a way for any user to create a temporary database. The database will have a file size and rate limit, and will be live for short period of time.

User Flow:

  • Navigate to sampleapis.com/create
  • Enter desired endpoint name
    -- validate if not already taken
  • Provide screen with existing list of URLs
    -- Make this list filterable

Create API for blockchain projects

Create a sample API for blockchain projects based on consensus, purpose behind it, market cap, ticker symbol, what languages it's written with, and how long it's been around for.

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

New Coffees

In the following API (https://api.sampleapis.com/coffee/hot) there have been added two new coffees (both with the title Black). Now there are 3 coffees who have exactly the same fields, except the id. Is this intentional? I have to build an own android app for school, but I can't get the data anymore, while previously I could get all the data. Now my coffee list returns 'null' in the app.

Migrate Front End to Vite

I've been hearing a lot of good things about Vite.js. Figured this would be a good playground to test how that would work and see if there are any performance / development gains.

Docs - How APIs Work

The purpose of Sample APIs is to be a resource to learn all things APIs.

I would like a documentation foundation set up explaining what an API is.
This should include things like;

  • Acronym Definitions
  • HTTP Verb Explanations
    • Links to authority references
  • Simple Diagrams providing a visual explanation
  • ... anything you think a beginner would benefit from knowing

Site down

I'm sorry to submit so many issues, but the site is down. Is it maybe possible to display a message when you work on the website? This way the users know that the website will be up again soon.

Countries JSON

I think the structure of https://github.com/jermbo/SampleAPIs/blob/main/src/api/countries.json should be different.

Instead of:
{
"name": [
{ "BD": "Bangladesh" },
{ "BE": "Belgium" },
{ "BF": "Burkina Faso" },
...
],
"capital": [
{ "BD": "Dhaka" },
{ "BE": "Brussels" },
{ "BF": "Ouagadougou" },
...
],
...
}

We should use:
{
"name": [
"BD": "Bangladesh" ,
"BE": "Belgium" ,
"BF": "Burkina Faso",
...
],
"capital": [
"BD": "Dhaka",
"BE": "Brussels",
"BF": "Ouagadougou",
...
],
...
}

It is going to be easy to manipulate and access to items inside the object.

If this makes any sense I can take care of it.

Presidents of the United State of America

Millions of peaches! Peaches for me!
No...not those Presidents. I was thinking of adding a collection for the US Presidents.
As a starter, each entry would look something like:

	{
		"ordinal": 1,
		"name": "George Washington",
		"yearsInOffice": "1789-1797",
		"vicePresidents": ["John Adams"],
		"photo":
	"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/220px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg"
	}

and more things could be added later.

website is having issues

Api-list isn't bringing back any results on the hosted website, the wine list API I was consuming is also failing.
image

API response includes errant name and rating avg values

Hey guys, enjoying your API!

Thought it was worth pointing out that there's an issue with one of the beers.

Doing a fetch of the Beers API (URL: https://api.sampleapis.com/beers/ale/).

The first beer should be the Founder's Ale which has been correct up until last night.

  • The name key is returning an errant a value
  • The rating.average is displaying a score of 9 out of the scale of 5.
{price: '$3', name: 'a', rating: {…}, image: 'https://www.totalwine.com/media/sys_master/twmmedia/h00/h94/11891416367134.png', id: 3}
id: 3
image: "https://www.totalwine.com/media/sys_master/twmmedia/h00/h94/11891416367134.png"
name: "a"
price: "$3"
rating: {average: 9, reviews: 298}

Better 404 Page

Currently the 404 page is a blank page with the text 404.

It would be great to have a nicely styled 404 page with smart redirects.

Update to Next.js

Now that this system is running on React, we need to convert to as SSR platform. Next.js seems to be a popular option.

CSS Color Names

Stumbled across this site, https://xkcd.com/color/rgb/, and thought it would be cool to have this data a part of the api. Eventually, I would like to build an random color generator using only css names.

Update Contribution Documents

As the system has been improved, some of the steps to contribute an API have been automated and need to be updated in the documentation to reflect.

Wrong data API coffee

The API of coffees is again filled with wrong data, which is stressful because in a few days I need to hand in my Android Studio project.

Basic Type Safety for EndPoints

Description

As a user I would like to have basic validation for every endpoint on Sample APIs. I would like a helpful error message when trying to do something that would break the data set by accident.

POST or PUT

If a user hits an endpoint via a POST or PUT with data that does not match previous entries in the endpoint, the server should throw a helpful error.

Something like:

{
	"error": 400,
        "message": "The data you are sending does not match the existing data object. Check out the expected shape versus what was sent.",
        "expected": "[EXAMPLE-DATA-FROM-ENDPOINT]",
        "received": "[USER-REQ.BODY]",
}

PATCH

If a user hits an endpoint via a PATCH what data that does not exist in previous entries in the endpoint, the server should throw a helpful error.

Something like:

{
	"error": 400,
	"message": "It appears you are trying to manipulate data that does not exist on the object. Check out the expected shape versus what was sent.",
        "expected": "[EXAMPLE-DATA-FROM-ENDPOINT]",
        "received": "[USER-REQ.BODY]",
}

GET or DELETE

If a user hits an endpoint via a GET or DELETE, the server should just pass everything through as normally expected.

State flag image for Oregon is not valid as an image source

"flag": "https://en.wikipedia.org/wiki/Oregon#/media/File:Flag_of_Oregon.svg"

While using the United States API, I encountered an issue rendering the Oregon state flag. This is because the URL provided for the state flag returns the incorrect content-type when used as an image source.

As an alternative, I have found an Oregon state flag image with a source that is consistent with the other state flag image URLs.

https://upload.wikimedia.org/wikipedia/commons/b/b9/Flag_of_Oregon.svg

The United States API should be updated to use this flag. I will open a corresponding PR to address this.

Acceptance Criteria:

  • The new Oregon state flag URL should be a valid URL that points to the Oregon state flag SVG file on Wikipedia.
  • When using this URL as an image source, it should render the image.
  • The PR and Issue should adhere to the Contribution guidelines

API List > Categories

I'm not sure if this has been brought up, as I couldn't find it, or even if you are even still working on this project.

I found a specific thing in the All Categories, dropdown where all the options on the inside are white, and this is because of the .api-filter select{} in the CSS, where the var(--color-text-light) is used. I've found a quick fix that doesn't change what "All Categories" looks like besides in the dropdown.

This fix is putting:
option{ text-color: ----}

Hopefully this helps!

Docs - What is GraphQL

The purpose of Sample APIs is to be a resource to learn all things GraphQL.

I would like a documentation foundation set up explaining what GraphQL APIs are.
This should include things like;

  • Acronym Definitions
  • HTTP Verb Explanations
    • Links to authority references
  • Simple Diagrams providing a visual explanation
  • ... anything you think a beginner would benefit from knowing

APIs are returning 429 "Too many requests" error

Whenever I call one of the APIs the request is returning a 429 HTTP code for "Too many requests." This happens on my first request, so I don't think I'm being rate limited. Is there some issue with the total requests to the site exceeding some threshold?

Correct endpoints.

Some endpoints are to complex for the JSON Server system and need to be simplified to be more consumable.
Some endpoints do not have proper indexes causing some features to not work properly.

Updated Documenation

Since the structure has changed a bit, it's time for a documentation refresh.

It would be nice to have it clearly explained how to set up a new data source, what are the requirements, what files need to change, etc.

API Data Reset

As an admin, I would like a simple way to reset all endpoints data or an individual endpoint data.

Currently, there is a way to reset do this. The issue is the server needs to be triggered to reset itself. After speaking with the host, if the app fails for what ever reason, then a server process automatically kicks in to turn the app back on.

We need to figure out a way to utilize that functionality when resetting the data without causing an infinite loop of reset, crash, turn on.

Docs - What is REST

The purpose of Sample APIs is to be a resource to learn all things REST.

I would like a documentation foundation set up explaining what REST APIs are.
This should include things like;

  • Acronym Definitions
  • HTTP Verb Explanations
    • Links to authority references
  • Simple Diagrams providing a visual explanation
  • ... anything you think a beginner would benefit from knowing

Ensure API list is dynamically generated

Currently, we are having to maintain a .js file to create the connections between endpoints and front end. The API List that powers the site should be dynamically generated based on the JSON files that exist inside the system.

502 when hitting api.sampleapis.com

I am getting a 502 bad gateway error when trying to hit endpoints at api.sampleapis.com. The API list on the website is also empty.

curl https://api.sampleapis.com/countries/countries

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>

Tests

Now that the system is in a pretty stable place, I believe it would be a good time to start introducing some tests.

I am open for what tests should be there, but I think we need the following as an MVP:

  • Ensure all .json files in the api folder have id's associated with each entry point.
  • Ensure all .json files in the api folder have at least 1 endpoint.
  • Ensure all endpoints are included in the apiList.js file
    • Ensure all endpoints included have the minimum values. +
  • Ensure all .json files in the api folder have associated backup file. .json.backup
  • Ensure all endpoints are rendering.
  • Ensure CRUD works on each endpoints.
  • apiList.js entry should have the following information
{
    id: 0, // Unique ID
    title: "", // Title to be displayed on home and individual pages
    longDesc: "", // A long description meant for display on the individual page. 
    desc: "", // A short description meant for display on the home page
    link: "", // Link to be used in the url. This should match the json file name exactly.
    graphLink: "", // The same name as the link, but with a '/graphql' in at the end.  
    endPoints: [ "" , ... ], // list of available endpoints, in string format. 
},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.