Programming With a Free API

What is an API? An application programming interface acts as an intermediary between your application and the API’s server. You request information from the server and it gives you information that you requested. When you get the data that you need, you can build a front-end design to display the information in a readable format.

Programming with a Free API
Photo by Flickr from Pexels

Find An API

You can use websites like Programmable Web, RapidAPI or API List. While you are evaluating APIs to use, consider whether or not you want to pay to use it. You can find free APIs for your projects.

Farmsense API

I found a free API on ProgrammableWeb called Farmsense. Farmsense provides three APIs to farmers: Day Lengths, Frost Dates and Moon Phases. I used the Moon Phases API to display the current phase of the moon.

Farmsense API Demo

Farmsense API uses the date to tell you what phase the moon is in, what percentage of full it is, how long the day is and more.

When I reviewed the AstroWidget, it shows way more information than I want. I wanted to display the current phase of the moon using HTML, JavaScript and CSS. First, I sketched out a design so that I would know what I wanted to build. Then, I read the API’s documentation. Farmsense API doesn’t require an API key. It does requires the current date.

I used JavaScript to get the current date and choose Milwaukee, WI as the location. Farmsense requires your location in longitude and latitude. To simplify, I decided to use one location.

Getting the Data From the API

How do you get data from the API? It returns the data in JSON. Instead of using the Astro-Widget’s method of retrieving the data, I used the JavaScript Fetch API to get it. The Fetch API made it simple and easy to retrieve the data and put it spots I wanted it.

The API doesn’t include images of the moon in each phase. I found icons of Moon Phases on Icons8. Then, I wrote a JavaScript function to determine the moon phase and displayed an icon image that closely matches the phase.

Screenshot of Moon Phase - Dec. 2, 2019

APIs let you work with data to create something more interesting. With HTML, CSS and JavaScript, you can create a simple user interface that retrieves data from an API. No database required for you to maintain. You can get start learning how to work with an API quickly. Have you built something fun with an API?

More Tips to Help You Program Better

Programming can be fun and challenging. Every programmer has their own list of tips, tricks and tools that help them solve problems and build things. Reading code, writing code, working with a team and taking breaks from coding all help you to improve your code. The collection below includes these tips and more.

More Tips For Programming Better
Photo by Kevin Ku on Unsplash

All my best programming tips

Jason Swett shares his best programming and debugging tips. He reminds you to work on one thing at a time, use clear names for things, don’t allow yourself to stay stuck and close unneeded tabs.

Top 5 tips to be a better programmer without programming!

You can become better at programming by focusing on your health and well being. Luke Garrigan talks about why you need to sleep, get moving, take breaks away from the computer and more.

10 Ways to Become a Better Developer

Whether you work on a team or as a freelance programmer, you need to work with or for others. Elizabeth at Praxent share her tips for being a better developer by embracing “teams”, how to say “no” to others, code for the future and make sure you do some coding for fun. Use it to explore ideas and problems that interest you.

10 Tips for Better Coding

Writing code can be difficult. You want to stay organized and embrace practices and process that help you write better code. In 10 Tips For Better Coding, Abdullah Abouzekry gives you tips that you can incorporate into your coding practice.

8 Ways to Become a Better Coder

Esther Schindler shares her eight actionable ways to become a better programmer. Her tips include how to read code, write code for fun, work with other developers and learn techinques instead of tools.

Whether you are a beginner or more experience programmer, sometimes you need to be reminded on what you can do to write better code.

Build Code With Accessibility

What is accessibility in web development? It means building websites that as many people as possible can use. Accessibility benefits everyone not only people with special needs. Have you tried to use your phone in outside in the side or with one hand? You may have given up or waited until later to do what you needed. If you have special needs, using an app or website can be a challenge. Accessibility means developing websites that people can use regardless of their physical and cognitive abilities. Or how they access your website.

Build Code With Accessibility
Photo by Zan Ilic on Unsplash

How do you build software with accessibility in mind?

In her talk at Dot Net Conference 2019, Rachel Appel explained how developers can build accessible websites without greatly changing how they code. People have variety of needs. When you develop, you need to make your code usable for people with a wide range of visual, cognitive, hearing and motor abilities.

