DEV Community

Cover image for Fast track yourself through hackathons with APIs
John Pham
John Pham

Posted on • Updated on • Originally published at pham.codes

Fast track yourself through hackathons with APIs

You're at a hackathon, have a stellar team, and a really cool idea but only 24-36 hours to work on it. Your team could implement everything from scratch. If your goal is to learn then do that! If you want to test an idea then you should leverage APIs and focus on building what makes your idea unique.

What's an API?

An API is an Application Programming Interface. Think of this as a function you can call from your application to do work such as: identifying puppies in an image and storing the location of your favorite coffee shops in a database.

It doesn't matter if you're building a web application, mobile app, or virtual reality game. APIs are platform agnostic so you can use them no matter what you're building.

Most APIs are either completely free or paid once you past a certain usage. For most hackathon projects, you'll stay in the free tiers. If your project becomes an overnight success then you'll have to start looking at the paid tiers.

There are pretty much APIs that do anything you could want! You can find APIs in this list, the GitHub Student Developer Pack, and from your hackathon's sponsors.


Here's a general workflow you can use during a hackathon:

  1. Identify a feature
  2. Find an API to help implement that feature
  3. Find documentation and code examples for the API
  4. Add the API to your application

Now let's walk through an example:

  1. I want to build an application to show Pokemon
  2. I've found the PokéAPI that can provide me the data
  3. Found the documentation
  4. I can add the API by creating my own client or using a wrapper library

Let's take a deeper look at steps 3 and 4.

The documentation

Before you choose to use an API, make sure it fulfills your requirements. Next you'll want to look at the documentation and ask:

  1. Are there a lot of code examples?
  2. Are all the parameters defined?
  3. How much can I use this API before I have to start paying?
  4. Is there a community around the API? Slack, Reddit, Twitter, StackOverflow, etc.

These are all signs of a well-maintained API. A well-maintained API means that if you run into a problem, you can usually find someone to help.

Using the API

If you don't know how REST and Request Methods works, please read Understanding REST and REST APIs.

Request Methods are how your application will communicate with APIs. Everyone programming language has it's own way of using Request Methods.


Going back to our example, we want to get show Pokemons in our application. From reading the documentation, there is the /api/v2/pokemon endpoint.

The documentation shows which Request Method to use (GET), what parameters we can use ({id or name}), and what the expected response is.

Before using this API directly in our application, let's test the API using a GUI tool. The benefits of using GUI tools includes iterating quickly without having to rebuild your application and having code exported from the GUI which you can use directly in your application.

For this example we will be using Postman, but you can also use Insomia and Postwoman.


With Postman, we want to make a GET request to https://pokeapi.co/api/v2/pokemon endpoint. Clicking send with make the request, we'll then see Pokemon data below.

Postman

What if we want to lookup a specific Pokemon? Say Charizard? From the documentation, all we have to do is add the name of the Pokemon we want to lookup to the endpoint: /pokemon/charizard.

Postman

We've successfully made API calls to get all the Pokemon and a specific Pokemon! Let's add this to our application now. A handy feature of Postman is it allows you to export your request to code.

You can access this feature by clicking Code then select the language you want to export to.

Postman

Wrapping up

You've learned how to leverage APIs during hackathons, how quickly iterate using a GUI tool, and export code. With this, you can focus on building what makes your project unique during the hackathon.

Top comments (3)

Collapse
 
cishiv profile image
Shivan Moodley

I really like this post. Hackathon solutions are a perfect case study for API first design. Determining data in and data out super early and then implementing something quickly.

Collapse
 
sebhani profile image
Hani

Awesome Post!! I liked the part where you mentioned Postman. I think using a GUI tool to verify results would ease and help avoiding additional unnecessary work!

Collapse
 
johnphamous profile image
John Pham

Thanks! 😁