First Steps

Introduction

In this tutorial we'll use the API to find out what Justin Bieber has been up to lately. We'll do everything in your web browser using the GET v1/search endpoint.

📘

Things you'll need

To follow this tutorial you'll need:

  • Your API key
  • A text editor
  • A web browser
  • Access to the internet

Let's go!

Step 1

Open your text editor. We're going to use this to write our query before we use it.

Step 2

In the editor, paste the following URL:

https://api.newswhip.com/v1/search?q=YOUR_SEARCH_TERM&key=YOUR_API_KEY

The first part of this, before the ?, is where the v1/search endpoint lives. This endpoint lets you perform simple keyword searches for the last 24 hour period.

The q represents the search term we want to use. The key represents the API key you use to authenticate.

Step 3

We want to search for Justin Bieber, so we'll want to replace YOUR_SEARCH_TERM in the URL with that. Before we do, we'll format this properly. In URLs %20 represents a space, so we're going to use Justin%20Bieber.

Your URL should now look like this:

https://api.newswhip.com/v1/search?q=Justin%20Bieber&key=YOUR_API_KEY

Step 4

Next, we'll insert our API key. Without this we won't get any results from the API. Your API key is unique to your account.

Your URL should now look something like this:

https://api.newswhip.com/v1/search?q=Justin%20Bieber&key=abG6r308li

Step 5

Copy what you have and open your web browser. Paste the URL into the address bar and press enter. Something like this will appear:

10791079

What you're seeing is the raw response that our API gives. It's in a format called JavaScript Object Notation (JSON). This is a structured format that makes it easy for software to read the data.

Step 6

We're going to make this easier for you to read and browse through. Select everything, copy it, and then go to jsonprettyprint.com.

Step 7

Paste the JSON data you just copied into the box and click the Pretty Print JSON button. The page will update and the JSON will be presented in a format that's easier to read.

10761076

Take a look through the output. You can see some of the data that NewsWhip calculates, like our prediction for the number of interactions the content will get, and you can see information about the posts that match your search.

What's next?

Now that you've seen how to play with one of our APIs in your browser, you may want to: