Blog
{Blog}  See what’s new with MongoDB 6.0 — and why you’ll want to upgrade today >>

Building a REST-like API with MongoDB

One of the big questions that is asked about MongoDB is, “Does MongoDB have a REST API?” The aim of this article is to answer this question once and for all, and show you examples of how to get started with the new REST-like Atlas Data API.

REST-like API vs Drivers

The most common way of accessing data from your projects has traditionally been using drivers. MongoDB has drivers for many different programming languages. These allow you to call various functions, including covering the Create, Read, Update, Delete (CRUD) operations, from within your project in the language of your choice.

We have many articles on how to get up and running using MongoDB drivers for your language of choice. So if you wish to use drivers, this is still a valid option.

Below is a list of some existing tutorials using current drivers, potentially in your language/framework of choice:

However, there are times when you might not want to use a driver—for example, if it is a purely command-line based application or script, such as one that relies on cURL for sending REST or GraphQL requests via HTTP.

Installing drivers and creating endpoints for your application that can make calls to the database can take time, and if you have a very simple use case, such as just CRUD, this extra overhead is unnecessary. This is where the new MongoDB Atlas Data API comes in.

What is the new Atlas Data API?

Atlas Data API is a fully managed REST-like API, to allow you to access your MongoDB Atlas data, and perform CRUD operations and aggregations with ease.

Once enabled on a cluster, you can achieve all the CRUD operations out of the box via a URL, with just an API key.

Learn more about how to make your first REST-like API calls with the new Data API and cURL.

Using the new Atlas Data API from different languages

As well as cURL, you can call the Data API from a variety of languages. All it needs is a way to make HTTP calls.

In fact, in Atlas, we even give you code snippets in different languages, right from the UI, to get you started making calls to find a document.

  1. Click the “Data API (Preview)” option from the left-hand sidebar.

Screenshot of Atlas, highlighting the Data API option in left-hand side menu

  1. Click the “Test Your API” button in the top right corner.

Screenshot of Data API page in Atlas, showing Test your API button in the top right

  1. Select your Cluster, Database, and Collection from the dropdown menus, and then select the language that you want from the dropdown box at the bottom.

Screenshot showing the Test Out Your API modal page that generates a code snippet in different languages based on the cluster, database and collection selected

Learn more about other operations, such as writing a document, you can make in our Data API documentation.

Summary

In this article, you have learned about how you can get started today with the new Atlas Data API, without needing to create your own endpoints. When you don’t require a full application, just the CRUD operations, the Atlas Data API gets you started with ease in just a few minutes. You can even get help from the Atlas UI to get you kickstarted with code snippets for your favourite language.

FAQ

Does MongoDB have a REST-like API?

Yes! Thanks to the new MongoDB Atlas Data API, you can perform CRUD operations on your fully-managed cloud hosted data right away, without needing to install drivers or write any code!

As well as this, we also have the Atlas Administration API, a way to manage your Atlas resources including adding, editing, or deleting administrative objects within Atlas, such as projects, users, and database deployments.

If you use Realm, you also have access to the Realm Admin API to allow you to manage things such as functions, rules, and authentication providers.