This page is a work in progress.You can help improve it. →

Writing an API Client

In this project, you will practice accessing an API. You'll see how an API request is made from code, and see how data is returned from an API.

Objectives

  • Understand API requests and responses from code.

Setup

For C#:

dotnet new sdg-console -o ApiClient

For JavaScript:

degit $GITHUB_USER/html-css-ts-project-template ApiClient

Explorer Mode

  • TOP TIP: Choose an API that has a simple, less nested API. Perhaps one that just returns an array of one-level-deep objects. This will make your task significantly easier.
  • Choose one of the APIs from this list that does not request "AUTH" (Authorization) since an API that requires authorization is a little more difficult to use when first learning. I have also selected some sample APIs that will be good choices:
APIDocumentation
Dogshttps://dog.ceo/dog-api/
Studio Ghiblihttps://ghibliapi.herokuapp.com/#tag/Films
Open Breweryhttps://www.openbrewerydb.org/
Recipeshttp://www.recipepuppy.com/about/api/
Deck of Cards!http://deckofcardsapi.com/
Geocodehttps://geocode.xyz/api
Jobshttps://jobs.github.com/api
Lyricshttps://lyricsovh.docs.apiary.io/#reference
Quoteshttps://pprathameshmore.github.io/QuoteGarden/
SpaceXhttps://docs.spacexdata.com/?version=latest
Jokeshttps://github.com/15Dkatz/official_joke_api
Star Wars APIhttps://swapi.dev
Harvard Art Museum API (this one requires an API key, but set up is very simple)https://www.harvardartmuseums.org/collections/api
  • After choosing your API read the documentation.
  • Create a new application for accessing the API.
  • For C# create a class to store information that comes back from your API.
  • Write code to query the API and show results.
  • If your API has more than one endpoint (URL) support a few options, perhaps by creating a menu system in your application.

Epic Mode

Use the site Mockaroo to create a mock API. You may need an account and then learn how their "Mock API" feature works.

Once you have created your Mock API for whatever schema you wish, create a client application to work with it.

© 2017 - 2022; Built with ♥ in St. Petersburg, Florida.