Introduction

What is an API?

An API ("application programming interface") is nothing new if you're a programmer. You've been using them any time you call a function or class from a codebase you didn't write. Another programmer wrote some useful code and provided you with nothing more than instructions on how to call that code. You know nothing about how it's implemented and you don't need to in order to use it. All you need to know is what goes in and what comes out.

A web API is very similar. A website or service exposes an "endpoint" which you can think of as a function you can call. You call that endpoint by sending an HTTP request (usually GET or POST) to its URL. The endpoint will then process your request and do something with it, usually by sending back data in the form of JSON or XML.

What is Reddit?

Reddit is one of the most popular social network platforms on the internet. It's essentially an internet forum where each board is called a "subreddit". Users can create their own subreddits which has allowed Reddit to provide dedicated discussion to an extremely large plethora of interests, both mainstream and niche. Users are also able to create posts, comments, like and dislike others' posted content, and send private messages to other users.

The Reddit API

The Reddit API allows programmatic control of virtually every function a user can perform on the site. This not only allows for apps that can completely recreate the site with a new interface, but also allows for the creation of bots that can expand site functionality.

In this guide I'll explain the concepts of the Reddit API, how to use it, and show you how to make a useful bot with the API.