Visual

People with visual issues include low vision, blindness and color contrast. Some people may use a screen narrator to help them navigate your website. For people using a screen narrator, use skip links. Skip links allow them to skip over the navigation and go directly to the content.

For making sure that your site is readable by as many people as possible, you can use Color Oracle, a free color blindness simulator. It is available for MacOS, Linux and Windows. You can also use Accessible Colors or WebAim’s Color Contrast Checker to ensure check your color choices.

Cognitive

People with cognitive difficulties includes learning and age-related issues. You want to keep things simple and clear. Write using short sentences, active voice and simple words. Use headings and labels to help people easily find information. See Mozilla’s Cognitive Accessibility for more tips.

Hearing

People have a wide range of hearing abilities. With videos or audio, you want to include transcripts and close captioning. In your software, don’t rely on sounds alone for feedback.

Motor

People with motor issues can have tremors, difficulty moving a mouse and more. Avoid pop-ups if you can. When you can’t, make sure that they can be closed easily. Use alt tags on all images that are not decorative.

By developing for a wide range of people, you make sure that your website is usable no matter how or where they access the web.

Read more

4 Ways to Make Your Web Design Simple

What is simplicity? According to Merriam-Webster Dictionary, simplicity is the state of being simple, uncomplicated or uncompounded. A simple web design is uncomplicated. Minimalist design style is related to simple. It has only the necessary elements for functionality. A minimalist design can be simple, but a simple design is not minimalist.

4 Ways to make your web design simple
Image by Ambady Sasi from Pixabay

Is your website complicated or complex?

What makes it complex?

  • Too much content
  • Unnecessary design elements
  • It’s slow to load and hard to use

Why do you want your design to be simple?

A simple website is easy to navigate and use. It has the right number of design elements. A simple website loads faster and helps guide your customer to do what they want. It has content that is readable and scannable.

What can you do to make it simple?

Look at your content and ask is it necessary?
If not, remove it. If its, consider rewriting it. Use bullet points, shorter paragraphs and headings to break the text up. You don’t want to overwhelm people with a sea of text.

Review your site for extra design elements
Do you have colors, illustrations and photos that serve as decorations? If so, consider removing anything that is unnecessary.

Check for ease of use

  • Is your navigation bar complicated? Too many options can make it hard to use.
  • Do they need to go to multiple pages before getting all of the information that they need? Too many pages can make a simple design hard to use.
  • Are your forms easy to use? Complicated forms can make your visitors leave your website.

Look for items that slow your site down
Your photos, CSS, CMS and additional code can slow your website down. People won’t use your site if it is really slow. Use tools to compress and optimize your photos and CSS. Make sure your CMS is updated to the latest version. If you use any third party or custom code to extend your website, check if they are causing speed issues. See if you can get rid of the slow ones.

Simplicity is not a design style. Keeping your web design simple is hard. Websites change and evolve over time. You have to continually work to keep the design simple.

Making a Dark Mode For Your Website

Do you use dark themes or dark mode in your text editor? You can offer website visitors a choice of dark or light modes. Some people prefer using the dark mode because it is easier on their eyes.

Making a Dark Mode For Your Website
Image by PublicDomainPictures from Pixabay

What do you need to create a dark mode?

The only tools you need are HTML, CSS and JavaScript. You can use a button to allow your visitors to select between modes or use media queries that check their operating system for their preference.

Toggle example

Ananay Negoi uses CSS Variables and a button to toggle between light and dark mode. She demonstrates how to build the Dark-Light mode switch.

Level 5 Media Query

Level 5 Media Query checks your operating system for your preference for a light or dark mode. You can use this query to automatically set the mode for each visitor.

Designing for dark mode

When you create a dark mode for your website, it involves more than switching the colors to darker ones. You need to consider how color, fonts, images affect the readability and usability of your website. Your website reflects your brand. You want to think about how a dark mode can affect your brand. Andy Clarke walks you through the steps he took when he created a dark mode version of his website.

Dark Mode Resources

If you want to implement a dark mode design of your website, refer to these resources on how to do it.