Questions? Feedback? powered by Olark live chat software

Making your first API request

Hello there! This getting started tutorial is meant for technical folks who aren't too familiar with APIs and want a zero-to-hero guide to grabbing data out of the appFigures API. If you're interested in more advanced topics just skip on down to the Next steps section below.

Starting out

Congrats on getting started with the appFigures API!

We'll get our feet wet by making some really simple API requests and then we'll talk about the next steps you can take to get all the information you need out of the API in a format that works for you.

When getting started with anything in life, there's really nothing more heart-warming than a list of sequential steps to follow, so let's start this off on the right foot:

1. Register an API Client

Before we can really do anything with the API we need to create what's called a client. We use our client's key to identify ourselves every time we make an API request. This is done so that the API knows exactly who is making the request, especially if we ever need to make requests on behalf of someone else (which we won't in this tutorial).

  1. Head on over to https://appfigures.com/developers/keys
  2. If you haven't already made an API client, go ahead and click the button to create a new one. If you already have one that you'd like to use just click it and skip to step 4.
  3. Give your new client a name. Make it something meaningful; if you plan on creating a full-blown app, this is the name your users will see when they log in. Next you'll need to choose permissions, or features your client will need access to. If you're not sure which permissions to choose just select "Read" for all of them. Remember, you can always delete clients and make new ones as needed.
  4. You'll now be presented with two different keys: a client key and a secret key. For the purpose of this tutorial we'll only be using the client key, so go ahead and copy that long alpha-numeric string to your clipboard.

2. Create the request

There are several ways to make API requests but let's use the simplest one: your trusty web browser. While it limits the type of requests we can make (after all browsers weren't built for this kind of thing), it's perfect for our humble needs at the moment. All we need to do is plop a url with the following format into our browser and it'll present us with the result from the API in the same way it usually presents us with web pages:

http://api.appfigures.com/v{version}/{some/route}?client_key={our_client_key}

Before we can actually use this link we'll need to replace {version} with the version of the API we want to use, {some/route} with the specific resource we need (e.g reviews, sales, ranks), and the last one, well, you get the idea.

Okay, enough theory. Let's start by asking the API for a list of all the countries it supports. Copy the link below into your browser, replace {your_client_key} with your client key (should be in your clipboard from step 4 above) and hit enter:

http://api.appfigures.com/v2/data/countries?client_key={your_client_key}

3. Authenticate

If everything went well your browser will now prompt you for a user name and password (this is called the Basic Auth way of authenticating, as opposed to OAuth for example). Enter the credentials for your appFigures account. If you have multiple accounts, use the one you created your API client with.

4. Rejoice!

You should now be presented with the list of every country supported by the API in the raw JSON format. It should look something like this:

{
  "AD": {
    "iso": "AD",
    "name": "Andorra",
    "apple_store_no": ""
  },
  "AE": {
    "iso": "AE",
    "name": "UAE",
    "apple_store_no": "143481"
  },
  "AF": {
    "iso": "AF",
    "name": "Afghanistan",
    "apple_store_no": ""
  },
  . . .
}

Time to play

You'll notice that we chose the data/countries route for the previous request, which is one of the many available routes (though arguably one of the less exciting ones). Each route represents a type of data that the API deals with. Let's try some more interesting ones:

The reviews route

Fetch the first 100 reviews of all the apps in your account:

http://api.appfigures.com/v2/reviews?count=100&client_key={your_client_key}

Read more about the reviews route →

The sales route

Fetch your all time sales stats for all your apps:

http://api.appfigures.com/v2/sales?client_key={your_client_key}

Read more about the sales route →

Now that you can make simple GET requests using your browser you can start exploring the API with the API Reference as your guide. Read about different routes to see what they do and then paste them into the browser. Try different values for the input parameters to unleash the API's full potential.

Some cool things to try

  • Translate your reviews - If we teak the reviews example above to include the parameter lang=es, all the reviews will be translated to Spanish:

    http://api.appfigures.com/v2/reviews?count=100&lang=es&client_key={your_client_key}
    

    You can read about all the reviews route's options right here.

  • Export as CSV - The default output format of the API is JSON but some routes can also output CSV (which Excel can import). These routes include Sales, Ads, and Ranks. See the API reference for detailed information on how to use these, but the gist is that you need to add the format parameter to your request with the value csv. For example:

    http://api.appfigures.com/v2/sales?format=csv&client_key={your_client_key}
    
  • Access public data - By default the API will only let you access public data about your own apps. If you're interested in market research and tracking other apps should check out Partner API Access.

Next steps

Using a programing language you'll be able to make any type of request (not just GET) and customize your output format to suite your specific needs. To get started check out some of the sample code we have available.

Use OAuth

In this tutorial we focused on using Basic Auth to authenticate with the API, which is great when we need to get data out of our own appFigures account. If you'd like build an API client which other appFigures members can use by logging in with their credentials you'll need to use OAuth. You can read more about authenticating and OAuth over at the documentation area.