Skip to content
Skip to main content

How to list Yahoo email messages

Last updated:

Yahoo Mail doesn’t have a public REST API. There’s no equivalent to Gmail’s API or Microsoft Graph. Internally, Nylas connects to Yahoo accounts over IMAP, but you don’t need to deal with IMAP protocols, socket connections, or MIME parsing yourself. The same Messages API you use for Gmail and Outlook works for Yahoo.

This guide covers listing messages from Yahoo accounts, including the OAuth setup process, the 90-day message cache, and how to reach older messages when you need them.

Yahoo doesn’t publish a public REST API for Mail. The only programmatic access is IMAP for reading and SMTP for sending, authenticated through Yahoo’s OAuth 2.0 host at api.login.yahoo.com. There’s no equivalent to the Gmail API or Microsoft Graph, so an integration either speaks IMAP directly or goes through a service that wraps it.

That host, api.login.yahoo.com, is where the OAuth authorization and token requests go once Yahoo issues you credentials, which requires signing a Commercial Access Agreement first. Reading mail still happens over IMAP, which exposes the last 90 days through the message cache. This guide uses a unified REST layer so you read Yahoo mail with the same call you’d use for Gmail or Outlook.

How do I list Yahoo Mail messages with the Nylas API?

Section titled “How do I list Yahoo Mail messages with the Nylas API?”

Send a GET request to /v3/grants/{grant_id}/messages with your API key. Nylas connects to Yahoo over IMAP and returns the 50 most recent messages by default, up to 200 per page, in the same JSON schema used for Gmail and Outlook. Authenticate with OAuth or an app password. See List messages for the request and response.

Yahoo’s only developer-facing email interface is raw IMAP. That means building your own connection pooling, MIME parsing, and sync infrastructure from scratch. On top of the protocol complexity, Yahoo OAuth requires signing a Commercial Access Agreement before you can even get API credentials, and the IMAP search implementation has known gaps (no NOT operator support, for example).

Nylas wraps all of that in a REST API with JSON responses. You don’t need to sign Yahoo’s agreement yourself, manage IMAP sockets, or work around IMAP search limitations. Your code works across Yahoo, Gmail, Outlook, and every other provider without modification.

If you’re only targeting Yahoo and are comfortable with IMAP, you can connect directly. For everything else, Nylas saves you significant development time.

You’ll need:

Yahoo requires a few extra steps compared to Google or Microsoft. You’ll need to:

  1. Request API access by submitting the Yahoo Mail API Access form. Yahoo will send you a Commercial Access Agreement to sign.
  2. Create a Yahoo app by registering your application in the Yahoo Apps dashboard to get a client ID and secret.
  3. Create a Yahoo connector in Nylas and configure it with your Yahoo client ID and secret.

Yahoo OAuth scopes are simpler than Google’s tier system:

Access levelScopes required
Read-onlyemail, mail-r
Read-writeemail, mail-r, mail-w

You can only select one access level. Yahoo doesn’t let you request both mail-r and mail-w separately.

If you’d rather skip the OAuth setup for testing, you can also authenticate Yahoo accounts using IMAP with an app password. This uses the imap provider type instead of yahoo and requires each user to generate an app password in their Yahoo account settings. OAuth is the better choice for production apps.

The full setup walkthrough is in the Yahoo authentication guide.

Make a List Messages request with the grant ID. By default, Nylas returns the 50 most recent messages. These examples limit results to 5:

Yahoo Mail connects over IMAP, so you authenticate with OAuth or an app password and then read the mailbox the same way. The Nylas CLI lists it from your terminal: nylas email list returns the 10 most recent inbox messages through the Messages API, with no code required.

The Nylas CLI mirrors the Messages API, so you can read the same inbox from your terminal without writing any code. After nylas init and nylas auth login, the email list command returns the 10 most recent inbox messages by default and pages through everything automatically once --limit goes over 200:

# List the 10 most recent inbox messages
nylas email list
# Show only unread messages from a specific sender
nylas email list --unread --from [email protected]
# Fetch everything across all folders, paginated automatically
nylas email list --all --all-folders --max 500

To find specific messages rather than list them, email search runs a full-text query with its own filters for sender (--from), date range (--after and --before), and attachments (--has-attachment). Search returns 20 results by default and only fetches more than one page once --limit goes over 200:

