Building an Android App Discovery Site with AppBrain API and Swagger

Welcome to our engineering blog! In the upcoming series of short technical blog posts, we will be sharing our experiences about developing FreeAppy, an Android app discovery site.

It takes you step by step through the process how we developed this site. We hope that our posts will be informative and useful to other developers who are working on similar projects.

FreeAppy is a website that helps users discover the best free apps available on the Google Play Store. It is built with Astro, AppBrain API, and ChatGPT.

Getting the data about Android apps is the most important aspect of this app discovery website. Fortunately, the AppBrain API offers an easy-to-use way to get this data. Their API is described with the OpenAPI specification, this makes it possible to automatically generate an API client for it.

We are using the Astro web framework which is using TypeScript, therefore our API client needs to be generated in Typescript aswell.

A very easy to use tool for this is swagger-typescript-api.

This command creates a TypeScript API client for the AppBrain API:

pnpx swagger-typescript-api \
  -p https://api.appbrain.com/v2/swagger.json \
  --api-class-name AppBrainApi -n appbrainApi.ts

The generated client code is in appbrainApi.ts. The snippet below shows how to instantiate and setup the API client. The customFetch part is needed to handle error messages in case of an error.

const token = import.meta.env.API_KEY;

export const appbrainApi = new AppBrainApi({
  customFetch: (...params) => {
    const url = params[0].toString();
    return fetch(...params).then(async (response) => {
      if (!response.ok) {
        const text = await response.text();
        return new Response(JSON.stringify({ message: text }), {
          status: response.status,
          statusText: response.statusText,
        });
      } else {
        return response;
      }
    })}
});
appbrainApi.setSecurityData(token);

Fetch lists of apps using the browseApps method:

const response = await appbrainApi.info.browseApps({
  category: "GAMES",
  sort: 'HOT-DAY',
  limit: 20,
  offset: 0
});

To get started, we first need to obtain an API key from AppBrain. The signup is quite simple, once you have the key you can place it in your .env file to make it available to the web app via import.meta.env.API_KEY.

In conclusion, fetching data with the a Swagger/OpenAPI has been a straightforward process and it can be an excellent way to start building an Android app discovery site. In the next post we will look into setting up an Astro project and display the app information.

Thank you for reading and we look forward to sharing more of our experiences with you!


FreeAppy Launch!

We are thrilled to announce the launch of our new website, freeappy.com! This website is designed to help Android users easily browse and find their favorite apps in the Google Play store.

We understand that finding the right app can sometimes be a daunting task. With so many options available, it can be hard to know where to start. That’s why we created a website that is optimized for mobile use to provide users with an easy-to-use interface that simplifies the search process.

Whether you’re looking for the latest game to pass the time, a productivity app to help you stay on top of your work, or a social media platform to connect with friends, FreeAppy.com has you covered.

Our team of developers has worked hard to ensure that FreeAppy.com is easy to navigate, with a clean and user-friendly interface. We believe that finding the perfect app should be a hassle-free experience, and that’s exactly what we’ve delivered.

So why wait? Check out freeappy.com today and discover the best apps that Google Play has to offer. We’re confident that you’ll love our website as much as we do!


About

FreeAppy.com is an Android app discovery site. We try to offer a clean and simple mobile website to find fun apps and games.