An external web API is an API that is designed to be accessed by a larger population in addition to web developers. We refer to external web APIs implemented in languages as wrappers because they strongly encapsulate the functions and interfaces provided by the native web API into an easy-to-use library. Libraries provide simple methods that interact with the whole service, eliminating the need to manually write the HTTP requests to the various endpoints.
API wrappers, both internal and external, have various characteristics that distinguish them from one another, making some more appropriate and useful for certain use cases than others. In this guide, we’ll evaluate, in no particular order, some of the most popular external APIs available in Rust, including:
We’ll assess each of the above APIs according to the following criteria:
Finally, we’ll outline some steps to help you choose the best external web API for your Rust project.
The native Spotify web API gives access to a set of endpoints, each with its own unique path. Like many other wrappers on this list, authentication by API key or OAuth is mandatory to access the Spotify web API.
The most popular Spotify Rust web API wrappers are aspotify
and rspotify
.
aspotify
aspotify
is a Rust wrapper for the Spotify API. It provides Rust structures around all of Spotify’s Object Model and functions around all its endpoints.
aspotify
uses reqwest
to handle API calls. At the moment, it supports all stable Spotify features. There are also plans to add support for other Rust HTTP clients, which would be a huge breakthrough for Rust developers who prefer working with agnostic libraries.
One drawback is aspotify
‘s relative lack of documentation. That said, the repository contains a great showcase of examples to help newcomers get started.
rspotify
rspotify
is a robust and lightweight wrapper for the Spotify Web API. It contains functions for all of Spotify’s endpoints, from fetching metadata to accessing user information (following users, artists and playlists, saved tracks management, etc.). As you might imagine, this web API also requires authentication.
rspotify
’s muse is Spotipy, a popular python Spotify web API. Like aspotify
, rspotify
uses reqwest
under the hood, but it has better support and documentation along, plus useful code examples. It looks ready to hop on your production code.
egg-mode
egg-mode
is a Rust library that interacts with the Twitter public API. Although the Twitter API is massive, egg-mode
still aims to implement the entire public API and make it as easy as possible for anybody to work with the Twitter API in Rust.
In egg-mode
, the endpoints are available as naked functions, which is interesting because, unlike other external web APIs, the authentication details are added as arguments rather than as a root worker.
Compared to other Rust Twitter wrappers, egg-mode
is quite new. Nonetheless, it is complete and stable enough to use in production. The library is quite popular, well-maintained and documented, and replete with great examples that cover most use cases.
Discord offers a mature API interface to help its robust and active community create third-party apps. Fortunately, there are two stable libraries to facilitate this interaction in Rust: serenity
and discord-rs
.
serenity
serenity
is a renowned Rust library for the Discord API that enables you to create full-fledged Discord bots. You can access the entire Discord API and perform actions such as sending messages, mentioning users, voice channel actions, getting/sending reactions, etc. serenity
‘s cutting edge features range from high- to low-level interfaces.
serenity
authenticates seamlessly to the API using Client::new(<token>)
, in which you provide your Discord bot token. After this, you can interact with the API. serenity
enables you to check your previous tokens with validate_token
, which is a plus for scalability.
This library is unique because it automatically handles sharded connections and caching, which simplifies complexity and avoids unnecessary HTTP requests to the Discord API.
Serenity is a pure joy to work with. It has a plethora of well-explained examples, its own Discord server, great maintenance/release schedule, issue management, and extensive documentation.
Pro tip: You can use serenity-utils
to extend serenity and provide conversions, prompts, and menu functionality for Discord bots created with serenity
.
discord-rs
discord-rs
is a Rust client library for the Discord chat client API.
With discord-rs
, after you authenticate with your bot token, you can access Discord events using a web socket connection.
The project is said to be maintained occasionally. You should not expect a lot of breaking changes nor recent updates. The documentation is well-written and includes great examples in the repository.
GitHub’s API gives you access to a panoply of features designed to help you manage repositories on GitHub. Besides being extremely reactive, the GitHub API also has a lot of endpoints which may become difficult to manage if ever you are building your next issue management bot or github action workflow.
hubcaps
hubcaps
provides a set of building blocks for interacting with the GitHub API. It provides an interface for repositories, branches, labels, deployment, issues, pulls, releases, gists, hooks, search, and teams and makes it really easy to authenticate to the Github API services.
hubcaps
is very stable and has been for quite some time. It’s reknowned for working with the GitHub API and already has a lot of closed issues. There are also numerous examples to help you get started.
octocrab
octocrab
is a third-party GitHub API client that enables you create your own GitHub integrations in Rust. It ships with a high-level, strongly typed, semantic API consisting of Rust functions that interact directly with the API and a lower-level HTTP API that enables you to extend current functions or create customized ones.
octocrab
exposes a suite of HTTP behavior that keeps using any prior authentication and configuration. This exposed API gives you great control over all the requests and responses generated from the HTTP calls.
Because GitHub changes fast, it’s difficult for a library to bind every brand new feature of the API. However, octocrab
moves quickly and pairs as much as possible with the native GitHub API. octocrab
follows current best practices for Rust without compromising the flexibility for which it’s known, enabling you to extend octocrab
‘s API and providing a strong bond around GitHub’s API.
Though octocrab
is quite new, it is a stable, well-maintained library that follows Rust conventions and is well-documented.
Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands, and inline requests.
telegram-bot
The Rust Telegram Bot Library, or telegram-bot
API, covers a wide range of Telegram bot capabilities. It gives you all the tools you need to build a full Telegram bot in just a few lines.
telegram-rs
displays a solid catalog of examples of things you may need in a bot. It’s well maintained and stable and the community is quick to follow up on issues.
teloxide
teloxide
describes itself as an elegant Telegram bots framework for Rust.
teloxide
makes the process of create a bot in Telegram delightful. It’s exquisitely designed and covers almost the whole of the Telegram bot API.
teloxide
provides a high-level Rust implementation that makes development approachable and fun. It follows the functional reactive design, has a full dialogue management subsystem, and provides strongly typed bot commands.
Aside from excellent documentation, these features prove that teloxide
was created to make the developer’s work easier. It’s production-ready and closely follows the official Telegram bot API, which changes quite frequently.
Amazon web services (AWS) is an extensive set of developer services that is known for its accessibility and completeness. AWS comprises more than 170 services ranging from database and authentication to AI and NLP products.
AWS services must have SDKs and wrappers in every existing language because these services become very important when you start working with the cloud.
rusoto_core
Rusoto is well-known in the Rust community for covering a wide range of popular AWS services, making it the premier choice for developers working with Rust and AWS.
rusoto-core
is the core crate, which contains common functionality. Rusoto separates each supported AWS service into a single crate, acting as a sort tree-shaking library in which you only use the service you need. These services are generated from the botocore
API definitions
Just like most of the web APIs listed in this guide, Rusoto requires an authentication API — which, in Rusoto, is managed by its own separate crate. This modular simplicity makes it really pleasant to work with Rusoto.
Rusoto has a thriving community and extensive documentation and is very stable and well maintained.
The following Rust libraries and packages don’t fit neatly into any of the categories listed above, but they’re still worth having in your arsenal.
urlshortener
As the name suggests, urlshortener
aims to implement as many URL shortener services as possible through a minimal interface.
let req = providers::request(long_url, &Provider::GooGl { api_key: key.to_owned() });
urlshortener
provides a long list of utilities you can use to shorten URLs; some requires authentication while others don’t.
wikipedia
Accessing Wikipedia through HTTP requests is an arduous task. There are often a lot of parameters to take care of and the results are difficult to parse through.
Fortunately, the wikipedia
library transforms the hassle of dealinth with Wikipedia endpoints into easy-to-use Rust functions.
wikipedia
is the only library of its kind that is widely available. It’s already stable, well-documented, and easy to learn.
pusher
Pusher helps you build real-time features and push notifications in your web and mobile apps.
pusher-rs
provides bindings for the Pusher REST API in Rust. It enables you to trigger events on your frontend and access the content of your Pusher channels. This content includes meaningful information about your application’s channels, properties, and, for presence-channels, the users currently subscribed to them.
pusher
has robust documentation and well-structured code and is incredibly stable for production use.
slack-hook
slack-hook
is a Rust crate designed exclusively for sending messages to Slack via webhooks. It can be used to connect any Rust app to your Slack workspace within a few lines.
slack-hook
is a very popular Rust crate because it gets the job done fast. It has very good documentation and is quite stable.
rants
NATS.io is an open-source messaging system for cloud-native applications, IoT messaging, and microservices architectures.
rants
is a thin wrapper over the NATS client protocol. The easiest way to learn to use the client is by reading the NATS client protocol documentation, which covers all of the provided protocols.
A highlight of rants
is that it allows you to select your preferred TLS support between the native-tls
and rustls
crates.
rants
is a very stable wrapper. It follows the concepts and terminologies used in the NATS client protocol. It is up to date and well-maintained.
We covered a lot of Rust external web APIs in this guide, but that’s still just the tip of the iceberg. Though this list is not exhaustive, it is comprehensive enough to give you an idea of what to look for when selecting an external Rust web API to use in production.
There are several criteria to consider when looking for a good open-source library for your Rust project. Here’s a quick cheat sheet you can reference the next time you’re looking for an external web API in Rust:
yahoo-weather
). Another useful resource for Rust developers is Awesome Rust, a curated list of Rust librariesrust-doc
. By opening the different modules, you can visualize how they’re used in practice and the parameters they take. Some packages, such as rusoto, have custom-made docs that are popular among the community because they are much more approachable
Debugging Rust applications can be difficult, especially when users experience issues that are hard to reproduce. If you’re interested in monitoring and tracking the performance of your Rust apps, automatically surfacing errors, and tracking slow network requests and load time, try LogRocket.
LogRocket is like a DVR for web and mobile apps, recording literally everything that happens on your Rust application. Instead of guessing why problems happen, you can aggregate and report on what state your application was in when an issue occurred. LogRocket also monitors your app’s performance, reporting metrics like client CPU load, client memory usage, and more.
Modernize how you debug your Rust apps — start monitoring for free.
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up nowMaking carousels can be time-consuming, but it doesn’t have to be. Learn how to use React Snap Carousel to simplify the process.
Consider using a React form library to mitigate the challenges of building and managing forms and surveys.
In this article, you’ll learn how to set up Hoppscotch and which APIs to test it with. Then we’ll discuss alternatives: OpenAPI DevTools and Postman.
Learn to migrate from react-native-camera to VisionCamera, manage permissions, optimize performance, and implement advanced features.