# Full-text search restricted to one sender, attachments only
nylas email search "invoice" --from [email protected] --has-attachment

Both commands accept --json, so you can pipe results into jq or a script. See the email list and email search command reference for every flag.

Yahoo exposes plain IMAP folder names, so --folder takes a readable value directly without an ID lookup. The one to remember is spam: Yahoo calls that folder Bulk Mail, not Junk or Spam. List the folders on an account, then read the flagged messages by name:

# See every folder name on the account, including custom ones
nylas email folders list
# Read the messages Yahoo flagged as spam
nylas email list --folder "Bulk Mail"

The cache keeps about 90 days of Yahoo mail searchable. To send Yahoo mail from the same command line, see Send email from the terminal.

You can narrow results with query parameters. Here’s what works with Yahoo accounts:

ParameterWhat it doesExample
subjectMatch on subject line?subject=Weekly standup
fromFilter by sender[email protected]
toFilter by recipient[email protected]
unreadUnread only?unread=true
inFilter by folder or label ID?in=INBOX
received_afterAfter a Unix timestamp?received_after=1706000000
received_beforeBefore a Unix timestamp?received_before=1706100000
has_attachmentOnly results with attachments?has_attachment=true

Here’s how to combine filters. This pulls unread messages from a specific sender:

Yahoo supports the search_query_native parameter for IMAP-style search. The in, limit, and page_token co-parameter restriction that Google and Microsoft enforce isn’t documented for Yahoo, so you can pair search_query_native with standard filters like from and subject.

See the search best practices guide for more on search_query_native across providers.

Yahoo is IMAP-based, which means it behaves differently from Google and Microsoft in a few important ways.

This is the most important Yahoo-specific detail. Nylas maintains a rolling cache of messages from the last 90 days. Anything received or created within that window is synced and available through the API. Messages older than 90 days aren’t in the cache, but you can still reach them by setting query_imap=true to query Yahoo’s IMAP server directly. This is slower due to provider latency, but it gives you access to the full mailbox.

When using query_imap, you must include the in parameter to specify which folder to search.

Nylas webhooks only fire for changes to messages within the 90-day cache window. If a user modifies or deletes a message older than 90 days, you won’t receive a notification. Plan your sync strategy accordingly if your app needs to track changes across the full mailbox.

Unlike Microsoft’s internal names (sentitems, deleteditems) or Google’s label system, Yahoo uses straightforward IMAP folder names:

Yahoo UI nameFolder ID
InboxInbox
SentSent
DraftDraft
TrashTrash
Bulk Mail (Spam)Bulk Mail
ArchiveArchive

Custom folders created by the user appear with their display names. Use the List Folders endpoint to get the complete list for a given account.

Yahoo doesn’t publish its API rate limits. If your app hits a rate limit, the response will include the duration you need to wait before retrying. Nylas handles retries automatically, but if you’re making a high volume of requests for many Yahoo users, you may see throttling.

As with other providers, webhooks are the best way to avoid hitting rate limits. Let Nylas notify you of changes instead of polling.

Yahoo accounts in Nylas use IMAP for reading and SMTP for sending. This is invisible to your code, but it explains a few behaviors:

  • Sync is slower than Google or Microsoft because those providers have native APIs with push notifications. Yahoo relies on periodic IMAP polling.
  • Message IDs are IMAP UIDs, which are numeric values like 12345 that are unique within a folder but may not be globally unique across the account.
  • Thread grouping relies on subject-line and header matching rather than a native threading system. This works well for most conversations but isn’t as precise as Gmail’s built-in thread_id.

Yahoo supports two authentication methods in Nylas:

MethodProvider typeBest for
Yahoo OAuthyahooProduction apps that want a smooth sign-in, no app passwords needed
IMAP with app passwordimapTesting or apps where users already manage app passwords

Yahoo OAuth is the recommended approach. It gives you a proper OAuth consent flow and doesn’t require users to create app passwords. See the Yahoo authentication guide for both methods.

The Messages API returns paginated responses. When there are more results, the response includes a next_cursor value. Pass it back as page_token to get the next page:

Keep paginating until the response comes back without a next_cursor.