6 one-liners that do the heavy lifting for you


Using an API can be a tricky challenge, with issues like authentication, rate limiting, different data formats, and various HTTP verbs to master. But some APIs can be simple, requiring little more than a browser or the curl command-line tool.

These APIs are easy to use and provide tangible benefits in a simple format, from Markdown formatting to everything you ever wanted to know about cats.

Convert markdown into HTML

A universal, speedy way to format your writing

The GitHub REST API is enormous, with approximately 700 different endpoints. Of course, the difference between some of these is minimal, but the entire set covers many diverse features, from following a user to getting a billing report.

A command line fetching and parsing a list of the GitHub API's endpoints to display them.

Some of the most interesting calls, that are useful in a wider context, are quite well hidden. But if you go looking, you can uncover some real gems, like the /markdown endpoint. This call carries out a simple, but much-used action: converting markdown into HTML.

Naturally, this API call requires you to provide the Markdown you want to convert as POST data, via the text parameter. You can do this with one of curl’s many options, using -d to supply the input Markdown:

curl https://api.github.com/markdown -d '{"text": "This is *really* important..."}'

The response is raw HTML that you can save to a file or pipe to another process:

Calling the GitHub markdown API using the curl command shows an HTML translation of the input.

You could even integrate this API into a more complex workflow, like a simple static site generator to turn your markdown into a blog. Of course, there are libraries in many programming languages to convert Markdown, and tools like pandoc to convert many formats, including Markdown. But GitHub’s API could be invaluable if either option is unavailable, and it’s perfect for shell scripting.

Find images of emoji

Express yourself

Another somewhat unexpected endpoint that GitHub’s API provides is /emojis. It’s another one with plenty of potential use, that’s still very easy to understand. This call returns a map of emoji names to URLs of images that represent each emoji.

The GitHub API emoji endpoint returning a list of emoji names with corresponding image URLs.

If you ever need to search for emojis by keyword or view a list of thumbnails, this is a very useful source. If your terminal supports graphics, it can be even more useful. For example, the powerful kitty terminal lets you output an image using the icat kitten:

Using the emojis endpoint from the GitHub API and kitty’s icat to show an octocat emoji in the terminal.

Again, you could include this in a startup script to make your terminal a bit more welcoming, or you could use emoji images in any script for some added visual flavor.

Get a cat fact

Fun feline facts for free

OK, this one might not be as useful to you if you’re a dog person, but I hope you can still appreciate the utility! The host of this API, catfact.ninja, presents it in a minimalist style, using the API documentation tool, Swagger:

The catfact.ninja website shows output from the Swagger documentation tool, with two endpoints shown: /fact and /facts.

So, not only does this API provide an insight into feline friends, but it will also introduce you to Swagger and the underlying OpenAPI Specification it uses to describe APIs.

Cat Fact is a tiny API, so it’s great for beginners to get their head around. The basic endpoint is /fact, which returns a random fact from a database of several hundred. Facts range from the common (“Cats dislike citrus scent.”) and the fascinating (“A domestic cat can run at speeds of 30 mph.”) to the pretty unsavory (“Approximately 24 cat skins can make a coat.”).

Since the app does not require authentication, and the output format is so straightforward, it’s easy to use on the command line, e.g.:

curl -s https://catfact.ninja/fact | jq -r .fact

You could set this up as a script to inject a random fact into your website’s homepage or have your terminal greet you with one on startup, by editing your .bashrc file, for example. Bonus points are available for creative use of a useless Linux command like cowsay:

A cat fact piped to the cowsay program with the kitty format, showing an ASCII cartoon of a large cat quoting the fact.

Look up country data

Get to know the world around you

There are many different geographic APIs, probably because location data is so fundamental to many modern services. If you’re not delivering something to somebody’s address, you’re using their location to select a currency or divert them to a language-specific translation. These services have many different selling points, but ease of use and low price aren’t often high up on the list.

I’ve picked the REST Countries API because it bucks the trend. Although it features several endpoints, the focus here is on countries, searching for them, and filtering the information received.

The simplest endpoint, all, returns data for every country, according to the fields requested in the fields parameter. So /all?fields=name will return name information about every country, while /all?fields=cca2,population gives an ISO 2-letter country code alongside the population.

Other endpoints restrict the set of countries returned, letting you filter them by criteria like currency, for example: /currency/gbp. Using these endpoints, you’ll see all fields, but you can restrict them in a similar way to /all, using the fields parameter, e.g., /currency/usd?fields=name.


Fetch a placeholder image

Watch this space

Placeholders can be a vital tool at several points in the design process; when presenting wireframes or a storyboard, for example. Sometimes, you want to plan for an image to exist in a layout, without knowing exactly what that image will be. Placeholders are so useful that some tools, such as Google Slides, have bespoke functionality supporting them.

Many APIs exist to provide a placeholder image on request, but few are as capable—and easy to use—as Placehold. This service generates plain placeholders with text, but you can configure them in many different ways using parameters to control size, format, color, and font. You can even customize the text, which, by default, reflects the image’s dimensions.

If you don’t specify a format, you’ll get an SVG back. Modern browsers will display an SVG if it’s the target of an IMG tag, so you can drop any Placehold URL directly into your page source, e.g.:

<img src="https://placehold.co/900x400" />

Consult a dictionary

Everything you ever wanted to know about words

Your OS may come with a free dictionary, but it’s unlikely to be as useful as this API. Free Dictionary API gives you a wealth of information about a word, including definitions, phonetics, and synonyms. There’s very little documentation because the API is, seemingly, a single endpoint with no parameters:

https://api.dictionaryapi.dev/api/v2/entries/en/<word>

Just replace with whatever word you want to look up and process the JSON response.

The Free Dictionary API website showing a response to a lookup for the word "squid," with phonetic details and meanings.

This API could come in handy when you just want to quickly look a word up, but it should also be a useful integration for many types of apps. If you’re writing an editor, any kind of translation tool, or a solver for your favorite word game, dictionary lookup could be an integral part.


Plenty of useful APIs are waiting to be discovered

A lot of APIs require quite an initial investment, which is a shame when you’re trying to build a quick prototype or a simple script. But there are accessible, free APIs out there to be discovered.



Source link

Leave a Reply

Subscribe to Our Newsletter

Get our latest articles delivered straight to your inbox. No spam, we promise.

Recent Reviews


Google Maps has a long list of hidden (and sometimes, just underrated) features that help you navigate seamlessly. But I was not a big fan of using Google Maps for walking: that is, until I started using the right set of features that helped me navigate better.

Add layers to your map

See more information on the screen

Layers are an incredibly useful yet underrated feature that can be utilized for all modes of transport. These help add more details to your map beyond the default view, so you can plan your journey better.

To use layers, open your Google Maps app (Android, iPhone). Tap the layer icon on the upper right side (under your profile picture and nearby attractions options). You can switch your map type from default to satellite or terrain, and overlay your map with details, such as traffic, transit, biking, street view (perfect for walking), and 3D (Android)/raised buildings (iPhone) (for buildings). To turn off map details, go back to Layers and tap again on the details you want to disable.

In particular, adding a street view and 3D/raised buildings layer can help you gauge the terrain and get more information about the landscape, so you can avoid tricky paths and discover shortcuts.

Set up Live View

Just hold up your phone

A feature that can help you set out on walks with good navigation is Google Maps’ Live View. This lets you use augmented reality (AR) technology to see real-time navigation: beyond the directions you see on your map, you are able to see directions in your live view through your camera, overlaying instructions with your real view. This feature is very useful for travel and new areas, since it gives you navigational insights for walking that go beyond a 2D map.

To use Live View, search for a location on Google Maps, then tap “Directions.” Once the route appears, tap “Walk,” then tap “Live View” in the navigation options. You will be prompted to point your camera at things like buildings, stores, and signs around you, so Google Maps can analyze your surroundings and give you accurate directions.

Download maps offline

Google Maps without an internet connection

Whether you’re on a hiking trip in a low-connectivity area or want offline maps for your favorite walking destinations, having specific map routes downloaded can be a great help. Google Maps lets you download maps to your device while you’re connected to Wi-Fi or mobile data, and use them when your device is offline.

For Android, open Google Maps and search for a specific place or location. In the placesheet, swipe right, then tap More > Download offline map > Download. For iPhone, search for a location on Google Maps, then, at the bottom of your screen, tap the name or address of the place. Tap More > Download offline map > Download.

After you download an area, use Google Maps as you normally would. If you go offline, your offline maps will guide you to your destination as long as the entire route is within the offline map.

Enable Detailed Voice Guidance

Get better instructions

Voice guidance is a basic yet powerful navigation tool that can come in handy during walks in unfamiliar locations and can be used to ensure your journey is on the right path. To ensure guidance audio is enabled, go to your Google Maps profile (upper right corner), then tap Settings > Navigation > Sound and Voice. Here, tap “Unmute” on “Guidance Audio.”

Apart from this, you can also use Google Assistant to help you along your journey, asking questions about your destination, nearby sights, detours, additional stops, etc. To use this feature on iPhone, map a walking route to a destination, then tap the mic icon in the upper-right corner. For Android, you can also say “Hey Google” after mapping your destination to activate the assistant.

Voice guidance is handy for both new and old places, like when you’re running errands and need to navigate hands-free.

Add multiple stops

Keep your trip going

If you walk regularly to run errands, Google Maps has a simple yet effective feature that can help you plan your route in a better way. With Maps’ multiple stop feature, you can add several stops between your current and final destination to minimize any wasted time and unnecessary detours.

To add multiple stops on Google Maps, search for a destination, then tap “Directions.” Select the walking option, then click the three dots on top (next to “Your Location”), and tap “Edit Stops.” You can now add a stop by searching for it and tapping “Add Stop,” and swap the stops at your convenience. Repeat this process by tapping “Add Stops” until your route is complete, then tap “Start” to begin your journey.

You can add up to ten stops in a single route on both mobile and desktop, and use the journey for multiple modes (walking, driving, and cycling) except public transport and flights. I find this Google Maps feature to be an essential tool for travel to walkable cities, especially when I’m planning a route I am unfamiliar with.


More to discover

A new feature to keep an eye out for, especially if you use Google Maps for walking and cycling, is Google’s Gemini boost, which will allow you to navigate hands-free and get real-time information about your journey. This feature has been rolling out for both Android and iOS users.



Source link